1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/src/ImageMetadata.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef ImageMetadata_h___ 1.11 +#define ImageMetadata_h___ 1.12 + 1.13 +#include <stdint.h> 1.14 +#include "mozilla/Maybe.h" 1.15 +#include "nsSize.h" 1.16 +#include "Orientation.h" 1.17 + 1.18 +namespace mozilla { 1.19 +namespace image { 1.20 + 1.21 +class RasterImage; 1.22 + 1.23 +// The metadata about an image that decoders accumulate as they decode. 1.24 +class ImageMetadata 1.25 +{ 1.26 +public: 1.27 + ImageMetadata() 1.28 + : mHotspotX(-1) 1.29 + , mHotspotY(-1) 1.30 + , mLoopCount(-1) 1.31 + , mIsNonPremultiplied(false) 1.32 + {} 1.33 + 1.34 + // Set the metadata this object represents on an image. 1.35 + void SetOnImage(RasterImage* image); 1.36 + 1.37 + void SetHotspot(uint16_t hotspotx, uint16_t hotspoty) 1.38 + { 1.39 + mHotspotX = hotspotx; 1.40 + mHotspotY = hotspoty; 1.41 + } 1.42 + void SetLoopCount(int32_t loopcount) 1.43 + { 1.44 + mLoopCount = loopcount; 1.45 + } 1.46 + 1.47 + void SetIsNonPremultiplied(bool nonPremult) 1.48 + { 1.49 + mIsNonPremultiplied = nonPremult; 1.50 + } 1.51 + 1.52 + void SetSize(int32_t width, int32_t height, Orientation orientation) 1.53 + { 1.54 + mSize.construct(nsIntSize(width, height)); 1.55 + mOrientation.construct(orientation); 1.56 + } 1.57 + 1.58 + bool HasSize() const { return !mSize.empty(); } 1.59 + bool HasOrientation() const { return !mOrientation.empty(); } 1.60 + 1.61 + int32_t GetWidth() const { return mSize.ref().width; } 1.62 + int32_t GetHeight() const { return mSize.ref().height; } 1.63 + Orientation GetOrientation() const { return mOrientation.ref(); } 1.64 + 1.65 +private: 1.66 + // The hotspot found on cursors, or -1 if none was found. 1.67 + int32_t mHotspotX; 1.68 + int32_t mHotspotY; 1.69 + 1.70 + // The loop count for animated images, or -1 for infinite loop. 1.71 + int32_t mLoopCount; 1.72 + 1.73 + Maybe<nsIntSize> mSize; 1.74 + Maybe<Orientation> mOrientation; 1.75 + 1.76 + bool mIsNonPremultiplied; 1.77 +}; 1.78 + 1.79 +} // namespace image 1.80 +} // namespace mozilla 1.81 + 1.82 +#endif // ImageMetadata_h___