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
24 // Inherited methods from Image.
25 nsresult
GetNativeSizes(nsTArray
<gfx::IntSize
>& aNativeSizes
) const override
;
26 size_t GetNativeSizesLength() const override
;
27 virtual already_AddRefed
<ProgressTracker
> GetProgressTracker() override
;
30 SizeOfSourceWithComputedFallback(SizeOfState
& aState
) const override
;
31 virtual void CollectSizeOfSurfaces(nsTArray
<SurfaceMemoryCounter
>& aCounters
,
32 MallocSizeOf aMallocSizeOf
) const override
;
34 virtual void IncrementAnimationConsumers() override
;
35 virtual void DecrementAnimationConsumers() override
;
37 virtual uint32_t GetAnimationConsumers() override
;
40 virtual nsresult
OnImageDataAvailable(nsIRequest
* aRequest
,
41 nsISupports
* aContext
,
42 nsIInputStream
* aInStr
,
43 uint64_t aSourceOffset
,
44 uint32_t aCount
) override
;
45 virtual nsresult
OnImageDataComplete(nsIRequest
* aRequest
,
46 nsISupports
* aContext
,
48 bool aLastPart
) override
;
50 virtual void OnSurfaceDiscarded(const SurfaceKey
& aSurfaceKey
) override
;
52 virtual void SetInnerWindowID(uint64_t aInnerWindowId
) override
;
53 virtual uint64_t InnerWindowID() const override
;
55 virtual bool HasError() override
;
56 virtual void SetHasError() override
;
58 nsIURI
* GetURI() const override
;
61 explicit ImageWrapper(Image
* aInnerImage
)
62 : mInnerImage(aInnerImage
)
64 MOZ_ASSERT(aInnerImage
, "Need an image to wrap");
67 virtual ~ImageWrapper() { }
70 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
72 Image
* InnerImage() const { return mInnerImage
.get(); }
74 void SetInnerImage(Image
* aInnerImage
)
76 MOZ_ASSERT(aInnerImage
, "Need an image to wrap");
77 mInnerImage
= aInnerImage
;
81 RefPtr
<Image
> mInnerImage
;
85 } // namespace mozilla
87 #endif // mozilla_image_ImageWrapper_h