Bug 1646700 [wpt PR 24235] - Update picture-in-picture idlharness test, a=testonly
[gecko.git] / image / FrozenImage.h
blob9569b4ccd2b2e1a4ca3790e9c9371edb061eced2
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 #ifndef mozilla_image_FrozenImage_h
7 #define mozilla_image_FrozenImage_h
9 #include "ImageWrapper.h"
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/RefPtr.h"
13 namespace mozilla {
14 namespace image {
16 /**
17 * An Image wrapper that disables animation, freezing the image at its first
18 * frame. It does this using two strategies. If this is the only instance of the
19 * image, animation will never start, because IncrementAnimationConsumers is
20 * ignored. If there is another instance that is animated, that's still OK,
21 * because any imgIContainer method that is affected by animation gets its
22 * aWhichFrame argument set to FRAME_FIRST when it passes through FrozenImage.
24 * XXX(seth): There a known (performance, not correctness) issue with
25 * GetImageContainer. See the comments for that method for more information.
27 class FrozenImage : public ImageWrapper {
28 typedef gfx::SourceSurface SourceSurface;
30 public:
31 NS_INLINE_DECL_REFCOUNTING_INHERITED(FrozenImage, ImageWrapper)
33 virtual void IncrementAnimationConsumers() override;
34 virtual void DecrementAnimationConsumers() override;
36 NS_IMETHOD GetAnimated(bool* aAnimated) override;
37 NS_IMETHOD_(already_AddRefed<SourceSurface>)
38 GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
39 NS_IMETHOD_(already_AddRefed<SourceSurface>)
40 GetFrameAtSize(const gfx::IntSize& aSize, uint32_t aWhichFrame,
41 uint32_t aFlags) override;
42 NS_IMETHOD_(bool)
43 IsImageContainerAvailable(layers::LayerManager* aManager,
44 uint32_t aFlags) override;
45 NS_IMETHOD_(already_AddRefed<layers::ImageContainer>)
46 GetImageContainer(layers::LayerManager* aManager, uint32_t aFlags) override;
47 NS_IMETHOD_(bool)
48 IsImageContainerAvailableAtSize(layers::LayerManager* aManager,
49 const gfx::IntSize& aSize,
50 uint32_t aFlags) override;
51 NS_IMETHOD_(ImgDrawResult)
52 GetImageContainerAtSize(layers::LayerManager* aManager,
53 const gfx::IntSize& aSize,
54 const Maybe<SVGImageContext>& aSVGContext,
55 uint32_t aFlags,
56 layers::ImageContainer** aOutContainer) override;
57 NS_IMETHOD_(ImgDrawResult)
58 Draw(gfxContext* aContext, const nsIntSize& aSize, const ImageRegion& aRegion,
59 uint32_t aWhichFrame, gfx::SamplingFilter aSamplingFilter,
60 const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
61 float aOpacity) override;
62 NS_IMETHOD StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) override;
63 NS_IMETHOD_(bool)
64 StartDecodingWithResult(uint32_t aFlags, uint32_t aWhichFrame) override;
65 NS_IMETHOD_(DecodeResult)
66 RequestDecodeWithResult(uint32_t aFlags, uint32_t aWhichFrame) override;
67 NS_IMETHOD RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
68 uint32_t aWhichFrame) override;
69 NS_IMETHOD_(void) RequestRefresh(const TimeStamp& aTime) override;
70 NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) override;
71 NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) override;
72 NS_IMETHOD ResetAnimation() override;
73 NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) override;
75 protected:
76 explicit FrozenImage(Image* aImage) : ImageWrapper(aImage) {}
77 virtual ~FrozenImage() {}
79 private:
80 friend class ImageOps;
83 } // namespace image
84 } // namespace mozilla
86 #endif // mozilla_image_FrozenImage_h