Backed out changeset ad0d9f62c29c (bug 206659) for B2G desktop mochitest orange.
[gecko.git] / image / src / ImageWrapper.cpp
blob6e2c9adddf6c6257128034ad0ddf79116259ac61
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;
14 namespace mozilla {
15 namespace image {
17 // Inherited methods from Image.
19 nsresult
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();
31 nsIntRect
32 ImageWrapper::FrameRect(uint32_t aWhichFrame)
34 return mInnerImage->FrameRect(aWhichFrame);
37 uint32_t
38 ImageWrapper::SizeOfData()
40 return mInnerImage->SizeOfData();
43 size_t
44 ImageWrapper::HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const
46 return mInnerImage->HeapSizeOfSourceWithComputedFallback(aMallocSizeOf);
49 size_t
50 ImageWrapper::HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const
52 return mInnerImage->HeapSizeOfDecodedWithComputedFallback(aMallocSizeOf);
55 size_t
56 ImageWrapper::NonHeapSizeOfDecoded() const
58 return mInnerImage->NonHeapSizeOfDecoded();
61 size_t
62 ImageWrapper::OutOfProcessSizeOfDecoded() const
64 return mInnerImage->OutOfProcessSizeOfDecoded();
67 void
68 ImageWrapper::IncrementAnimationConsumers()
70 MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
71 "with DecrementAnimationConsumers");
72 mInnerImage->IncrementAnimationConsumers();
75 void
76 ImageWrapper::DecrementAnimationConsumers()
78 MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
79 "with IncrementAnimationConsumers");
80 mInnerImage->DecrementAnimationConsumers();
83 #ifdef DEBUG
84 uint32_t
85 ImageWrapper::GetAnimationConsumers()
87 return mInnerImage->GetAnimationConsumers();
89 #endif
91 nsresult
92 ImageWrapper::OnImageDataAvailable(nsIRequest* aRequest,
93 nsISupports* aContext,
94 nsIInputStream* aInStr,
95 uint64_t aSourceOffset,
96 uint32_t aCount)
98 return mInnerImage->OnImageDataAvailable(aRequest, aContext, aInStr,
99 aSourceOffset, aCount);
102 nsresult
103 ImageWrapper::OnImageDataComplete(nsIRequest* aRequest,
104 nsISupports* aContext,
105 nsresult aStatus,
106 bool aLastPart)
108 return mInnerImage->OnImageDataComplete(aRequest, aContext, aStatus, aLastPart);
111 nsresult
112 ImageWrapper::OnNewSourceData()
114 return mInnerImage->OnNewSourceData();
117 void
118 ImageWrapper::SetInnerWindowID(uint64_t aInnerWindowId)
120 mInnerImage->SetInnerWindowID(aInnerWindowId);
123 uint64_t
124 ImageWrapper::InnerWindowID() const
126 return mInnerImage->InnerWindowID();
129 bool
130 ImageWrapper::HasError()
132 return mInnerImage->HasError();
135 void
136 ImageWrapper::SetHasError()
138 mInnerImage->SetHasError();
141 ImageURL*
142 ImageWrapper::GetURI()
144 return mInnerImage->GetURI();
147 // Methods inherited from XPCOM interfaces.
149 NS_IMPL_ISUPPORTS1(ImageWrapper, imgIContainer)
151 NS_IMETHODIMP
152 ImageWrapper::GetWidth(int32_t* aWidth)
154 return mInnerImage->GetWidth(aWidth);
157 NS_IMETHODIMP
158 ImageWrapper::GetHeight(int32_t* aHeight)
160 return mInnerImage->GetHeight(aHeight);
163 NS_IMETHODIMP
164 ImageWrapper::GetIntrinsicSize(nsSize* aSize)
166 return mInnerImage->GetIntrinsicSize(aSize);
169 NS_IMETHODIMP
170 ImageWrapper::GetIntrinsicRatio(nsSize* aSize)
172 return mInnerImage->GetIntrinsicRatio(aSize);
175 NS_IMETHODIMP_(Orientation)
176 ImageWrapper::GetOrientation()
178 return mInnerImage->GetOrientation();
181 NS_IMETHODIMP
182 ImageWrapper::GetType(uint16_t* aType)
184 return mInnerImage->GetType(aType);
187 NS_IMETHODIMP_(uint16_t)
188 ImageWrapper::GetType()
190 return mInnerImage->GetType();
193 NS_IMETHODIMP
194 ImageWrapper::GetAnimated(bool* aAnimated)
196 return mInnerImage->GetAnimated(aAnimated);
199 NS_IMETHODIMP
200 ImageWrapper::GetFrame(uint32_t aWhichFrame,
201 uint32_t aFlags,
202 gfxASurface** _retval)
204 return mInnerImage->GetFrame(aWhichFrame, aFlags, _retval);
207 NS_IMETHODIMP_(bool)
208 ImageWrapper::FrameIsOpaque(uint32_t aWhichFrame)
210 return mInnerImage->FrameIsOpaque(aWhichFrame);
213 NS_IMETHODIMP
214 ImageWrapper::GetImageContainer(LayerManager* aManager, ImageContainer** _retval)
216 return mInnerImage->GetImageContainer(aManager, _retval);
219 NS_IMETHODIMP
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,
228 uint32_t aFlags)
230 return mInnerImage->Draw(aContext, aFilter, aUserSpaceToImageSpace, aFill,
231 aSubimage, aViewportSize, aSVGContext, aWhichFrame,
232 aFlags);
235 NS_IMETHODIMP
236 ImageWrapper::RequestDecode()
238 return mInnerImage->RequestDecode();
241 NS_IMETHODIMP
242 ImageWrapper::StartDecoding()
244 return mInnerImage->StartDecoding();
247 bool
248 ImageWrapper::IsDecoded()
250 return mInnerImage->IsDecoded();
253 NS_IMETHODIMP
254 ImageWrapper::LockImage()
256 MOZ_ASSERT(NS_IsMainThread(),
257 "Main thread to encourage serialization with UnlockImage");
258 return mInnerImage->LockImage();
261 NS_IMETHODIMP
262 ImageWrapper::UnlockImage()
264 MOZ_ASSERT(NS_IsMainThread(),
265 "Main thread to encourage serialization with LockImage");
266 return mInnerImage->UnlockImage();
269 NS_IMETHODIMP
270 ImageWrapper::RequestDiscard()
272 return mInnerImage->RequestDiscard();
275 NS_IMETHODIMP_(void)
276 ImageWrapper::RequestRefresh(const mozilla::TimeStamp& aTime)
278 return mInnerImage->RequestRefresh(aTime);
281 NS_IMETHODIMP
282 ImageWrapper::GetAnimationMode(uint16_t* aAnimationMode)
284 return mInnerImage->GetAnimationMode(aAnimationMode);
287 NS_IMETHODIMP
288 ImageWrapper::SetAnimationMode(uint16_t aAnimationMode)
290 return mInnerImage->SetAnimationMode(aAnimationMode);
293 NS_IMETHODIMP
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();
311 NS_IMETHODIMP_(void)
312 ImageWrapper::SetAnimationStartTime(const mozilla::TimeStamp& aTime)
314 mInnerImage->SetAnimationStartTime(aTime);
317 } // namespace image
318 } // namespace mozilla