Line data Source code
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/. */
5 :
6 : #ifndef mozilla_image_DynamicImage_h
7 : #define mozilla_image_DynamicImage_h
8 :
9 : #include "mozilla/MemoryReporting.h"
10 : #include "gfxDrawable.h"
11 : #include "Image.h"
12 :
13 : namespace mozilla {
14 : namespace image {
15 :
16 : /**
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
19 : * ephemeral.
20 : */
21 : class DynamicImage : public Image
22 : {
23 : public:
24 : NS_DECL_ISUPPORTS
25 : NS_DECL_IMGICONTAINER
26 :
27 0 : explicit DynamicImage(gfxDrawable* aDrawable)
28 0 : : mDrawable(aDrawable)
29 : {
30 0 : MOZ_ASSERT(aDrawable, "Must have a gfxDrawable to wrap");
31 0 : }
32 :
33 : // Inherited methods from Image.
34 : nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
35 : virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
36 : virtual size_t SizeOfSourceWithComputedFallback(
37 : MallocSizeOf aMallocSizeOf) const override;
38 : virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
39 : MallocSizeOf aMallocSizeOf) const override;
40 :
41 : virtual void IncrementAnimationConsumers() override;
42 : virtual void DecrementAnimationConsumers() override;
43 : #ifdef DEBUG
44 : virtual uint32_t GetAnimationConsumers() override;
45 : #endif
46 :
47 : virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
48 : nsISupports* aContext,
49 : nsIInputStream* aInStr,
50 : uint64_t aSourceOffset,
51 : uint32_t aCount) override;
52 : virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
53 : nsISupports* aContext,
54 : nsresult aStatus,
55 : bool aLastPart) override;
56 :
57 : virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
58 :
59 : virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
60 : virtual uint64_t InnerWindowID() const override;
61 :
62 : virtual bool HasError() override;
63 : virtual void SetHasError() override;
64 :
65 : virtual ImageURL* GetURI() override;
66 :
67 : private:
68 0 : virtual ~DynamicImage() { }
69 :
70 : RefPtr<gfxDrawable> mDrawable;
71 : };
72 :
73 : } // namespace image
74 : } // namespace mozilla
75 :
76 : #endif // mozilla_image_DynamicImage_h
|