Fix typo in 9b54bd30006c008b4a951331b273613d5bac3abf
[pm.git] / image / src / DynamicImage.h
blob4a24f09bc164a35e38a2aa4a78bc78904aa5505a
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_DYNAMICIMAGE_H_
7 #define MOZILLA_IMAGELIB_DYNAMICIMAGE_H_
9 #include "mozilla/MemoryReporting.h"
10 #include "gfxDrawable.h"
11 #include "Image.h"
13 namespace mozilla {
14 namespace image {
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.
21 class DynamicImage : public Image
23 public:
24 NS_DECL_ISUPPORTS
25 NS_DECL_IMGICONTAINER
27 explicit DynamicImage(gfxDrawable* aDrawable)
28 : mDrawable(aDrawable)
30 MOZ_ASSERT(aDrawable, "Must have a gfxDrawable to wrap");
33 // Inherited methods from Image.
34 virtual nsresult Init(const char* aMimeType, uint32_t aFlags) override;
36 virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
37 virtual size_t SizeOfSourceWithComputedFallback(
38 MallocSizeOf aMallocSizeOf) const override;
39 virtual size_t SizeOfDecoded(gfxMemoryLocation aLocation,
40 MallocSizeOf aMallocSizeOf) const override;
42 virtual void IncrementAnimationConsumers() override;
43 virtual void DecrementAnimationConsumers() override;
44 #ifdef DEBUG
45 virtual uint32_t GetAnimationConsumers() override;
46 #endif
48 virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
49 nsISupports* aContext,
50 nsIInputStream* aInStr,
51 uint64_t aSourceOffset,
52 uint32_t aCount) override;
53 virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
54 nsISupports* aContext,
55 nsresult aStatus,
56 bool aLastPart) override;
58 virtual void OnSurfaceDiscarded() override;
60 virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
61 virtual uint64_t InnerWindowID() const override;
63 virtual bool HasError() override;
64 virtual void SetHasError() override;
66 virtual ImageURL* GetURI() override;
68 private:
69 virtual ~DynamicImage() { }
71 nsRefPtr<gfxDrawable> mDrawable;
74 } // namespace image
75 } // namespace mozilla
77 #endif // MOZILLA_IMAGELIB_DYNAMICIMAGE_H_