image/src/FrozenImage.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:afd106a7251e
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/. */
5
6 #ifndef MOZILLA_IMAGELIB_FROZENIMAGE_H_
7 #define MOZILLA_IMAGELIB_FROZENIMAGE_H_
8
9 #include "ImageWrapper.h"
10 #include "mozilla/gfx/2D.h"
11 #include "mozilla/RefPtr.h"
12
13 namespace mozilla {
14 namespace image {
15
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.
23 *
24 * XXX(seth): There a known (performance, not correctness) issue with
25 * GetImageContainer. See the comments for that method for more information.
26 */
27 class FrozenImage : public ImageWrapper
28 {
29 typedef mozilla::gfx::SourceSurface SourceSurface;
30
31 public:
32 NS_DECL_ISUPPORTS
33
34 virtual ~FrozenImage() { }
35
36 virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
37 virtual void IncrementAnimationConsumers() MOZ_OVERRIDE;
38 virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
39
40 NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
41 NS_IMETHOD_(TemporaryRef<SourceSurface>)
42 GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
43 NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
44 NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
45 layers::ImageContainer** _retval) MOZ_OVERRIDE;
46 NS_IMETHOD Draw(gfxContext* aContext,
47 GraphicsFilter aFilter,
48 const gfxMatrix& aUserSpaceToImageSpace,
49 const gfxRect& aFill,
50 const nsIntRect& aSubimage,
51 const nsIntSize& aViewportSize,
52 const SVGImageContext* aSVGContext,
53 uint32_t aWhichFrame,
54 uint32_t aFlags) MOZ_OVERRIDE;
55 NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime) MOZ_OVERRIDE;
56 NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE;
57 NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE;
58 NS_IMETHOD ResetAnimation() MOZ_OVERRIDE;
59 NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE;
60
61 protected:
62 FrozenImage(Image* aImage) : ImageWrapper(aImage) { }
63
64 private:
65 friend class ImageOps;
66 };
67
68 } // namespace image
69 } // namespace mozilla
70
71 #endif // MOZILLA_IMAGELIB_FROZENIMAGE_H_

mercurial