Bug 1836072 [wpt PR 40324] - Fix scrollbar-width repaint issues on non viewports...
[gecko.git] / gfx / gl / SharedSurfaceD3D11Interop.h
blob5295c23f0072ff98e0a16bcd888ba4b3862b6082
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/. */
6 #ifndef SHARED_SURFACE_D3D11_INTEROP_H_
7 #define SHARED_SURFACE_D3D11_INTEROP_H_
9 #include <d3d11.h>
10 #include <windows.h>
11 #include "SharedSurface.h"
13 namespace mozilla {
14 namespace gl {
16 class DXInterop2Device;
17 class GLContext;
18 class WGLLibrary;
20 class SharedSurface_D3D11Interop final : public SharedSurface {
21 public:
22 struct Data final {
23 const RefPtr<DXInterop2Device> interop;
24 HANDLE lockHandle;
25 RefPtr<ID3D11Texture2D> texD3D;
26 HANDLE dxgiHandle;
27 UniquePtr<Renderbuffer> interopRb;
28 UniquePtr<MozFramebuffer> interopFbIfNeedsIndirect;
30 const Data mData;
31 const bool mNeedsFinish;
33 private:
34 bool mLockedForGL = false;
36 public:
37 static UniquePtr<SharedSurface_D3D11Interop> Create(const SharedSurfaceDesc&,
38 DXInterop2Device*);
40 private:
41 SharedSurface_D3D11Interop(const SharedSurfaceDesc&,
42 UniquePtr<MozFramebuffer>&& fbForDrawing, Data&&);
44 public:
45 virtual ~SharedSurface_D3D11Interop();
47 void LockProdImpl() override {}
48 void UnlockProdImpl() override {}
50 void ProducerAcquireImpl() override;
51 void ProducerReleaseImpl() override;
53 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override;
56 class SurfaceFactory_D3D11Interop : public SurfaceFactory {
57 public:
58 const RefPtr<DXInterop2Device> mInterop;
60 static UniquePtr<SurfaceFactory_D3D11Interop> Create(GLContext& gl);
62 protected:
63 SurfaceFactory_D3D11Interop(const PartialSharedSurfaceDesc&,
64 DXInterop2Device* interop);
66 public:
67 virtual ~SurfaceFactory_D3D11Interop();
69 protected:
70 UniquePtr<SharedSurface> CreateSharedImpl(
71 const SharedSurfaceDesc& desc) override {
72 return SharedSurface_D3D11Interop::Create(desc, mInterop);
76 } /* namespace gl */
77 } /* namespace mozilla */
79 #endif /* SHARED_SURFACE_D3D11_INTEROP_H_ */