tor-browser

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

SharedSurfaceANGLE.h (2565B)


      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_ANGLE_H_
      7 #define SHARED_SURFACE_ANGLE_H_
      8 
      9 #include <windows.h>
     10 #include <memory>
     11 
     12 #include "mozilla/layers/LayersTypes.h"
     13 #include "SharedSurface.h"
     14 
     15 struct IDXGIKeyedMutex;
     16 struct ID3D11Device;
     17 struct ID3D11Texture2D;
     18 
     19 namespace mozilla {
     20 
     21 namespace gfx {
     22 class FileHandleWrapper;
     23 }  // namespace gfx
     24 
     25 namespace layers {
     26 class FenceD3D11;
     27 }  // namespace layers
     28 
     29 namespace gl {
     30 
     31 class GLContext;
     32 class EglDisplay;
     33 
     34 class SharedSurface_ANGLEShareHandle final : public SharedSurface {
     35 public:
     36  const RefPtr<ID3D11Device> mDevice;
     37  const std::weak_ptr<EglDisplay> mEGL;
     38  const EGLSurface mPBuffer;
     39  const RefPtr<gfx::FileHandleWrapper> mSharedHandle;
     40  const Maybe<layers::CompositeProcessFencesHolderId> mFencesHolderId;
     41  const RefPtr<layers::FenceD3D11> mWriteFence;
     42  const RefPtr<IDXGIKeyedMutex> mKeyedMutex;
     43 
     44  static UniquePtr<SharedSurface_ANGLEShareHandle> Create(
     45      const SharedSurfaceDesc&);
     46 
     47 private:
     48  SharedSurface_ANGLEShareHandle(
     49      const SharedSurfaceDesc&, const RefPtr<ID3D11Device> aDevice,
     50      const std::weak_ptr<EglDisplay>& egl, EGLSurface pbuffer,
     51      RefPtr<gfx::FileHandleWrapper>&& aSharedHandle,
     52      const Maybe<layers::CompositeProcessFencesHolderId> aFencesHolderId,
     53      const RefPtr<layers::FenceD3D11>& aWriteFence,
     54      const RefPtr<IDXGIKeyedMutex>& keyedMutex);
     55 
     56 public:
     57  virtual ~SharedSurface_ANGLEShareHandle();
     58 
     59  virtual void LockProdImpl() override;
     60  virtual void UnlockProdImpl() override;
     61 
     62  virtual void ProducerAcquireImpl() override;
     63  virtual void ProducerReleaseImpl() override;
     64  virtual void ProducerReadAcquireImpl() override;
     65  virtual void ProducerReadReleaseImpl() override;
     66 
     67  Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
     68 };
     69 
     70 class SurfaceFactory_ANGLEShareHandle final : public SurfaceFactory {
     71 public:
     72  static UniquePtr<SurfaceFactory_ANGLEShareHandle> Create(GLContext& gl);
     73 
     74 private:
     75  explicit SurfaceFactory_ANGLEShareHandle(const PartialSharedSurfaceDesc& desc)
     76      : SurfaceFactory(desc) {}
     77 
     78  virtual UniquePtr<SharedSurface> CreateSharedImpl(
     79      const SharedSurfaceDesc& desc) override {
     80    return SharedSurface_ANGLEShareHandle::Create(desc);
     81  }
     82 };
     83 
     84 }  // namespace gl
     85 } /* namespace mozilla */
     86 
     87 #endif /* SHARED_SURFACE_ANGLE_H_ */