Bug 1885565 - Part 2: Fix up parameter ordering and kDoc descriptions in NavigationBa...
[gecko.git] / image / ImageWrapper.cpp
blobeafd6ffe04990d44302ad6d9a7de13497646ef5e
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 "mozilla/gfx/2D.h"
8 #include "mozilla/RefPtr.h"
9 #include "Orientation.h"
10 #include "mozilla/image/Resolution.h"
12 #include "mozilla/MemoryReporting.h"
14 namespace mozilla {
16 using dom::Document;
17 using gfx::IntSize;
18 using gfx::SamplingFilter;
19 using gfx::SourceSurface;
20 using layers::ImageContainer;
22 namespace image {
24 // Inherited methods from Image.
26 already_AddRefed<ProgressTracker> ImageWrapper::GetProgressTracker() {
27 return mInnerImage->GetProgressTracker();
30 size_t ImageWrapper::SizeOfSourceWithComputedFallback(
31 SizeOfState& aState) const {
32 return mInnerImage->SizeOfSourceWithComputedFallback(aState);
35 void ImageWrapper::CollectSizeOfSurfaces(
36 nsTArray<SurfaceMemoryCounter>& aCounters,
37 MallocSizeOf aMallocSizeOf) const {
38 mInnerImage->CollectSizeOfSurfaces(aCounters, aMallocSizeOf);
41 void ImageWrapper::IncrementAnimationConsumers() {
42 MOZ_ASSERT(NS_IsMainThread(),
43 "Main thread only to encourage serialization "
44 "with DecrementAnimationConsumers");
45 mInnerImage->IncrementAnimationConsumers();
48 void ImageWrapper::DecrementAnimationConsumers() {
49 MOZ_ASSERT(NS_IsMainThread(),
50 "Main thread only to encourage serialization "
51 "with IncrementAnimationConsumers");
52 mInnerImage->DecrementAnimationConsumers();
55 #ifdef DEBUG
56 uint32_t ImageWrapper::GetAnimationConsumers() {
57 return mInnerImage->GetAnimationConsumers();
59 #endif
61 nsresult ImageWrapper::OnImageDataAvailable(nsIRequest* aRequest,
62 nsIInputStream* aInStr,
63 uint64_t aSourceOffset,
64 uint32_t aCount) {
65 return mInnerImage->OnImageDataAvailable(aRequest, aInStr, aSourceOffset,
66 aCount);
69 nsresult ImageWrapper::OnImageDataComplete(nsIRequest* aRequest,
70 nsresult aStatus, bool aLastPart) {
71 return mInnerImage->OnImageDataComplete(aRequest, aStatus, aLastPart);
74 void ImageWrapper::OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) {
75 return mInnerImage->OnSurfaceDiscarded(aSurfaceKey);
78 void ImageWrapper::SetInnerWindowID(uint64_t aInnerWindowId) {
79 mInnerImage->SetInnerWindowID(aInnerWindowId);
82 uint64_t ImageWrapper::InnerWindowID() const {
83 return mInnerImage->InnerWindowID();
86 bool ImageWrapper::HasError() { return mInnerImage->HasError(); }
88 void ImageWrapper::SetHasError() { mInnerImage->SetHasError(); }
90 nsIURI* ImageWrapper::GetURI() const { return mInnerImage->GetURI(); }
92 // Methods inherited from XPCOM interfaces.
94 NS_IMPL_ISUPPORTS(ImageWrapper, imgIContainer)
96 NS_IMETHODIMP
97 ImageWrapper::GetWidth(int32_t* aWidth) {
98 return mInnerImage->GetWidth(aWidth);
101 NS_IMETHODIMP
102 ImageWrapper::GetHeight(int32_t* aHeight) {
103 return mInnerImage->GetHeight(aHeight);
106 void ImageWrapper::MediaFeatureValuesChangedAllDocuments(
107 const mozilla::MediaFeatureChange& aChange) {}
109 nsresult ImageWrapper::GetNativeSizes(nsTArray<IntSize>& aNativeSizes) {
110 return mInnerImage->GetNativeSizes(aNativeSizes);
113 size_t ImageWrapper::GetNativeSizesLength() {
114 return mInnerImage->GetNativeSizesLength();
117 NS_IMETHODIMP
118 ImageWrapper::GetIntrinsicSize(nsSize* aSize) {
119 return mInnerImage->GetIntrinsicSize(aSize);
122 Maybe<AspectRatio> ImageWrapper::GetIntrinsicRatio() {
123 return mInnerImage->GetIntrinsicRatio();
126 nsresult ImageWrapper::GetHotspotX(int32_t* aX) {
127 return Image::GetHotspotX(aX);
130 nsresult ImageWrapper::GetHotspotY(int32_t* aY) {
131 return Image::GetHotspotY(aY);
134 NS_IMETHODIMP_(Orientation)
135 ImageWrapper::GetOrientation() { return mInnerImage->GetOrientation(); }
137 NS_IMETHODIMP_(Resolution)
138 ImageWrapper::GetResolution() { return mInnerImage->GetResolution(); }
140 NS_IMETHODIMP
141 ImageWrapper::GetType(uint16_t* aType) { return mInnerImage->GetType(aType); }
143 NS_IMETHODIMP
144 ImageWrapper::GetProviderId(uint32_t* aId) {
145 return mInnerImage->GetProviderId(aId);
148 NS_IMETHODIMP
149 ImageWrapper::GetAnimated(bool* aAnimated) {
150 return mInnerImage->GetAnimated(aAnimated);
153 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
154 ImageWrapper::GetFrame(uint32_t aWhichFrame, uint32_t aFlags) {
155 return mInnerImage->GetFrame(aWhichFrame, aFlags);
158 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
159 ImageWrapper::GetFrameAtSize(const IntSize& aSize, uint32_t aWhichFrame,
160 uint32_t aFlags) {
161 return mInnerImage->GetFrameAtSize(aSize, aWhichFrame, aFlags);
164 NS_IMETHODIMP_(bool)
165 ImageWrapper::WillDrawOpaqueNow() { return mInnerImage->WillDrawOpaqueNow(); }
167 NS_IMETHODIMP_(bool)
168 ImageWrapper::IsImageContainerAvailable(WindowRenderer* aRenderer,
169 uint32_t aFlags) {
170 return mInnerImage->IsImageContainerAvailable(aRenderer, aFlags);
173 NS_IMETHODIMP_(ImgDrawResult)
174 ImageWrapper::GetImageProvider(WindowRenderer* aRenderer,
175 const gfx::IntSize& aSize,
176 const SVGImageContext& aSVGContext,
177 const Maybe<ImageIntRegion>& aRegion,
178 uint32_t aFlags,
179 WebRenderImageProvider** aProvider) {
180 return mInnerImage->GetImageProvider(aRenderer, aSize, aSVGContext, aRegion,
181 aFlags, aProvider);
184 NS_IMETHODIMP_(ImgDrawResult)
185 ImageWrapper::Draw(gfxContext* aContext, const nsIntSize& aSize,
186 const ImageRegion& aRegion, uint32_t aWhichFrame,
187 SamplingFilter aSamplingFilter,
188 const SVGImageContext& aSVGContext, uint32_t aFlags,
189 float aOpacity) {
190 return mInnerImage->Draw(aContext, aSize, aRegion, aWhichFrame,
191 aSamplingFilter, aSVGContext, aFlags, aOpacity);
194 NS_IMETHODIMP
195 ImageWrapper::StartDecoding(uint32_t aFlags, uint32_t aWhichFrame) {
196 return mInnerImage->StartDecoding(aFlags, aWhichFrame);
199 bool ImageWrapper::StartDecodingWithResult(uint32_t aFlags,
200 uint32_t aWhichFrame) {
201 return mInnerImage->StartDecodingWithResult(aFlags, aWhichFrame);
204 bool ImageWrapper::HasDecodedPixels() {
205 return InnerImage()->HasDecodedPixels();
208 imgIContainer::DecodeResult ImageWrapper::RequestDecodeWithResult(
209 uint32_t aFlags, uint32_t aWhichFrame) {
210 return mInnerImage->RequestDecodeWithResult(aFlags, aWhichFrame);
213 NS_IMETHODIMP
214 ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags,
215 uint32_t aWhichFrame) {
216 return mInnerImage->RequestDecodeForSize(aSize, aFlags, aWhichFrame);
219 NS_IMETHODIMP
220 ImageWrapper::LockImage() {
221 MOZ_ASSERT(NS_IsMainThread(),
222 "Main thread to encourage serialization with UnlockImage");
223 return mInnerImage->LockImage();
226 NS_IMETHODIMP
227 ImageWrapper::UnlockImage() {
228 MOZ_ASSERT(NS_IsMainThread(),
229 "Main thread to encourage serialization with LockImage");
230 return mInnerImage->UnlockImage();
233 NS_IMETHODIMP
234 ImageWrapper::RequestDiscard() { return mInnerImage->RequestDiscard(); }
236 NS_IMETHODIMP_(void)
237 ImageWrapper::RequestRefresh(const TimeStamp& aTime) {
238 return mInnerImage->RequestRefresh(aTime);
241 NS_IMETHODIMP
242 ImageWrapper::GetAnimationMode(uint16_t* aAnimationMode) {
243 return mInnerImage->GetAnimationMode(aAnimationMode);
246 NS_IMETHODIMP
247 ImageWrapper::SetAnimationMode(uint16_t aAnimationMode) {
248 return mInnerImage->SetAnimationMode(aAnimationMode);
251 NS_IMETHODIMP
252 ImageWrapper::ResetAnimation() { return mInnerImage->ResetAnimation(); }
254 NS_IMETHODIMP_(float)
255 ImageWrapper::GetFrameIndex(uint32_t aWhichFrame) {
256 return mInnerImage->GetFrameIndex(aWhichFrame);
259 NS_IMETHODIMP_(int32_t)
260 ImageWrapper::GetFirstFrameDelay() { return mInnerImage->GetFirstFrameDelay(); }
262 NS_IMETHODIMP_(void)
263 ImageWrapper::SetAnimationStartTime(const TimeStamp& aTime) {
264 mInnerImage->SetAnimationStartTime(aTime);
267 void ImageWrapper::PropagateUseCounters(Document* aReferencingDocument) {
268 mInnerImage->PropagateUseCounters(aReferencingDocument);
271 nsIntSize ImageWrapper::OptimalImageSizeForDest(const gfxSize& aDest,
272 uint32_t aWhichFrame,
273 SamplingFilter aSamplingFilter,
274 uint32_t aFlags) {
275 return mInnerImage->OptimalImageSizeForDest(aDest, aWhichFrame,
276 aSamplingFilter, aFlags);
279 NS_IMETHODIMP_(nsIntRect)
280 ImageWrapper::GetImageSpaceInvalidationRect(const nsIntRect& aRect) {
281 return mInnerImage->GetImageSpaceInvalidationRect(aRect);
284 already_AddRefed<imgIContainer> ImageWrapper::Unwrap() {
285 return mInnerImage->Unwrap();
288 } // namespace image
289 } // namespace mozilla