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 mozilla_image_ImageMetadata_h
8 #define mozilla_image_ImageMetadata_h
11 #include "mozilla/Maybe.h"
14 #include "Orientation.h"
15 #include "FrameTimeout.h"
20 // The metadata about an image that decoders accumulate as they decode.
26 , mFirstFrameTimeout(FrameTimeout::Forever())
27 , mHasAnimation(false)
30 void SetHotspot(uint16_t aHotspotX
, uint16_t aHotspotY
)
32 mHotspot
= Some(gfx::IntPoint(aHotspotX
, aHotspotY
));
34 gfx::IntPoint
GetHotspot() const { return *mHotspot
; }
35 bool HasHotspot() const { return mHotspot
.isSome(); }
37 void SetLoopCount(int32_t loopcount
)
39 mLoopCount
= loopcount
;
41 int32_t GetLoopCount() const { return mLoopCount
; }
43 void SetLoopLength(FrameTimeout aLength
) { mLoopLength
= Some(aLength
); }
44 FrameTimeout
GetLoopLength() const { return *mLoopLength
; }
45 bool HasLoopLength() const { return mLoopLength
.isSome(); }
47 void SetFirstFrameTimeout(FrameTimeout aTimeout
) { mFirstFrameTimeout
= aTimeout
; }
48 FrameTimeout
GetFirstFrameTimeout() const { return mFirstFrameTimeout
; }
50 void SetFirstFrameRefreshArea(const gfx::IntRect
& aRefreshArea
)
52 mFirstFrameRefreshArea
= Some(aRefreshArea
);
54 gfx::IntRect
GetFirstFrameRefreshArea() const { return *mFirstFrameRefreshArea
; }
55 bool HasFirstFrameRefreshArea() const { return mFirstFrameRefreshArea
.isSome(); }
57 void SetSize(int32_t width
, int32_t height
, Orientation orientation
)
60 mSize
.emplace(nsIntSize(width
, height
));
61 mOrientation
.emplace(orientation
);
64 nsIntSize
GetSize() const { return *mSize
; }
65 bool HasSize() const { return mSize
.isSome(); }
67 void AddNativeSize(const nsIntSize
& aSize
)
69 mNativeSizes
.AppendElement(aSize
);
72 const nsTArray
<nsIntSize
>& GetNativeSizes() const { return mNativeSizes
; }
74 Orientation
GetOrientation() const { return *mOrientation
; }
75 bool HasOrientation() const { return mOrientation
.isSome(); }
77 void SetHasAnimation() { mHasAnimation
= true; }
78 bool HasAnimation() const { return mHasAnimation
; }
81 /// The hotspot found on cursors, if present.
82 Maybe
<gfx::IntPoint
> mHotspot
;
84 /// The loop count for animated images, or -1 for infinite loop.
87 // The total length of a single loop through an animated image.
88 Maybe
<FrameTimeout
> mLoopLength
;
90 /// The timeout of an animated image's first frame.
91 FrameTimeout mFirstFrameTimeout
;
93 // The area of the image that needs to be invalidated when the animation
95 Maybe
<gfx::IntRect
> mFirstFrameRefreshArea
;
97 Maybe
<nsIntSize
> mSize
;
98 Maybe
<Orientation
> mOrientation
;
100 // Sizes the image can natively decode to.
101 nsTArray
<nsIntSize
> mNativeSizes
;
103 bool mHasAnimation
: 1;
107 } // namespace mozilla
109 #endif // mozilla_image_ImageMetadata_h