Bug 1490079 [wpt PR 12936] - Mark tools/wpt Windows test failures as xfail, a=testonly
[gecko.git] / image / ImageWrapper.h
blob9202a7ad711588391d28b2a396a9764bf0629f96
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
20 public:
21 NS_DECL_ISUPPORTS
22 NS_DECL_IMGICONTAINER
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;
29 virtual size_t
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;
36 #ifdef DEBUG
37 virtual uint32_t GetAnimationConsumers() override;
38 #endif
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,
47 nsresult aStatus,
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;
60 protected:
61 explicit ImageWrapper(Image* aInnerImage)
62 : mInnerImage(aInnerImage)
64 MOZ_ASSERT(aInnerImage, "Need an image to wrap");
67 virtual ~ImageWrapper() { }
69 /**
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;
80 private:
81 RefPtr<Image> mInnerImage;
84 } // namespace image
85 } // namespace mozilla
87 #endif // mozilla_image_ImageWrapper_h