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_DynamicImage_h
7 #define mozilla_image_DynamicImage_h
9 #include "mozilla/MemoryReporting.h"
10 #include "gfxDrawable.h"
17 * An Image that is dynamically created. The content of the image is provided by
18 * a gfxDrawable. It's anticipated that most uses of DynamicImage will be
21 class DynamicImage
: public Image
{
26 explicit DynamicImage(gfxDrawable
* aDrawable
) : mDrawable(aDrawable
) {
27 MOZ_ASSERT(aDrawable
, "Must have a gfxDrawable to wrap");
30 // Inherited methods from Image.
31 nsresult
GetNativeSizes(nsTArray
<gfx::IntSize
>& aNativeSizes
) const override
;
32 size_t GetNativeSizesLength() const override
;
33 virtual already_AddRefed
<ProgressTracker
> GetProgressTracker() override
;
34 virtual size_t SizeOfSourceWithComputedFallback(
35 SizeOfState
& aState
) const override
;
36 virtual void CollectSizeOfSurfaces(nsTArray
<SurfaceMemoryCounter
>& aCounters
,
37 MallocSizeOf aMallocSizeOf
) const override
;
39 virtual void IncrementAnimationConsumers() override
;
40 virtual void DecrementAnimationConsumers() override
;
42 virtual uint32_t GetAnimationConsumers() override
;
45 virtual nsresult
OnImageDataAvailable(nsIRequest
* aRequest
,
46 nsISupports
* aContext
,
47 nsIInputStream
* aInStr
,
48 uint64_t aSourceOffset
,
49 uint32_t aCount
) override
;
50 virtual nsresult
OnImageDataComplete(nsIRequest
* aRequest
,
51 nsISupports
* aContext
, nsresult aStatus
,
52 bool aLastPart
) override
;
54 virtual void OnSurfaceDiscarded(const SurfaceKey
& aSurfaceKey
) override
;
56 virtual void SetInnerWindowID(uint64_t aInnerWindowId
) override
;
57 virtual uint64_t InnerWindowID() const override
;
59 virtual bool HasError() override
;
60 virtual void SetHasError() override
;
62 nsIURI
* GetURI() const override
;
65 virtual ~DynamicImage() {}
67 RefPtr
<gfxDrawable
> mDrawable
;
71 } // namespace mozilla
73 #endif // mozilla_image_DynamicImage_h