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_IMAGELIB_IMAGEWRAPPER_H_
7 #define MOZILLA_IMAGELIB_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 virtual nsresult
Init(const char* aMimeType
, uint32_t aFlags
) MOZ_OVERRIDE
;
27 virtual already_AddRefed
<ProgressTracker
> GetProgressTracker() MOZ_OVERRIDE
;
30 SizeOfSourceWithComputedFallback( MallocSizeOf aMallocSizeOf
) const
33 SizeOfDecoded(gfxMemoryLocation aLocation
,
34 MallocSizeOf aMallocSizeOf
) const MOZ_OVERRIDE
;
36 virtual void IncrementAnimationConsumers() MOZ_OVERRIDE
;
37 virtual void DecrementAnimationConsumers() MOZ_OVERRIDE
;
39 virtual uint32_t GetAnimationConsumers() MOZ_OVERRIDE
;
42 virtual nsresult
OnImageDataAvailable(nsIRequest
* aRequest
,
43 nsISupports
* aContext
,
44 nsIInputStream
* aInStr
,
45 uint64_t aSourceOffset
,
46 uint32_t aCount
) MOZ_OVERRIDE
;
47 virtual nsresult
OnImageDataComplete(nsIRequest
* aRequest
,
48 nsISupports
* aContext
,
50 bool aLastPart
) MOZ_OVERRIDE
;
52 virtual void OnSurfaceDiscarded() MOZ_OVERRIDE
;
54 virtual void SetInnerWindowID(uint64_t aInnerWindowId
) MOZ_OVERRIDE
;
55 virtual uint64_t InnerWindowID() const MOZ_OVERRIDE
;
57 virtual bool HasError() MOZ_OVERRIDE
;
58 virtual void SetHasError() MOZ_OVERRIDE
;
60 virtual ImageURL
* GetURI() MOZ_OVERRIDE
;
63 explicit ImageWrapper(Image
* aInnerImage
)
64 : mInnerImage(aInnerImage
)
66 MOZ_ASSERT(aInnerImage
, "Need an image to wrap");
69 virtual ~ImageWrapper() { }
72 * Returns a weak reference to the inner image wrapped by this ImageWrapper.
74 Image
* InnerImage() const { return mInnerImage
.get(); }
76 void SetInnerImage(Image
* aInnerImage
)
78 MOZ_ASSERT(aInnerImage
, "Need an image to wrap");
79 mInnerImage
= aInnerImage
;
83 nsRefPtr
<Image
> mInnerImage
;
87 } // namespace mozilla
89 #endif // MOZILLA_IMAGELIB_IMAGEWRAPPER_H_