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_ANGLE_H_
7 #define SHARED_SURFACE_ANGLE_H_
11 #include "SharedSurface.h"
13 struct IDXGIKeyedMutex
;
14 struct ID3D11Texture2D
;
19 class FileHandleWrapper
;
27 class SharedSurface_ANGLEShareHandle final
: public SharedSurface
{
29 const std::weak_ptr
<EglDisplay
> mEGL
;
30 const EGLSurface mPBuffer
;
31 const RefPtr
<gfx::FileHandleWrapper
> mSharedHandle
;
32 const RefPtr
<IDXGIKeyedMutex
> mKeyedMutex
;
34 static UniquePtr
<SharedSurface_ANGLEShareHandle
> Create(
35 const SharedSurfaceDesc
&);
38 SharedSurface_ANGLEShareHandle(const SharedSurfaceDesc
&,
39 const std::weak_ptr
<EglDisplay
>& egl
,
41 RefPtr
<gfx::FileHandleWrapper
>&& aSharedHandle
,
42 const RefPtr
<IDXGIKeyedMutex
>& keyedMutex
);
45 virtual ~SharedSurface_ANGLEShareHandle();
47 virtual void LockProdImpl() override
;
48 virtual void UnlockProdImpl() override
;
50 virtual bool ProducerAcquireImpl() override
;
51 virtual void ProducerReleaseImpl() override
;
52 virtual bool ProducerReadAcquireImpl() override
;
53 virtual void ProducerReadReleaseImpl() override
;
55 Maybe
<layers::SurfaceDescriptor
> ToSurfaceDescriptor() override
;
58 class SurfaceFactory_ANGLEShareHandle final
: public SurfaceFactory
{
60 static UniquePtr
<SurfaceFactory_ANGLEShareHandle
> Create(GLContext
& gl
);
63 explicit SurfaceFactory_ANGLEShareHandle(const PartialSharedSurfaceDesc
& desc
)
64 : SurfaceFactory(desc
) {}
66 virtual UniquePtr
<SharedSurface
> CreateSharedImpl(
67 const SharedSurfaceDesc
& desc
) override
{
68 return SharedSurface_ANGLEShareHandle::Create(desc
);
73 } /* namespace mozilla */
75 #endif /* SHARED_SURFACE_ANGLE_H_ */