tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DynamicImage.h (2312B)


      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 public:
     23  NS_DECL_ISUPPORTS
     24  NS_DECL_IMGICONTAINER
     25 
     26  explicit DynamicImage(gfxDrawable* aDrawable) : mDrawable(aDrawable) {
     27    MOZ_ASSERT(aDrawable, "Must have a gfxDrawable to wrap");
     28  }
     29 
     30  // Inherited methods from Image.
     31  virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
     32  virtual size_t SizeOfSourceWithComputedFallback(
     33      SizeOfState& aState) const override;
     34  virtual void CollectSizeOfSurfaces(nsTArray<SurfaceMemoryCounter>& aCounters,
     35                                     MallocSizeOf aMallocSizeOf) const override;
     36 
     37  virtual void IncrementAnimationConsumers() override;
     38  virtual void DecrementAnimationConsumers() override;
     39 #ifdef DEBUG
     40  virtual uint32_t GetAnimationConsumers() override;
     41 #endif
     42 
     43  virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
     44                                        nsIInputStream* aInStr,
     45                                        uint64_t aSourceOffset,
     46                                        uint32_t aCount) override;
     47  virtual nsresult OnImageDataComplete(nsIRequest* aRequest, nsresult aStatus,
     48                                       bool aLastPart) override;
     49 
     50  virtual void OnSurfaceDiscarded(const SurfaceKey& aSurfaceKey) override;
     51 
     52  virtual void SetInnerWindowID(uint64_t aInnerWindowId) override;
     53  virtual uint64_t InnerWindowID() const override;
     54 
     55  virtual bool HasError() override;
     56  virtual void SetHasError() override;
     57 
     58  nsIURI* GetURI() const override;
     59 
     60 private:
     61  virtual ~DynamicImage() {}
     62 
     63  RefPtr<gfxDrawable> mDrawable;
     64 };
     65 
     66 }  // namespace image
     67 }  // namespace mozilla
     68 
     69 #endif  // mozilla_image_DynamicImage_h