1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "FrozenImage.h"
11 using layers::ImageContainer
;
12 using layers::LayerManager
;
16 void FrozenImage::IncrementAnimationConsumers() {
17 // Do nothing. This will prevent animation from starting if there are no other
18 // instances of this image.
21 void FrozenImage::DecrementAnimationConsumers() {
26 FrozenImage::GetAnimated(bool* aAnimated
) {
28 nsresult rv
= InnerImage()->GetAnimated(&dummy
);
29 if (NS_SUCCEEDED(rv
)) {
35 NS_IMETHODIMP_(already_AddRefed
<SourceSurface
>)
36 FrozenImage::GetFrame(uint32_t aWhichFrame
, uint32_t aFlags
) {
37 return InnerImage()->GetFrame(FRAME_FIRST
, aFlags
);
40 NS_IMETHODIMP_(already_AddRefed
<SourceSurface
>)
41 FrozenImage::GetFrameAtSize(const IntSize
& aSize
, uint32_t aWhichFrame
,
43 return InnerImage()->GetFrameAtSize(aSize
, FRAME_FIRST
, aFlags
);
47 FrozenImage::IsImageContainerAvailable(LayerManager
* aManager
,
52 NS_IMETHODIMP_(already_AddRefed
<ImageContainer
>)
53 FrozenImage::GetImageContainer(layers::LayerManager
* aManager
,
55 // XXX(seth): GetImageContainer does not currently support anything but the
56 // current frame. We work around this by always returning null, but if it ever
57 // turns out that FrozenImage is widely used on codepaths that can actually
58 // benefit from GetImageContainer, it would be a good idea to fix that method
59 // for performance reasons.
64 FrozenImage::IsImageContainerAvailableAtSize(LayerManager
* aManager
,
70 NS_IMETHODIMP_(ImgDrawResult
)
71 FrozenImage::GetImageContainerAtSize(layers::LayerManager
* aManager
,
72 const gfx::IntSize
& aSize
,
73 const Maybe
<SVGImageContext
>& aSVGContext
,
75 layers::ImageContainer
** aOutContainer
) {
76 // XXX(seth): GetImageContainer does not currently support anything but the
77 // current frame. We work around this by always returning null, but if it ever
78 // turns out that FrozenImage is widely used on codepaths that can actually
79 // benefit from GetImageContainer, it would be a good idea to fix that method
80 // for performance reasons.
81 return ImgDrawResult::NOT_SUPPORTED
;
84 NS_IMETHODIMP_(ImgDrawResult
)
85 FrozenImage::Draw(gfxContext
* aContext
, const nsIntSize
& aSize
,
86 const ImageRegion
& aRegion
,
87 uint32_t /* aWhichFrame - ignored */,
88 SamplingFilter aSamplingFilter
,
89 const Maybe
<SVGImageContext
>& aSVGContext
, uint32_t aFlags
,
91 return InnerImage()->Draw(aContext
, aSize
, aRegion
, FRAME_FIRST
,
92 aSamplingFilter
, aSVGContext
, aFlags
, aOpacity
);
96 FrozenImage::StartDecoding(uint32_t aFlags
, uint32_t aWhichFrame
) {
97 return InnerImage()->StartDecoding(aFlags
, FRAME_FIRST
);
100 bool FrozenImage::StartDecodingWithResult(uint32_t aFlags
,
101 uint32_t aWhichFrame
) {
102 return InnerImage()->StartDecodingWithResult(aFlags
, FRAME_FIRST
);
105 imgIContainer::DecodeResult
FrozenImage::RequestDecodeWithResult(
106 uint32_t aFlags
, uint32_t aWhichFrame
) {
107 return InnerImage()->RequestDecodeWithResult(aFlags
, FRAME_FIRST
);
111 FrozenImage::RequestDecodeForSize(const nsIntSize
& aSize
, uint32_t aFlags
,
112 uint32_t aWhichFrame
) {
113 return InnerImage()->RequestDecodeForSize(aSize
, aFlags
, FRAME_FIRST
);
117 FrozenImage::RequestRefresh(const TimeStamp
& aTime
) {
122 FrozenImage::GetAnimationMode(uint16_t* aAnimationMode
) {
123 *aAnimationMode
= kNormalAnimMode
;
128 FrozenImage::SetAnimationMode(uint16_t aAnimationMode
) {
134 FrozenImage::ResetAnimation() {
139 NS_IMETHODIMP_(float)
140 FrozenImage::GetFrameIndex(uint32_t aWhichFrame
) {
141 MOZ_ASSERT(aWhichFrame
<= FRAME_MAX_VALUE
, "Invalid argument");
146 } // namespace mozilla