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 #include "ImageWrapper.h"
7 #include "Orientation.h"
9 #include "mozilla/MemoryReporting.h"
11 using mozilla::layers::LayerManager
;
12 using mozilla::layers::ImageContainer
;
17 // Inherited methods from Image.
20 ImageWrapper::Init(const char* aMimeType
, uint32_t aFlags
)
22 return mInnerImage
->Init(aMimeType
, aFlags
);
25 already_AddRefed
<imgStatusTracker
>
26 ImageWrapper::GetStatusTracker()
28 return mInnerImage
->GetStatusTracker();
32 ImageWrapper::FrameRect(uint32_t aWhichFrame
)
34 return mInnerImage
->FrameRect(aWhichFrame
);
38 ImageWrapper::SizeOfData()
40 return mInnerImage
->SizeOfData();
44 ImageWrapper::HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf
) const
46 return mInnerImage
->HeapSizeOfSourceWithComputedFallback(aMallocSizeOf
);
50 ImageWrapper::HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf
) const
52 return mInnerImage
->HeapSizeOfDecodedWithComputedFallback(aMallocSizeOf
);
56 ImageWrapper::NonHeapSizeOfDecoded() const
58 return mInnerImage
->NonHeapSizeOfDecoded();
62 ImageWrapper::OutOfProcessSizeOfDecoded() const
64 return mInnerImage
->OutOfProcessSizeOfDecoded();
68 ImageWrapper::IncrementAnimationConsumers()
70 MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
71 "with DecrementAnimationConsumers");
72 mInnerImage
->IncrementAnimationConsumers();
76 ImageWrapper::DecrementAnimationConsumers()
78 MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
79 "with IncrementAnimationConsumers");
80 mInnerImage
->DecrementAnimationConsumers();
85 ImageWrapper::GetAnimationConsumers()
87 return mInnerImage
->GetAnimationConsumers();
92 ImageWrapper::OnImageDataAvailable(nsIRequest
* aRequest
,
93 nsISupports
* aContext
,
94 nsIInputStream
* aInStr
,
95 uint64_t aSourceOffset
,
98 return mInnerImage
->OnImageDataAvailable(aRequest
, aContext
, aInStr
,
99 aSourceOffset
, aCount
);
103 ImageWrapper::OnImageDataComplete(nsIRequest
* aRequest
,
104 nsISupports
* aContext
,
108 return mInnerImage
->OnImageDataComplete(aRequest
, aContext
, aStatus
, aLastPart
);
112 ImageWrapper::OnNewSourceData()
114 return mInnerImage
->OnNewSourceData();
118 ImageWrapper::SetInnerWindowID(uint64_t aInnerWindowId
)
120 mInnerImage
->SetInnerWindowID(aInnerWindowId
);
124 ImageWrapper::InnerWindowID() const
126 return mInnerImage
->InnerWindowID();
130 ImageWrapper::HasError()
132 return mInnerImage
->HasError();
136 ImageWrapper::SetHasError()
138 mInnerImage
->SetHasError();
142 ImageWrapper::GetURI()
144 return mInnerImage
->GetURI();
147 // Methods inherited from XPCOM interfaces.
149 NS_IMPL_ISUPPORTS1(ImageWrapper
, imgIContainer
)
152 ImageWrapper::GetWidth(int32_t* aWidth
)
154 return mInnerImage
->GetWidth(aWidth
);
158 ImageWrapper::GetHeight(int32_t* aHeight
)
160 return mInnerImage
->GetHeight(aHeight
);
164 ImageWrapper::GetIntrinsicSize(nsSize
* aSize
)
166 return mInnerImage
->GetIntrinsicSize(aSize
);
170 ImageWrapper::GetIntrinsicRatio(nsSize
* aSize
)
172 return mInnerImage
->GetIntrinsicRatio(aSize
);
175 NS_IMETHODIMP_(Orientation
)
176 ImageWrapper::GetOrientation()
178 return mInnerImage
->GetOrientation();
182 ImageWrapper::GetType(uint16_t* aType
)
184 return mInnerImage
->GetType(aType
);
187 NS_IMETHODIMP_(uint16_t)
188 ImageWrapper::GetType()
190 return mInnerImage
->GetType();
194 ImageWrapper::GetAnimated(bool* aAnimated
)
196 return mInnerImage
->GetAnimated(aAnimated
);
200 ImageWrapper::GetFrame(uint32_t aWhichFrame
,
202 gfxASurface
** _retval
)
204 return mInnerImage
->GetFrame(aWhichFrame
, aFlags
, _retval
);
208 ImageWrapper::FrameIsOpaque(uint32_t aWhichFrame
)
210 return mInnerImage
->FrameIsOpaque(aWhichFrame
);
214 ImageWrapper::GetImageContainer(LayerManager
* aManager
, ImageContainer
** _retval
)
216 return mInnerImage
->GetImageContainer(aManager
, _retval
);
220 ImageWrapper::Draw(gfxContext
* aContext
,
221 GraphicsFilter aFilter
,
222 const gfxMatrix
& aUserSpaceToImageSpace
,
223 const gfxRect
& aFill
,
224 const nsIntRect
& aSubimage
,
225 const nsIntSize
& aViewportSize
,
226 const SVGImageContext
* aSVGContext
,
227 uint32_t aWhichFrame
,
230 return mInnerImage
->Draw(aContext
, aFilter
, aUserSpaceToImageSpace
, aFill
,
231 aSubimage
, aViewportSize
, aSVGContext
, aWhichFrame
,
236 ImageWrapper::RequestDecode()
238 return mInnerImage
->RequestDecode();
242 ImageWrapper::StartDecoding()
244 return mInnerImage
->StartDecoding();
248 ImageWrapper::IsDecoded()
250 return mInnerImage
->IsDecoded();
254 ImageWrapper::LockImage()
256 MOZ_ASSERT(NS_IsMainThread(),
257 "Main thread to encourage serialization with UnlockImage");
258 return mInnerImage
->LockImage();
262 ImageWrapper::UnlockImage()
264 MOZ_ASSERT(NS_IsMainThread(),
265 "Main thread to encourage serialization with LockImage");
266 return mInnerImage
->UnlockImage();
270 ImageWrapper::RequestDiscard()
272 return mInnerImage
->RequestDiscard();
276 ImageWrapper::RequestRefresh(const mozilla::TimeStamp
& aTime
)
278 return mInnerImage
->RequestRefresh(aTime
);
282 ImageWrapper::GetAnimationMode(uint16_t* aAnimationMode
)
284 return mInnerImage
->GetAnimationMode(aAnimationMode
);
288 ImageWrapper::SetAnimationMode(uint16_t aAnimationMode
)
290 return mInnerImage
->SetAnimationMode(aAnimationMode
);
294 ImageWrapper::ResetAnimation()
296 return mInnerImage
->ResetAnimation();
299 NS_IMETHODIMP_(float)
300 ImageWrapper::GetFrameIndex(uint32_t aWhichFrame
)
302 return mInnerImage
->GetFrameIndex(aWhichFrame
);
305 NS_IMETHODIMP_(int32_t)
306 ImageWrapper::GetFirstFrameDelay()
308 return mInnerImage
->GetFirstFrameDelay();
312 ImageWrapper::SetAnimationStartTime(const mozilla::TimeStamp
& aTime
)
314 mInnerImage
->SetAnimationStartTime(aTime
);
318 } // namespace mozilla