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