tor-browser

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

WebRenderImageProvider.h (1917B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef MOZILLA_IMAGE_WEBRENDERIMAGEPROVIDER_H_
      8 #define MOZILLA_IMAGE_WEBRENDERIMAGEPROVIDER_H_
      9 
     10 #include "nsISupportsImpl.h"
     11 
     12 namespace mozilla {
     13 namespace layers {
     14 class RenderRootStateManager;
     15 }
     16 
     17 namespace wr {
     18 class IpcResourceUpdateQueue;
     19 struct ExternalImageId;
     20 struct ImageKey;
     21 }  // namespace wr
     22 
     23 namespace image {
     24 
     25 class ImageResource;
     26 using ImageProviderId = uint32_t;
     27 
     28 class WebRenderImageProvider {
     29 public:
     30  // Subclasses may or may not be XPCOM classes, so we just require that they
     31  // implement AddRef and Release.
     32  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
     33 
     34  ImageProviderId GetProviderId() const { return mProviderId; }
     35 
     36  static ImageProviderId AllocateProviderId();
     37 
     38  /**
     39   * Generate an ImageKey for the given frame.
     40   * @param aSurface  The current frame. This should match what was cached via
     41   *                  SetCurrentFrame, but if it does not, it will need to
     42   *                  regenerate the cached ImageKey.
     43   */
     44  virtual nsresult UpdateKey(layers::RenderRootStateManager* aManager,
     45                             wr::IpcResourceUpdateQueue& aResources,
     46                             wr::ImageKey& aKey) {
     47    return NS_ERROR_NOT_AVAILABLE;
     48  }
     49 
     50  /**
     51   * Invalidate if a blob recording or simple surface provider (both are only
     52   * used by vector images), requiring it to be regenerated.
     53   */
     54  virtual void InvalidateSurface() {}
     55 
     56 protected:
     57  WebRenderImageProvider(const ImageResource* aImage);
     58 
     59 private:
     60  ImageProviderId mProviderId;
     61 };
     62 
     63 }  // namespace image
     64 }  // namespace mozilla
     65 
     66 #endif /* MOZILLA_IMAGE_WEBRENDERIMAGEPROVIDER_H_ */