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