Bug 1679927 Part 1: Make AppleVTDecoder check color depth and use 10-bit YUV420 when...
[gecko.git] / image / ImageWrapper.h
blob07dd5f73260e2327377d5eba5106bdf643f23636
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 nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
25 size_t GetNativeSizesLength() const override;
26 virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
28 virtual size_t SizeOfSourceWithComputedFallback(
29 SizeOfState& aState) const override;
30 virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
31 MallocSizeOf aMallocSizeOf) const override;
33 virtual void IncrementAnimationConsumers() override;
34 virtual void DecrementAnimationConsumers() override;
35 #ifdef DEBUG
36 virtual uint32_t GetAnimationConsumers() override;
37 #endif
39 virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
40 nsIInputStream* aInStr,
41 uint64_t aSourceOffset,
42 uint32_t aCount) override;
43 virtual nsresult OnImageDataComplete(nsIRequest* aRequest, nsresult aStatus,
44 bool aLastPart) override;
46 virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
48 virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
49 virtual uint64_t InnerWindowID() const override;
51 virtual bool HasError() override;
52 virtual void SetHasError() override;
54 nsIURI* GetURI() const override;
56 protected:
57 explicit ImageWrapper(Image* aInnerImage) : mInnerImage(aInnerImage) {
58 MOZ_ASSERT(aInnerImage, "Need an image to wrap");
61 virtual ~ImageWrapper() {}
63 /**
64 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
66 Image* InnerImage() const { return mInnerImage.get(); }
68 void SetInnerImage(Image* aInnerImage) {
69 MOZ_ASSERT(aInnerImage, "Need an image to wrap");
70 mInnerImage = aInnerImage;
73 private:
74 RefPtr<Image> mInnerImage;
77 } // namespace image
78 } // namespace mozilla
80 #endif // mozilla_image_ImageWrapper_h