Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef MOZILLA_IMAGELIB_FROZENIMAGE_H_ |
michael@0 | 7 | #define MOZILLA_IMAGELIB_FROZENIMAGE_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "ImageWrapper.h" |
michael@0 | 10 | #include "mozilla/gfx/2D.h" |
michael@0 | 11 | #include "mozilla/RefPtr.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace image { |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * An Image wrapper that disables animation, freezing the image at its first |
michael@0 | 18 | * frame. It does this using two strategies. If this is the only instance of the |
michael@0 | 19 | * image, animation will never start, because IncrementAnimationConsumers is |
michael@0 | 20 | * ignored. If there is another instance that is animated, that's still OK, |
michael@0 | 21 | * because any imgIContainer method that is affected by animation gets its |
michael@0 | 22 | * aWhichFrame argument set to FRAME_FIRST when it passes through FrozenImage. |
michael@0 | 23 | * |
michael@0 | 24 | * XXX(seth): There a known (performance, not correctness) issue with |
michael@0 | 25 | * GetImageContainer. See the comments for that method for more information. |
michael@0 | 26 | */ |
michael@0 | 27 | class FrozenImage : public ImageWrapper |
michael@0 | 28 | { |
michael@0 | 29 | typedef mozilla::gfx::SourceSurface SourceSurface; |
michael@0 | 30 | |
michael@0 | 31 | public: |
michael@0 | 32 | NS_DECL_ISUPPORTS |
michael@0 | 33 | |
michael@0 | 34 | virtual ~FrozenImage() { } |
michael@0 | 35 | |
michael@0 | 36 | virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; |
michael@0 | 37 | virtual void IncrementAnimationConsumers() MOZ_OVERRIDE; |
michael@0 | 38 | virtual void DecrementAnimationConsumers() MOZ_OVERRIDE; |
michael@0 | 39 | |
michael@0 | 40 | NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE; |
michael@0 | 41 | NS_IMETHOD_(TemporaryRef<SourceSurface>) |
michael@0 | 42 | GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 43 | NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE; |
michael@0 | 44 | NS_IMETHOD GetImageContainer(layers::LayerManager* aManager, |
michael@0 | 45 | layers::ImageContainer** _retval) MOZ_OVERRIDE; |
michael@0 | 46 | NS_IMETHOD Draw(gfxContext* aContext, |
michael@0 | 47 | GraphicsFilter aFilter, |
michael@0 | 48 | const gfxMatrix& aUserSpaceToImageSpace, |
michael@0 | 49 | const gfxRect& aFill, |
michael@0 | 50 | const nsIntRect& aSubimage, |
michael@0 | 51 | const nsIntSize& aViewportSize, |
michael@0 | 52 | const SVGImageContext* aSVGContext, |
michael@0 | 53 | uint32_t aWhichFrame, |
michael@0 | 54 | uint32_t aFlags) MOZ_OVERRIDE; |
michael@0 | 55 | NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime) MOZ_OVERRIDE; |
michael@0 | 56 | NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE; |
michael@0 | 57 | NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE; |
michael@0 | 58 | NS_IMETHOD ResetAnimation() MOZ_OVERRIDE; |
michael@0 | 59 | NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE; |
michael@0 | 60 | |
michael@0 | 61 | protected: |
michael@0 | 62 | FrozenImage(Image* aImage) : ImageWrapper(aImage) { } |
michael@0 | 63 | |
michael@0 | 64 | private: |
michael@0 | 65 | friend class ImageOps; |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | } // namespace image |
michael@0 | 69 | } // namespace mozilla |
michael@0 | 70 | |
michael@0 | 71 | #endif // MOZILLA_IMAGELIB_FROZENIMAGE_H_ |