Bumping manifests a=b2g-bump
[gecko.git] / gfx / gl / SharedSurfaceEGL.h
blob8c3fec0cd9c4779754d1b7bacf0abc69a5d4e056
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"
14 namespace mozilla {
15 namespace gl {
17 class GLContext;
18 class GLLibraryEGL;
19 class TextureGarbageBin;
21 class SharedSurface_EGLImage
22 : public SharedSurface
24 public:
25 static UniquePtr<SharedSurface_EGLImage> Create(GLContext* prodGL,
26 const GLFormats& formats,
27 const gfx::IntSize& size,
28 bool hasAlpha,
29 EGLContext context);
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);
39 protected:
40 mutable Mutex mMutex;
41 GLLibraryEGL* const mEGL;
42 const GLFormats mFormats;
43 GLuint mProdTex;
44 public:
45 const EGLImage mImage;
46 protected:
47 GLContext* mCurConsGL;
48 GLuint mConsTex;
49 nsRefPtr<TextureGarbageBin> mGarbageBin;
50 EGLSync mSync;
52 SharedSurface_EGLImage(GLContext* gl,
53 GLLibraryEGL* egl,
54 const gfx::IntSize& size,
55 bool hasAlpha,
56 const GLFormats& formats,
57 GLuint prodTex,
58 EGLImage image);
60 EGLDisplay Display() const;
61 void UpdateProdTexture(const MutexAutoLock& curAutoLock);
63 public:
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 {
74 return mProdTex;
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
87 public:
88 // Fallible:
89 static UniquePtr<SurfaceFactory_EGLImage> Create(GLContext* prodGL,
90 const SurfaceCaps& caps);
92 protected:
93 const EGLContext mContext;
95 SurfaceFactory_EGLImage(GLContext* prodGL,
96 EGLContext context,
97 const SurfaceCaps& caps)
98 : SurfaceFactory(prodGL, SharedSurfaceType::EGLImageShare, caps)
99 , mContext(context)
102 public:
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_ */