michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef ImageMetadata_h___ michael@0: #define ImageMetadata_h___ michael@0: michael@0: #include michael@0: #include "mozilla/Maybe.h" michael@0: #include "nsSize.h" michael@0: #include "Orientation.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: class RasterImage; michael@0: michael@0: // The metadata about an image that decoders accumulate as they decode. michael@0: class ImageMetadata michael@0: { michael@0: public: michael@0: ImageMetadata() michael@0: : mHotspotX(-1) michael@0: , mHotspotY(-1) michael@0: , mLoopCount(-1) michael@0: , mIsNonPremultiplied(false) michael@0: {} michael@0: michael@0: // Set the metadata this object represents on an image. michael@0: void SetOnImage(RasterImage* image); michael@0: michael@0: void SetHotspot(uint16_t hotspotx, uint16_t hotspoty) michael@0: { michael@0: mHotspotX = hotspotx; michael@0: mHotspotY = hotspoty; michael@0: } michael@0: void SetLoopCount(int32_t loopcount) michael@0: { michael@0: mLoopCount = loopcount; michael@0: } michael@0: michael@0: void SetIsNonPremultiplied(bool nonPremult) michael@0: { michael@0: mIsNonPremultiplied = nonPremult; michael@0: } michael@0: michael@0: void SetSize(int32_t width, int32_t height, Orientation orientation) michael@0: { michael@0: mSize.construct(nsIntSize(width, height)); michael@0: mOrientation.construct(orientation); michael@0: } michael@0: michael@0: bool HasSize() const { return !mSize.empty(); } michael@0: bool HasOrientation() const { return !mOrientation.empty(); } michael@0: michael@0: int32_t GetWidth() const { return mSize.ref().width; } michael@0: int32_t GetHeight() const { return mSize.ref().height; } michael@0: Orientation GetOrientation() const { return mOrientation.ref(); } michael@0: michael@0: private: michael@0: // The hotspot found on cursors, or -1 if none was found. michael@0: int32_t mHotspotX; michael@0: int32_t mHotspotY; michael@0: michael@0: // The loop count for animated images, or -1 for infinite loop. michael@0: int32_t mLoopCount; michael@0: michael@0: Maybe mSize; michael@0: Maybe mOrientation; michael@0: michael@0: bool mIsNonPremultiplied; michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif // ImageMetadata_h___