tor-browser

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

WebRenderTextureHost.h (4146B)


      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_GFX_WEBRENDERTEXTUREHOST_H
      8 #define MOZILLA_GFX_WEBRENDERTEXTUREHOST_H
      9 
     10 #include "mozilla/layers/TextureHost.h"
     11 #include "mozilla/webrender/WebRenderTypes.h"
     12 
     13 namespace mozilla {
     14 namespace layers {
     15 
     16 class SurfaceDescriptor;
     17 
     18 // This textureHost is specialized for WebRender usage. With WebRender, there is
     19 // no Compositor during composition. Instead, we use RendererOGL for
     20 // composition. So, there are some UNREACHABLE asserts for the original
     21 // Compositor related code path in this class. Furthermore, the RendererOGL runs
     22 // at RenderThead instead of Compositor thread. This class is also creating the
     23 // corresponding RenderXXXTextureHost used by RendererOGL at RenderThread.
     24 class WebRenderTextureHost final : public TextureHost {
     25 public:
     26  WebRenderTextureHost(TextureFlags aFlags, TextureHost* aTexture,
     27                       const wr::ExternalImageId& aExternalImageId);
     28  virtual ~WebRenderTextureHost();
     29 
     30  void DeallocateDeviceData() override {}
     31 
     32  void UnbindTextureSource() override;
     33 
     34  gfx::SurfaceFormat GetFormat() const override;
     35 
     36  virtual void NotifyNotUsed() override;
     37 
     38  virtual bool IsValid() override;
     39 
     40  // Return the format used for reading the texture. Some hardware specific
     41  // textureHosts use their special data representation internally, but we could
     42  // treat these textureHost as the read-format when we read them.
     43  // Please check TextureHost::GetReadFormat().
     44  gfx::SurfaceFormat GetReadFormat() const override;
     45 
     46  already_AddRefed<gfx::DataSourceSurface> GetAsSurface(
     47      gfx::DataSourceSurface* aSurface) override;
     48 
     49  gfx::ColorDepth GetColorDepth() const override;
     50  gfx::YUVColorSpace GetYUVColorSpace() const override;
     51  gfx::ColorRange GetColorRange() const override;
     52 
     53  bool NeedsYFlip() const override;
     54 
     55  gfx::IntSize GetSize() const override;
     56 
     57 #ifdef MOZ_LAYERS_HAVE_LOG
     58  const char* Name() override { return "WebRenderTextureHost"; }
     59 #endif
     60 
     61  void MaybeDestroyRenderTexture() override;
     62 
     63  WebRenderTextureHost* AsWebRenderTextureHost() override { return this; }
     64 
     65  RemoteTextureHostWrapper* AsRemoteTextureHostWrapper() override {
     66    return mWrappedTextureHost->AsRemoteTextureHostWrapper();
     67  }
     68 
     69  BufferTextureHost* AsBufferTextureHost() override {
     70    return mWrappedTextureHost->AsBufferTextureHost();
     71  }
     72 
     73  DXGITextureHostD3D11* AsDXGITextureHostD3D11() override {
     74    return mWrappedTextureHost->AsDXGITextureHostD3D11();
     75  }
     76 
     77  DXGIYCbCrTextureHostD3D11* AsDXGIYCbCrTextureHostD3D11() override {
     78    return mWrappedTextureHost->AsDXGIYCbCrTextureHostD3D11();
     79  }
     80 
     81  bool IsWrappingSurfaceTextureHost() override;
     82 
     83  virtual void PrepareForUse() override;
     84 
     85  wr::ExternalImageId GetExternalImageKey();
     86 
     87  int32_t GetRGBStride();
     88 
     89  bool NeedsDeferredDeletion() const override;
     90 
     91  uint32_t NumSubTextures() override;
     92 
     93  void PushResourceUpdates(wr::TransactionBuilder& aResources,
     94                           ResourceUpdateOp aOp,
     95                           const Range<wr::ImageKey>& aImageKeys,
     96                           const wr::ExternalImageId& aExtID) override;
     97 
     98  void PushDisplayItems(wr::DisplayListBuilder& aBuilder,
     99                        const wr::LayoutRect& aBounds,
    100                        const wr::LayoutRect& aClip, wr::ImageRendering aFilter,
    101                        const Range<wr::ImageKey>& aImageKeys,
    102                        PushDisplayItemFlagSet aFlags) override;
    103 
    104  bool SupportsExternalCompositing(WebRenderBackend aBackend) override;
    105 
    106  void SetReadFence(Fence* aReadFence) override;
    107 
    108  AndroidHardwareBuffer* GetAndroidHardwareBuffer() const override;
    109 
    110  void MaybeNotifyForUse(wr::TransactionBuilder& aTxn);
    111 
    112  TextureHostType GetTextureHostType() override;
    113 
    114  const RefPtr<TextureHost> mWrappedTextureHost;
    115 };
    116 
    117 }  // namespace layers
    118 }  // namespace mozilla
    119 
    120 #endif  // MOZILLA_GFX_WEBRENDERTEXTUREHOST_H