Bumping manifests a=b2g-bump
[gecko.git] / image / src / ImageMetadata.h
blobb57dadaa4c1b12f5bed908fb1d9caf8b539d8738
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef ImageMetadata_h___
8 #define ImageMetadata_h___
10 #include <stdint.h>
11 #include "mozilla/Maybe.h"
12 #include "nsSize.h"
13 #include "Orientation.h"
15 namespace mozilla {
16 namespace image {
18 class RasterImage;
20 // The metadata about an image that decoders accumulate as they decode.
21 class ImageMetadata
23 public:
24 ImageMetadata()
25 : mHotspotX(-1)
26 , mHotspotY(-1)
27 , mLoopCount(-1)
30 // Set the metadata this object represents on an image.
31 void SetOnImage(RasterImage* image);
33 void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
35 mHotspotX = hotspotx;
36 mHotspotY = hotspoty;
38 void SetLoopCount(int32_t loopcount)
40 mLoopCount = loopcount;
43 void SetSize(int32_t width, int32_t height, Orientation orientation)
45 if (!HasSize()) {
46 mSize.emplace(nsIntSize(width, height));
47 mOrientation.emplace(orientation);
51 bool HasSize() const { return mSize.isSome(); }
52 bool HasOrientation() const { return mOrientation.isSome(); }
54 int32_t GetWidth() const { return mSize->width; }
55 int32_t GetHeight() const { return mSize->height; }
56 nsIntSize GetSize() const { return *mSize; }
57 Orientation GetOrientation() const { return *mOrientation; }
59 private:
60 // The hotspot found on cursors, or -1 if none was found.
61 int32_t mHotspotX;
62 int32_t mHotspotY;
64 // The loop count for animated images, or -1 for infinite loop.
65 int32_t mLoopCount;
67 Maybe<nsIntSize> mSize;
68 Maybe<Orientation> mOrientation;
71 } // namespace image
72 } // namespace mozilla
74 #endif // ImageMetadata_h___