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 #ifndef mozilla_image_ImageWrapper_h
7 #define mozilla_image_ImageWrapper_h
9 #include "mozilla/MemoryReporting.h"
16 * Abstract superclass for Images that wrap other Images.
18 class ImageWrapper
: public Image
{
23 // Inherited methods from Image.
24 virtual already_AddRefed
<ProgressTracker
> GetProgressTracker() override
;
26 virtual size_t SizeOfSourceWithComputedFallback(
27 SizeOfState
& aState
) const override
;
28 virtual void CollectSizeOfSurfaces(nsTArray
<SurfaceMemoryCounter
>& aCounters
,
29 MallocSizeOf aMallocSizeOf
) const override
;
31 virtual void IncrementAnimationConsumers() override
;
32 virtual void DecrementAnimationConsumers() override
;
34 virtual uint32_t GetAnimationConsumers() override
;
37 virtual nsresult
OnImageDataAvailable(nsIRequest
* aRequest
,
38 nsIInputStream
* aInStr
,
39 uint64_t aSourceOffset
,
40 uint32_t aCount
) override
;
41 virtual nsresult
OnImageDataComplete(nsIRequest
* aRequest
, nsresult aStatus
,
42 bool aLastPart
) override
;
44 virtual void OnSurfaceDiscarded(const SurfaceKey
& aSurfaceKey
) override
;
46 virtual void SetInnerWindowID(uint64_t aInnerWindowId
) override
;
47 virtual uint64_t InnerWindowID() const override
;
49 virtual bool HasError() override
;
50 virtual void SetHasError() override
;
52 nsIURI
* GetURI() const override
;
55 explicit ImageWrapper(Image
* aInnerImage
) : mInnerImage(aInnerImage
) {
56 MOZ_ASSERT(aInnerImage
, "Need an image to wrap");
59 virtual ~ImageWrapper() {}
62 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
64 Image
* InnerImage() const { return mInnerImage
.get(); }
66 void SetInnerImage(Image
* aInnerImage
) {
67 MOZ_ASSERT(aInnerImage
, "Need an image to wrap");
68 mInnerImage
= aInnerImage
;
72 RefPtr
<Image
> mInnerImage
;
76 } // namespace mozilla
78 #endif // mozilla_image_ImageWrapper_h