image/src/ImageMetadata.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef ImageMetadata_h___
michael@0 8 #define ImageMetadata_h___
michael@0 9
michael@0 10 #include <stdint.h>
michael@0 11 #include "mozilla/Maybe.h"
michael@0 12 #include "nsSize.h"
michael@0 13 #include "Orientation.h"
michael@0 14
michael@0 15 namespace mozilla {
michael@0 16 namespace image {
michael@0 17
michael@0 18 class RasterImage;
michael@0 19
michael@0 20 // The metadata about an image that decoders accumulate as they decode.
michael@0 21 class ImageMetadata
michael@0 22 {
michael@0 23 public:
michael@0 24 ImageMetadata()
michael@0 25 : mHotspotX(-1)
michael@0 26 , mHotspotY(-1)
michael@0 27 , mLoopCount(-1)
michael@0 28 , mIsNonPremultiplied(false)
michael@0 29 {}
michael@0 30
michael@0 31 // Set the metadata this object represents on an image.
michael@0 32 void SetOnImage(RasterImage* image);
michael@0 33
michael@0 34 void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
michael@0 35 {
michael@0 36 mHotspotX = hotspotx;
michael@0 37 mHotspotY = hotspoty;
michael@0 38 }
michael@0 39 void SetLoopCount(int32_t loopcount)
michael@0 40 {
michael@0 41 mLoopCount = loopcount;
michael@0 42 }
michael@0 43
michael@0 44 void SetIsNonPremultiplied(bool nonPremult)
michael@0 45 {
michael@0 46 mIsNonPremultiplied = nonPremult;
michael@0 47 }
michael@0 48
michael@0 49 void SetSize(int32_t width, int32_t height, Orientation orientation)
michael@0 50 {
michael@0 51 mSize.construct(nsIntSize(width, height));
michael@0 52 mOrientation.construct(orientation);
michael@0 53 }
michael@0 54
michael@0 55 bool HasSize() const { return !mSize.empty(); }
michael@0 56 bool HasOrientation() const { return !mOrientation.empty(); }
michael@0 57
michael@0 58 int32_t GetWidth() const { return mSize.ref().width; }
michael@0 59 int32_t GetHeight() const { return mSize.ref().height; }
michael@0 60 Orientation GetOrientation() const { return mOrientation.ref(); }
michael@0 61
michael@0 62 private:
michael@0 63 // The hotspot found on cursors, or -1 if none was found.
michael@0 64 int32_t mHotspotX;
michael@0 65 int32_t mHotspotY;
michael@0 66
michael@0 67 // The loop count for animated images, or -1 for infinite loop.
michael@0 68 int32_t mLoopCount;
michael@0 69
michael@0 70 Maybe<nsIntSize> mSize;
michael@0 71 Maybe<Orientation> mOrientation;
michael@0 72
michael@0 73 bool mIsNonPremultiplied;
michael@0 74 };
michael@0 75
michael@0 76 } // namespace image
michael@0 77 } // namespace mozilla
michael@0 78
michael@0 79 #endif // ImageMetadata_h___

mercurial