Bug 1646700 [wpt PR 24235] - Update picture-in-picture idlharness test, a=testonly
[gecko.git] / image / FrozenImage.cpp
blob25e056f88995d229833a81b8551afb322d6631e8
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;
12 using layers::LayerManager;
14 namespace image {
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() {
22 // Do nothing.
25 NS_IMETHODIMP
26 FrozenImage::GetAnimated(bool* aAnimated) {
27 bool dummy;
28 nsresult rv = InnerImage()->GetAnimated(&dummy);
29 if (NS_SUCCEEDED(rv)) {
30 *aAnimated = false;
32 return 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,
42 uint32_t aFlags) {
43 return InnerImage()->GetFrameAtSize(aSize, FRAME_FIRST, aFlags);
46 NS_IMETHODIMP_(bool)
47 FrozenImage::IsImageContainerAvailable(LayerManager* aManager,
48 uint32_t aFlags) {
49 return false;
52 NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
53 FrozenImage::GetImageContainer(layers::LayerManager* aManager,
54 uint32_t aFlags) {
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.
60 return nullptr;
63 NS_IMETHODIMP_(bool)
64 FrozenImage::IsImageContainerAvailableAtSize(LayerManager* aManager,
65 const IntSize& aSize,
66 uint32_t aFlags) {
67 return false;
70 NS_IMETHODIMP_(ImgDrawResult)
71 FrozenImage::GetImageContainerAtSize(layers::LayerManager* aManager,
72 const gfx::IntSize& aSize,
73 const Maybe<SVGImageContext>& aSVGContext,
74 uint32_t aFlags,
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,
90 float aOpacity) {
91 return InnerImage()->Draw(aContext, aSize, aRegion, FRAME_FIRST,
92 aSamplingFilter, aSVGContext, aFlags, aOpacity);
95 NS_IMETHODIMP
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);
110 NS_IMETHODIMP
111 FrozenImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
112 uint32_t aWhichFrame) {
113 return InnerImage()->RequestDecodeForSize(aSize, aFlags, FRAME_FIRST);
116 NS_IMETHODIMP_(void)
117 FrozenImage::RequestRefresh(const TimeStamp& aTime) {
118 // Do nothing.
121 NS_IMETHODIMP
122 FrozenImage::GetAnimationMode(uint16_t* aAnimationMode) {
123 *aAnimationMode = kNormalAnimMode;
124 return NS_OK;
127 NS_IMETHODIMP
128 FrozenImage::SetAnimationMode(uint16_t aAnimationMode) {
129 // Do nothing.
130 return NS_OK;
133 NS_IMETHODIMP
134 FrozenImage::ResetAnimation() {
135 // Do nothing.
136 return NS_OK;
139 NS_IMETHODIMP_(float)
140 FrozenImage::GetFrameIndex(uint32_t aWhichFrame) {
141 MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
142 return 0;
145 } // namespace image
146 } // namespace mozilla