1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
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_EGL_H_
7 #define SHARED_SURFACE_EGL_H_
9 #include "mozilla/Attributes.h"
10 #include "mozilla/Mutex.h"
11 #include "nsAutoPtr.h"
12 #include "SharedSurface.h"
19 class TextureGarbageBin
;
21 class SharedSurface_EGLImage
22 : public SharedSurface
25 static UniquePtr
<SharedSurface_EGLImage
> Create(GLContext
* prodGL
,
26 const GLFormats
& formats
,
27 const gfx::IntSize
& size
,
31 static SharedSurface_EGLImage
* Cast(SharedSurface
* surf
) {
32 MOZ_ASSERT(surf
->mType
== SharedSurfaceType::EGLImageShare
);
34 return (SharedSurface_EGLImage
*)surf
;
37 static bool HasExtensions(GLLibraryEGL
* egl
, GLContext
* gl
);
41 GLLibraryEGL
* const mEGL
;
42 const GLFormats mFormats
;
45 const EGLImage mImage
;
47 GLContext
* mCurConsGL
;
49 nsRefPtr
<TextureGarbageBin
> mGarbageBin
;
52 SharedSurface_EGLImage(GLContext
* gl
,
54 const gfx::IntSize
& size
,
56 const GLFormats
& formats
,
60 EGLDisplay
Display() const;
61 void UpdateProdTexture(const MutexAutoLock
& curAutoLock
);
64 virtual ~SharedSurface_EGLImage();
66 virtual void LockProdImpl() MOZ_OVERRIDE
{}
67 virtual void UnlockProdImpl() MOZ_OVERRIDE
{}
69 virtual void Fence() MOZ_OVERRIDE
;
70 virtual bool WaitSync() MOZ_OVERRIDE
;
71 virtual bool PollSync() MOZ_OVERRIDE
;
73 virtual GLuint
ProdTexture() MOZ_OVERRIDE
{
77 // Implementation-specific functions below:
78 // Returns texture and target
79 void AcquireConsumerTexture(GLContext
* consGL
, GLuint
* out_texture
, GLuint
* out_target
);
84 class SurfaceFactory_EGLImage
85 : public SurfaceFactory
89 static UniquePtr
<SurfaceFactory_EGLImage
> Create(GLContext
* prodGL
,
90 const SurfaceCaps
& caps
);
93 const EGLContext mContext
;
95 SurfaceFactory_EGLImage(GLContext
* prodGL
,
97 const SurfaceCaps
& caps
)
98 : SurfaceFactory(prodGL
, SharedSurfaceType::EGLImageShare
, caps
)
103 virtual UniquePtr
<SharedSurface
> CreateShared(const gfx::IntSize
& size
) MOZ_OVERRIDE
{
104 bool hasAlpha
= mReadCaps
.alpha
;
105 return SharedSurface_EGLImage::Create(mGL
, mFormats
, size
, hasAlpha
, mContext
);
109 } /* namespace gfx */
110 } /* namespace mozilla */
112 #endif /* SHARED_SURFACE_EGL_H_ */