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_DMABUF_H_
7 #define SHARED_SURFACE_DMABUF_H_
9 #include "SharedSurface.h"
10 #include "mozilla/widget/DMABufSurface.h"
18 class SharedSurface_DMABUF final
: public SharedSurface
{
20 const RefPtr
<DMABufSurface
> mSurface
;
22 static UniquePtr
<SharedSurface_DMABUF
> Create(const SharedSurfaceDesc
&);
25 SharedSurface_DMABUF(const SharedSurfaceDesc
&, UniquePtr
<MozFramebuffer
>,
26 RefPtr
<DMABufSurface
>);
28 void UpdateProdTexture(const MutexAutoLock
& curAutoLock
);
31 virtual ~SharedSurface_DMABUF();
33 // Exclusive Content/WebGL lock/unlock of surface for write
34 virtual void LockProdImpl() override
{}
35 virtual void UnlockProdImpl() override
{}
37 // Non-exclusive Content/WebGL lock/unlock of surface for write
38 virtual void ProducerAcquireImpl() override
{}
39 virtual void ProducerReleaseImpl() override
;
41 // Non-exclusive Content/WebGL lock/unlock for read from surface
42 virtual void ProducerReadAcquireImpl() override
{}
43 virtual void ProducerReadReleaseImpl() override
{}
45 Maybe
<layers::SurfaceDescriptor
> ToSurfaceDescriptor() override
;
47 void WaitForBufferOwnership() override
;
50 class SurfaceFactory_DMABUF
: public SurfaceFactory
{
52 static UniquePtr
<SurfaceFactory_DMABUF
> Create(GLContext
& gl
);
54 explicit SurfaceFactory_DMABUF(GLContext
&);
57 virtual UniquePtr
<SharedSurface
> CreateSharedImpl(
58 const SharedSurfaceDesc
& desc
) override
{
59 return SharedSurface_DMABUF::Create(desc
);
62 bool CanCreateSurface(GLContext
& gl
);
67 } // namespace mozilla
69 #endif /* SHARED_SURFACE_DMABUF_H_ */