Bug 1796551 [wpt PR 36570] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / image / ImageWrapper.h
blobd72393e9764918e989f44422042005148d89be4a
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"
10 #include "Image.h"
12 namespace mozilla {
13 namespace image {
15 /**
16 * Abstract superclass for Images that wrap other Images.
18 class ImageWrapper : public Image {
19 public:
20 NS_DECL_ISUPPORTS
21 NS_DECL_IMGICONTAINER
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;
33 #ifdef DEBUG
34 virtual uint32_t GetAnimationConsumers() override;
35 #endif
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;
54 protected:
55 explicit ImageWrapper(Image* aInnerImage) : mInnerImage(aInnerImage) {
56 MOZ_ASSERT(aInnerImage, "Need an image to wrap");
59 virtual ~ImageWrapper() {}
61 /**
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;
71 private:
72 RefPtr<Image> mInnerImage;
75 } // namespace image
76 } // namespace mozilla
78 #endif // mozilla_image_ImageWrapper_h