tor-browser

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

RenderTextureHostWrapper.h (3472B)


      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_RENDERTEXTUREHOSTWRAPPER_H
      8 #define MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H
      9 
     10 #include "RenderTextureHostSWGL.h"
     11 
     12 namespace mozilla {
     13 
     14 namespace wr {
     15 
     16 /**
     17 * RenderTextureHost of GPUVideoTextureHost.
     18 *
     19 * GPUVideoTextureHost wraps TextureHost. This class wraps RenderTextureHost of
     20 * the wrapped TextureHost. Lifetime of the wrapped TextureHost is usually
     21 * longer than GPUVideoTextureHost and the wrapped TextureHost is used by
     22 * multiple GPUVideoTextureHosts. This class is used to reduce recreations of
     23 * the wrappded RenderTextureHost. Initializations of some
     24 * RenderTextureHosts(RenderDXGITextureHost and
     25 * RenderDXGIYCbCrTextureHost) have overhead.
     26 */
     27 class RenderTextureHostWrapper final : public RenderTextureHostSWGL {
     28 public:
     29  explicit RenderTextureHostWrapper(ExternalImageId aExternalImageId);
     30 
     31  // RenderTextureHost
     32  wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
     33  void Unlock() override;
     34  void ClearCachedResources() override;
     35  void PrepareForUse() override;
     36  void NotifyForUse() override;
     37  void NotifyNotUsed() override;
     38  bool SyncObjectNeeded() override;
     39  RefPtr<layers::TextureSource> CreateTextureSource(
     40      layers::TextureSourceProvider* aProvider) override;
     41  RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() override;
     42  RenderDXGITextureHost* AsRenderDXGITextureHost() override;
     43  RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() override;
     44  RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() override;
     45  RenderAndroidHardwareBufferTextureHost*
     46  AsRenderAndroidHardwareBufferTextureHost() override;
     47  RenderAndroidSurfaceTextureHost* AsRenderAndroidSurfaceTextureHost() override;
     48  RenderEGLImageTextureHost* AsRenderEGLImageTextureHost() override;
     49  RenderTextureHostSWGL* AsRenderTextureHostSWGL() override;
     50  RenderDMABUFTextureHost* AsRenderDMABUFTextureHost() override;
     51  void SetIsSoftwareDecodedVideo() override;
     52  bool IsSoftwareDecodedVideo() override;
     53  RefPtr<RenderTextureHostUsageInfo> GetOrMergeUsageInfo(
     54      const MutexAutoLock& aProofOfMapLock,
     55      RefPtr<RenderTextureHostUsageInfo> aUsageInfo) override;
     56  RefPtr<RenderTextureHostUsageInfo> GetTextureHostUsageInfo(
     57      const MutexAutoLock& aProofOfMapLock) override;
     58 
     59  // RenderTextureHostSWGL
     60  size_t GetPlaneCount() const override;
     61  gfx::SurfaceFormat GetFormat() const override;
     62  gfx::ColorDepth GetColorDepth() const override;
     63  gfx::YUVRangedColorSpace GetYUVColorSpace() const override;
     64  bool MapPlane(RenderCompositor* aCompositor, uint8_t aChannelIndex,
     65                PlaneInfo& aPlaneInfo) override;
     66  void UnmapPlanes() override;
     67 
     68  // This is just a wrapper, so doesn't need to report the
     69  // size of the wrapped object (which reports itself).
     70  size_t Bytes() override { return 0; }
     71 
     72 private:
     73  ~RenderTextureHostWrapper() override;
     74 
     75  void EnsureTextureHost() const;
     76  RenderTextureHostSWGL* EnsureRenderTextureHostSWGL() const;
     77 
     78  ExternalImageId mExternalImageId;
     79  mutable RefPtr<RenderTextureHost> mTextureHost;
     80 };
     81 
     82 }  // namespace wr
     83 }  // namespace mozilla
     84 
     85 #endif  // MOZILLA_GFX_RENDERTEXTUREHOSTWRAPPER_H