tor-browser

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

SharedSurfaceD3D11Interop.h (2250B)


      1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
      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 SHARED_SURFACE_D3D11_INTEROP_H_
      7 #define SHARED_SURFACE_D3D11_INTEROP_H_
      8 
      9 #include <d3d11.h>
     10 #include <windows.h>
     11 #include "SharedSurface.h"
     12 
     13 namespace mozilla {
     14 
     15 namespace gfx {
     16 class FileHandleWrapper;
     17 }  // namespace gfx
     18 
     19 namespace gl {
     20 
     21 class DXInterop2Device;
     22 class GLContext;
     23 class WGLLibrary;
     24 
     25 class SharedSurface_D3D11Interop final : public SharedSurface {
     26 public:
     27  struct Data final {
     28    const RefPtr<DXInterop2Device> interop;
     29    HANDLE lockHandle;
     30    RefPtr<ID3D11Texture2D> texD3D;
     31    RefPtr<gfx::FileHandleWrapper> dxgiHandle;
     32    UniquePtr<Renderbuffer> interopRb;
     33    UniquePtr<MozFramebuffer> interopFbIfNeedsIndirect;
     34  };
     35  const Data mData;
     36  const bool mNeedsFinish;
     37 
     38 private:
     39  bool mLockedForGL = false;
     40 
     41 public:
     42  static UniquePtr<SharedSurface_D3D11Interop> Create(const SharedSurfaceDesc&,
     43                                                      DXInterop2Device*);
     44 
     45 private:
     46  SharedSurface_D3D11Interop(const SharedSurfaceDesc&,
     47                             UniquePtr<MozFramebuffer>&& fbForDrawing, Data&&);
     48 
     49 public:
     50  virtual ~SharedSurface_D3D11Interop();
     51 
     52  void LockProdImpl() override {}
     53  void UnlockProdImpl() override {}
     54 
     55  void ProducerAcquireImpl() override;
     56  void ProducerReleaseImpl() override;
     57 
     58  Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
     59 };
     60 
     61 class SurfaceFactory_D3D11Interop : public SurfaceFactory {
     62 public:
     63  const RefPtr<DXInterop2Device> mInterop;
     64 
     65  static UniquePtr<SurfaceFactory_D3D11Interop> Create(GLContext& gl);
     66 
     67 protected:
     68  SurfaceFactory_D3D11Interop(const PartialSharedSurfaceDesc&,
     69                              DXInterop2Device* interop);
     70 
     71 public:
     72  virtual ~SurfaceFactory_D3D11Interop();
     73 
     74 protected:
     75  UniquePtr<SharedSurface> CreateSharedImpl(
     76      const SharedSurfaceDesc& desc) override {
     77    return SharedSurface_D3D11Interop::Create(desc, mInterop);
     78  }
     79 };
     80 
     81 } /* namespace gl */
     82 } /* namespace mozilla */
     83 
     84 #endif /* SHARED_SURFACE_D3D11_INTEROP_H_ */