Bug 1728955: part 8) Refactor `DisplayErrCode` in Windows' `nsClipboard`. r=masayuki
[gecko.git] / image / FrozenImage.cpp
blobd77fa7182241f3332bd2caad220b18d8e20db3af
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"
8 namespace mozilla {
10 using namespace gfx;
11 using layers::ImageContainer;
13 namespace image {
15 void FrozenImage::IncrementAnimationConsumers() {
16 // Do nothing. This will prevent animation from starting if there are no other
17 // instances of this image.
20 void FrozenImage::DecrementAnimationConsumers() {
21 // Do nothing.
24 NS_IMETHODIMP
25 FrozenImage::GetAnimated(bool* aAnimated) {
26 bool dummy;
27 nsresult rv = InnerImage()->GetAnimated(&dummy);
28 if (NS_SUCCEEDED(rv)) {
29 *aAnimated = false;
31 return rv;
34 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
35 FrozenImage::GetFrame(uint32_t aWhichFrame, uint32_t aFlags) {
36 return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
39 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
40 FrozenImage::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
41 uint32_t aFlags) {
42 return InnerImage()->GetFrameAtSize(aSize, FRAME_FIRST, aFlags);
45 bool FrozenImage::IsNonAnimated() const {
46 // We usually don't create frozen images for non-animated images, but it might
47 // happen if we don't have enough data at the time of the creation to
48 // determine whether the image is actually animated.
49 bool animated = false;
50 return NS_SUCCEEDED(InnerImage()->GetAnimated(&animated)) && !animated;
53 NS_IMETHODIMP_(bool)
54 FrozenImage::IsImageContainerAvailable(WindowRenderer* aRenderer,
55 uint32_t aFlags) {
56 if (IsNonAnimated()) {
57 return InnerImage()->IsImageContainerAvailable(aRenderer, aFlags);
59 return false;
62 NS_IMETHODIMP_(ImgDrawResult)
63 FrozenImage::GetImageContainerAtSize(WindowRenderer* aRenderer,
64 const gfx::IntSize& aSize,
65 const Maybe<SVGImageContext>& aSVGContext,
66 const Maybe<ImageIntRegion>& aRegion,
67 uint32_t aFlags,
68 layers::ImageContainer** aOutContainer) {
69 if (IsNonAnimated()) {
70 return InnerImage()->GetImageContainerAtSize(
71 aRenderer, aSize, aSVGContext, aRegion, aFlags, aOutContainer);
74 // XXX(seth): GetImageContainer does not currently support anything but the
75 // current frame. We work around this by always returning null, but if it ever
76 // turns out that FrozenImage is widely used on codepaths that can actually
77 // benefit from GetImageContainer, it would be a good idea to fix that method
78 // for performance reasons.
79 return ImgDrawResult::NOT_SUPPORTED;
82 NS_IMETHODIMP_(ImgDrawResult)
83 FrozenImage::Draw(gfxContext* aContext, const nsIntSize& aSize,
84 const ImageRegion& aRegion,
85 uint32_t /* aWhichFrame - ignored */,
86 SamplingFilter aSamplingFilter,
87 const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
88 float aOpacity) {
89 return InnerImage()->Draw(aContext, aSize, aRegion, FRAME_FIRST,
90 aSamplingFilter, aSVGContext, aFlags, aOpacity);
93 NS_IMETHODIMP
94 FrozenImage::StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) {
95 return InnerImage()->StartDecoding(aFlags, FRAME_FIRST);
98 bool FrozenImage::StartDecodingWithResult(uint32_t aFlags,
99 uint32_t aWhichFrame) {
100 return InnerImage()->StartDecodingWithResult(aFlags, FRAME_FIRST);
103 imgIContainer::DecodeResult FrozenImage::RequestDecodeWithResult(
104 uint32_t aFlags, uint32_t aWhichFrame) {
105 return InnerImage()->RequestDecodeWithResult(aFlags, FRAME_FIRST);
108 NS_IMETHODIMP
109 FrozenImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
110 uint32_t aWhichFrame) {
111 return InnerImage()->RequestDecodeForSize(aSize, aFlags, FRAME_FIRST);
114 NS_IMETHODIMP_(void)
115 FrozenImage::RequestRefresh(const TimeStamp& aTime) {
116 // Do nothing.
119 NS_IMETHODIMP
120 FrozenImage::GetAnimationMode(uint16_t* aAnimationMode) {
121 *aAnimationMode = kNormalAnimMode;
122 return NS_OK;
125 NS_IMETHODIMP
126 FrozenImage::SetAnimationMode(uint16_t aAnimationMode) {
127 // Do nothing.
128 return NS_OK;
131 NS_IMETHODIMP
132 FrozenImage::ResetAnimation() {
133 // Do nothing.
134 return NS_OK;
137 NS_IMETHODIMP_(float)
138 FrozenImage::GetFrameIndex(uint32_t aWhichFrame) {
139 MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
140 return 0;
143 } // namespace image
144 } // namespace mozilla