image/src/FrozenImage.cpp

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:8c1e8bf22aa6
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 #include "FrozenImage.h"
7
8 using namespace mozilla::gfx;
9
10 namespace mozilla {
11 namespace image {
12
13 NS_IMPL_ISUPPORTS(FrozenImage, imgIContainer)
14
15 nsIntRect
16 FrozenImage::FrameRect(uint32_t /* aWhichFrame - ignored */)
17 {
18 return InnerImage()->FrameRect(FRAME_FIRST);
19 }
20
21 void
22 FrozenImage::IncrementAnimationConsumers()
23 {
24 // Do nothing. This will prevent animation from starting if there are no other
25 // instances of this image.
26 }
27
28 void
29 FrozenImage::DecrementAnimationConsumers()
30 {
31 // Do nothing.
32 }
33
34 NS_IMETHODIMP
35 FrozenImage::GetAnimated(bool* aAnimated)
36 {
37 bool dummy;
38 nsresult rv = InnerImage()->GetAnimated(&dummy);
39 if (NS_SUCCEEDED(rv)) {
40 *aAnimated = false;
41 }
42 return rv;
43 }
44
45 NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
46 FrozenImage::GetFrame(uint32_t aWhichFrame,
47 uint32_t aFlags)
48 {
49 return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
50 }
51
52 NS_IMETHODIMP_(bool)
53 FrozenImage::FrameIsOpaque(uint32_t aWhichFrame)
54 {
55 return InnerImage()->FrameIsOpaque(FRAME_FIRST);
56 }
57
58 NS_IMETHODIMP
59 FrozenImage::GetImageContainer(layers::LayerManager* aManager,
60 layers::ImageContainer** _retval)
61 {
62 // XXX(seth): GetImageContainer does not currently support anything but the
63 // current frame. We work around this by always returning null, but if it ever
64 // turns out that FrozenImage is widely used on codepaths that can actually
65 // benefit from GetImageContainer, it would be a good idea to fix that method
66 // for performance reasons.
67
68 *_retval = nullptr;
69 return NS_OK;
70 }
71
72 NS_IMETHODIMP
73 FrozenImage::Draw(gfxContext* aContext,
74 GraphicsFilter aFilter,
75 const gfxMatrix& aUserSpaceToImageSpace,
76 const gfxRect& aFill,
77 const nsIntRect& aSubimage,
78 const nsIntSize& aViewportSize,
79 const SVGImageContext* aSVGContext,
80 uint32_t /* aWhichFrame - ignored */,
81 uint32_t aFlags)
82 {
83 return InnerImage()->Draw(aContext, aFilter, aUserSpaceToImageSpace,
84 aFill, aSubimage, aViewportSize, aSVGContext,
85 FRAME_FIRST, aFlags);
86 }
87
88 NS_IMETHODIMP_(void)
89 FrozenImage::RequestRefresh(const mozilla::TimeStamp& aTime)
90 {
91 // Do nothing.
92 }
93
94 NS_IMETHODIMP
95 FrozenImage::GetAnimationMode(uint16_t* aAnimationMode)
96 {
97 *aAnimationMode = kNormalAnimMode;
98 return NS_OK;
99 }
100
101 NS_IMETHODIMP
102 FrozenImage::SetAnimationMode(uint16_t aAnimationMode)
103 {
104 // Do nothing.
105 return NS_OK;
106 }
107
108 NS_IMETHODIMP
109 FrozenImage::ResetAnimation()
110 {
111 // Do nothing.
112 return NS_OK;
113 }
114
115 NS_IMETHODIMP_(float)
116 FrozenImage::GetFrameIndex(uint32_t aWhichFrame)
117 {
118 MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
119 return 0;
120 }
121
122 } // namespace image
123 } // namespace mozilla

mercurial