Bumping manifests a=b2g-bump
[gecko.git] / image / src / FrozenImage.h
blob32b0f4664085283ed4d1d8e96c136850589499e5
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_IMAGELIB_FROZENIMAGE_H_
7 #define MOZILLA_IMAGELIB_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
29 typedef gfx::SourceSurface SourceSurface;
31 public:
32 NS_DECL_ISUPPORTS_INHERITED
34 virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
35 virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
36 virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
38 NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
39 NS_IMETHOD_(TemporaryRef<SourceSurface>)
40 GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
41 NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
42 NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
43 layers::ImageContainer** _retval) MOZ_OVERRIDE;
44 NS_IMETHOD Draw(gfxContext* aContext,
45 const nsIntSize& aSize,
46 const ImageRegion& aRegion,
47 uint32_t aWhichFrame,
48 GraphicsFilter aFilter,
49 const Maybe<SVGImageContext>& aSVGContext,
50 uint32_t aFlags) MOZ_OVERRIDE;
51 NS_IMETHOD_(void) RequestRefresh(const TimeStamp& aTime) MOZ_OVERRIDE;
52 NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE;
53 NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE;
54 NS_IMETHOD ResetAnimation() MOZ_OVERRIDE;
55 NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE;
57 protected:
58 FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
59 virtual ~FrozenImage() { }
61 private:
62 friend class ImageOps;
65 } // namespace image
66 } // namespace mozilla
68 #endif // MOZILLA_IMAGELIB_FROZENIMAGE_H_