michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_IMAGELIB_FROZENIMAGE_H_ michael@0: #define MOZILLA_IMAGELIB_FROZENIMAGE_H_ michael@0: michael@0: #include "ImageWrapper.h" michael@0: #include "mozilla/gfx/2D.h" michael@0: #include "mozilla/RefPtr.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: /** michael@0: * An Image wrapper that disables animation, freezing the image at its first michael@0: * frame. It does this using two strategies. If this is the only instance of the michael@0: * image, animation will never start, because IncrementAnimationConsumers is michael@0: * ignored. If there is another instance that is animated, that's still OK, michael@0: * because any imgIContainer method that is affected by animation gets its michael@0: * aWhichFrame argument set to FRAME_FIRST when it passes through FrozenImage. michael@0: * michael@0: * XXX(seth): There a known (performance, not correctness) issue with michael@0: * GetImageContainer. See the comments for that method for more information. michael@0: */ michael@0: class FrozenImage : public ImageWrapper michael@0: { michael@0: typedef mozilla::gfx::SourceSurface SourceSurface; michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: virtual ~FrozenImage() { } michael@0: michael@0: virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; michael@0: virtual void IncrementAnimationConsumers() MOZ_OVERRIDE; michael@0: virtual void DecrementAnimationConsumers() MOZ_OVERRIDE; michael@0: michael@0: NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE; michael@0: NS_IMETHOD_(TemporaryRef) michael@0: GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE; michael@0: NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetImageContainer(layers::LayerManager* aManager, michael@0: layers::ImageContainer** _retval) MOZ_OVERRIDE; michael@0: NS_IMETHOD Draw(gfxContext* aContext, michael@0: GraphicsFilter aFilter, michael@0: const gfxMatrix& aUserSpaceToImageSpace, michael@0: const gfxRect& aFill, michael@0: const nsIntRect& aSubimage, michael@0: const nsIntSize& aViewportSize, michael@0: const SVGImageContext* aSVGContext, michael@0: uint32_t aWhichFrame, michael@0: uint32_t aFlags) MOZ_OVERRIDE; michael@0: NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime) MOZ_OVERRIDE; michael@0: NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE; michael@0: NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE; michael@0: NS_IMETHOD ResetAnimation() MOZ_OVERRIDE; michael@0: NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: FrozenImage(Image* aImage) : ImageWrapper(aImage) { } michael@0: michael@0: private: michael@0: friend class ImageOps; michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif // MOZILLA_IMAGELIB_FROZENIMAGE_H_