DynamicImage.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef mozilla_image_DynamicImage_h
  6. #define mozilla_image_DynamicImage_h
  7. #include "mozilla/MemoryReporting.h"
  8. #include "gfxDrawable.h"
  9. #include "Image.h"
  10. namespace mozilla {
  11. namespace image {
  12. /**
  13. * An Image that is dynamically created. The content of the image is provided by
  14. * a gfxDrawable. It's anticipated that most uses of DynamicImage will be
  15. * ephemeral.
  16. */
  17. class DynamicImage : public Image
  18. {
  19. public:
  20. NS_DECL_ISUPPORTS
  21. NS_DECL_IMGICONTAINER
  22. explicit DynamicImage(gfxDrawable* aDrawable)
  23. : mDrawable(aDrawable)
  24. {
  25. MOZ_ASSERT(aDrawable, "Must have a gfxDrawable to wrap");
  26. }
  27. // Inherited methods from Image.
  28. virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
  29. virtual size_t SizeOfSourceWithComputedFallback(
  30. MallocSizeOf aMallocSizeOf) const override;
  31. virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
  32. 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
  38. virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
  39. nsISupports* aContext,
  40. nsIInputStream* aInStr,
  41. uint64_t aSourceOffset,
  42. uint32_t aCount) override;
  43. virtual nsresult OnImageDataComplete(nsIRequest* aRequest,
  44. nsISupports* aContext,
  45. nsresult aStatus,
  46. bool aLastPart) override;
  47. virtual void OnSurfaceDiscarded() override;
  48. virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
  49. virtual uint64_t InnerWindowID() const override;
  50. virtual bool HasError() override;
  51. virtual void SetHasError() override;
  52. virtual ImageURL* GetURI() override;
  53. private:
  54. virtual ~DynamicImage() { }
  55. RefPtr<gfxDrawable> mDrawable;
  56. };
  57. } // namespace image
  58. } // namespace mozilla
  59. #endif // mozilla_image_DynamicImage_h