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_ANDROID_HARDWARE_BUFFER_H_
7 #define SHARED_SURFACE_ANDROID_HARDWARE_BUFFER_H_
9 #include "mozilla/Attributes.h"
10 #include "mozilla/Mutex.h"
11 #include "CompositorTypes.h"
12 #include "SharedSurface.h"
17 class AndroidHardwareBuffer
;
22 class SharedSurface_AndroidHardwareBuffer final
: public SharedSurface
{
24 const UniquePtr
<Texture
> mTex
;
25 const RefPtr
<layers::AndroidHardwareBuffer
> mAndroidHardwareBuffer
;
28 static UniquePtr
<SharedSurface_AndroidHardwareBuffer
> Create(
29 const SharedSurfaceDesc
&);
32 SharedSurface_AndroidHardwareBuffer(
33 const SharedSurfaceDesc
&, UniquePtr
<MozFramebuffer
>, UniquePtr
<Texture
>,
34 RefPtr
<layers::AndroidHardwareBuffer
> buffer
);
37 virtual ~SharedSurface_AndroidHardwareBuffer();
39 void LockProdImpl() override
{}
40 void UnlockProdImpl() override
{}
42 void ProducerAcquireImpl() override
{}
43 void ProducerReleaseImpl() override
;
45 Maybe
<layers::SurfaceDescriptor
> ToSurfaceDescriptor() override
;
47 void WaitForBufferOwnership() override
;
50 class SurfaceFactory_AndroidHardwareBuffer final
: public SurfaceFactory
{
52 static UniquePtr
<SurfaceFactory_AndroidHardwareBuffer
> Create(GLContext
&);
55 explicit SurfaceFactory_AndroidHardwareBuffer(
56 const PartialSharedSurfaceDesc
& desc
)
57 : SurfaceFactory(desc
) {}
60 virtual UniquePtr
<SharedSurface
> CreateSharedImpl(
61 const SharedSurfaceDesc
& desc
) override
{
62 return SharedSurface_AndroidHardwareBuffer::Create(desc
);
68 } /* namespace mozilla */
70 #endif /* SHARED_SURFACE_ANDROID_HARDWARE_BUFFER_H_ */