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_SURFACEIO_H_
7 #define SHARED_SURFACEIO_H_
9 #include "mozilla/RefPtr.h"
10 #include "SharedSurface.h"
19 class SharedSurface_IOSurface final
: public SharedSurface
{
21 const UniquePtr
<Texture
> mTex
;
22 const RefPtr
<MacIOSurface
> mIOSurf
;
24 static UniquePtr
<SharedSurface_IOSurface
> Create(const SharedSurfaceDesc
&);
27 SharedSurface_IOSurface(const SharedSurfaceDesc
&, UniquePtr
<MozFramebuffer
>,
28 UniquePtr
<Texture
>, const RefPtr
<MacIOSurface
>&);
31 ~SharedSurface_IOSurface();
33 virtual void LockProdImpl() override
{}
34 virtual void UnlockProdImpl() override
{}
36 virtual void ProducerAcquireImpl() override
{}
37 virtual void ProducerReleaseImpl() override
;
39 virtual bool NeedsIndirectReads() const override
{ return true; }
41 Maybe
<layers::SurfaceDescriptor
> ToSurfaceDescriptor() override
;
44 class SurfaceFactory_IOSurface
: public SurfaceFactory
{
46 const gfx::IntSize mMaxDims
;
48 explicit SurfaceFactory_IOSurface(GLContext
& gl
);
50 virtual UniquePtr
<SharedSurface
> CreateSharedImpl(
51 const SharedSurfaceDesc
& desc
) override
{
52 if (desc
.size
.width
> mMaxDims
.width
||
53 desc
.size
.height
> mMaxDims
.height
) {
56 return SharedSurface_IOSurface::Create(desc
);
62 } /* namespace mozilla */
64 #endif /* SHARED_SURFACEIO_H_ */