2013-03-11 01:43:38 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#ifndef mozilla_image_FrozenImage_h
|
|
|
|
#define mozilla_image_FrozenImage_h
|
2013-03-11 01:43:38 +00:00
|
|
|
|
|
|
|
#include "ImageWrapper.h"
|
2014-04-15 18:02:23 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2015-10-18 05:24:48 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-03-11 01:43:38 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Image wrapper that disables animation, freezing the image at its first
|
|
|
|
* frame. It does this using two strategies. If this is the only instance of the
|
|
|
|
* image, animation will never start, because IncrementAnimationConsumers is
|
|
|
|
* ignored. If there is another instance that is animated, that's still OK,
|
|
|
|
* because any imgIContainer method that is affected by animation gets its
|
|
|
|
* aWhichFrame argument set to FRAME_FIRST when it passes through FrozenImage.
|
|
|
|
*
|
|
|
|
* XXX(seth): There a known (performance, not correctness) issue with
|
|
|
|
* GetImageContainer. See the comments for that method for more information.
|
|
|
|
*/
|
|
|
|
class FrozenImage : public ImageWrapper {
|
2014-07-10 15:00:31 +00:00
|
|
|
typedef gfx::SourceSurface SourceSurface;
|
2014-04-15 18:02:23 +00:00
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
public:
|
2018-02-12 20:44:40 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(FrozenImage, ImageWrapper)
|
2013-03-11 01:43:38 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void IncrementAnimationConsumers() override;
|
|
|
|
virtual void DecrementAnimationConsumers() override;
|
2013-03-11 01:43:38 +00:00
|
|
|
|
2021-03-12 18:39:05 +00:00
|
|
|
bool IsNonAnimated() const;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetAnimated(bool* aAnimated) override;
|
2015-06-17 14:00:52 +00:00
|
|
|
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
2015-03-21 16:28:04 +00:00
|
|
|
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) override;
|
2015-09-19 20:34:09 +00:00
|
|
|
NS_IMETHOD_(already_AddRefed<SourceSurface>)
|
|
|
|
GetFrameAtSize(const gfx::IntSize& aSize, uint32_t aWhichFrame,
|
|
|
|
uint32_t aFlags) override;
|
2015-05-13 07:23:44 +00:00
|
|
|
NS_IMETHOD_(bool)
|
2021-09-05 22:36:45 +00:00
|
|
|
IsImageContainerAvailable(WindowRenderer* aRenderer,
|
2015-05-13 07:23:44 +00:00
|
|
|
uint32_t aFlags) override;
|
2018-09-13 23:48:21 +00:00
|
|
|
NS_IMETHOD_(ImgDrawResult)
|
2021-11-27 11:47:36 +00:00
|
|
|
GetImageProvider(WindowRenderer* aRenderer, const gfx::IntSize& aSize,
|
2022-07-14 16:03:25 +00:00
|
|
|
const SVGImageContext& aSVGContext,
|
2021-11-27 11:47:36 +00:00
|
|
|
const Maybe<ImageIntRegion>& aRegion, uint32_t aFlags,
|
|
|
|
WebRenderImageProvider** aProvider) override;
|
|
|
|
NS_IMETHOD_(ImgDrawResult)
|
2017-12-11 15:37:59 +00:00
|
|
|
Draw(gfxContext* aContext, const nsIntSize& aSize, const ImageRegion& aRegion,
|
2016-05-25 16:01:18 +00:00
|
|
|
uint32_t aWhichFrame, gfx::SamplingFilter aSamplingFilter,
|
2022-07-14 16:03:25 +00:00
|
|
|
const SVGImageContext& aSVGContext, uint32_t aFlags,
|
2017-01-03 05:53:22 +00:00
|
|
|
float aOpacity) override;
|
2019-05-21 17:34:14 +00:00
|
|
|
NS_IMETHOD StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) override;
|
|
|
|
NS_IMETHOD_(bool)
|
|
|
|
StartDecodingWithResult(uint32_t aFlags, uint32_t aWhichFrame) override;
|
2022-05-20 09:02:32 +00:00
|
|
|
NS_IMETHOD_(bool)
|
|
|
|
HasDecodedPixels() override;
|
2020-04-20 21:04:45 +00:00
|
|
|
NS_IMETHOD_(DecodeResult)
|
2019-05-21 17:34:14 +00:00
|
|
|
RequestDecodeWithResult(uint32_t aFlags, uint32_t aWhichFrame) override;
|
|
|
|
NS_IMETHOD RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
|
|
|
|
uint32_t aWhichFrame) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD_(void) RequestRefresh(const TimeStamp& aTime) override;
|
|
|
|
NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) override;
|
|
|
|
NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) override;
|
|
|
|
NS_IMETHOD ResetAnimation() override;
|
|
|
|
NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) override;
|
2013-03-11 01:43:38 +00:00
|
|
|
|
|
|
|
protected:
|
2014-09-02 16:20:24 +00:00
|
|
|
explicit FrozenImage(Image* aImage) : ImageWrapper(aImage) {}
|
2014-06-23 18:49:08 +00:00
|
|
|
virtual ~FrozenImage() {}
|
2013-03-11 01:43:38 +00:00
|
|
|
|
|
|
|
private:
|
2013-04-05 21:14:34 +00:00
|
|
|
friend class ImageOps;
|
2013-03-11 01:43:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#endif // mozilla_image_FrozenImage_h
|