Chromium Code Reviews| Index: ui/gfx/gl/gl_surface_egl.h |
| =================================================================== |
| --- ui/gfx/gl/gl_surface_egl.h (revision 80956) |
| +++ ui/gfx/gl/gl_surface_egl.h (working copy) |
| @@ -2,118 +2,80 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef UI_GFX_GL_GL_CONTEXT_EGL_H_ |
| -#define UI_GFX_GL_GL_CONTEXT_EGL_H_ |
| +#ifndef UI_GFX_GL_GL_SURFACE_EGL_H_ |
| +#define UI_GFX_GL_GL_SURFACE_EGL_H_ |
| #pragma once |
| #include "base/memory/ref_counted.h" |
|
Alexey Marinichev
2011/04/13 23:45:07
Should surfaces be refcounted? If they shouldn't,
apatrick_chromium
2011/04/13 23:51:58
No that was a hack for windows that is not needed
|
| -#include "ui/gfx/gl/gl_context.h" |
| +#include "ui/gfx/gl/gl_surface.h" |
| #include "ui/gfx/size.h" |
| +typedef void* EGLConfig; |
| typedef void* EGLDisplay; |
| -typedef void* EGLContext; |
| typedef void* EGLSurface; |
| namespace gfx { |
| -// Takes ownership of an EGL surface and reference counts it so it can be shared |
| -// by multiple EGL contexts and destroyed with the last. |
| -class SharedEGLSurface : public base::RefCounted<SharedEGLSurface> { |
| +// Interface for EGL contexts. |
| +class GLSurfaceEGL : public GLSurface { |
| public: |
| - explicit SharedEGLSurface(EGLSurface surface); |
| - ~SharedEGLSurface(); |
| + GLSurfaceEGL(); |
| + virtual ~GLSurfaceEGL(); |
| - EGLSurface egl_surface() const; |
| - |
| - private: |
| - EGLSurface surface_; |
| - DISALLOW_COPY_AND_ASSIGN(SharedEGLSurface); |
| -}; |
| - |
| -// Interface for EGL contexts. Adds an EGL specific accessor for retreiving |
| -// the surface. |
| -class BaseEGLContext : public GLContext { |
| - public: |
| - BaseEGLContext() {} |
| - virtual ~BaseEGLContext() {} |
| - |
| static bool InitializeOneOff(); |
| - |
| static EGLDisplay GetDisplay(); |
| + static EGLConfig GetConfig(); |
| - // Get the associated EGL surface. |
| - virtual SharedEGLSurface* GetSurface() = 0; |
| - |
| - // Implement GLContext. |
| - virtual std::string GetExtensions(); |
| - |
| private: |
| - DISALLOW_COPY_AND_ASSIGN(BaseEGLContext); |
| + DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); |
| }; |
| -// Encapsulates an EGL OpenGL ES context that renders to a view. |
| -class NativeViewEGLContext : public BaseEGLContext { |
| +// Encapsulates an EGL surface bound to a view. |
| +class NativeViewGLSurfaceEGL : public GLSurfaceEGL { |
| public: |
| - explicit NativeViewEGLContext(void* window); |
| - virtual ~NativeViewEGLContext(); |
| + explicit NativeViewGLSurfaceEGL(void* window); |
| + virtual ~NativeViewGLSurfaceEGL(); |
| // Initialize an EGL context. |
| bool Initialize(); |
| - // Implement GLContext. |
| + // Implement GLSurface. |
| virtual void Destroy(); |
| - virtual bool MakeCurrent(); |
| - virtual bool IsCurrent(); |
| virtual bool IsOffscreen(); |
| virtual bool SwapBuffers(); |
| virtual gfx::Size GetSize(); |
| - virtual void* GetHandle(); |
| - virtual void SetSwapInterval(int interval); |
| + virtual EGLSurface GetHandle(); |
| - // Implement BaseEGLContext. |
| - virtual SharedEGLSurface* GetSurface(); |
| - |
| private: |
| void* window_; |
| - scoped_refptr<SharedEGLSurface> surface_; |
| - EGLContext context_; |
| + EGLSurface surface_; |
| - DISALLOW_COPY_AND_ASSIGN(NativeViewEGLContext); |
| + DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL); |
| }; |
| -// Encapsulates an EGL OpenGL ES context intended for offscreen use. It is |
| -// actually associated with a native window or a pbuffer on supporting platforms |
| -// and will render to it. The caller must bind an FBO to prevent this. |
| -// TODO(apatrick): implement pbuffers in ANGLE and change this to |
| -// PbufferEGLContext and use it on all EGL platforms. |
| -class SecondaryEGLContext : public BaseEGLContext { |
| +// Encapsulates a pbuffer EGL surface. |
| +class PbufferGLSurfaceEGL : public GLSurfaceEGL { |
| public: |
| - SecondaryEGLContext(); |
| - virtual ~SecondaryEGLContext(); |
| + explicit PbufferGLSurfaceEGL(const gfx::Size& size); |
| + virtual ~PbufferGLSurfaceEGL(); |
| // Initialize an EGL context that shares a namespace with another. |
| - bool Initialize(GLContext* shared_context); |
| + bool Initialize(); |
| - // Implement GLContext. |
| + // Implement GLSurface. |
| virtual void Destroy(); |
| - virtual bool MakeCurrent(); |
| - virtual bool IsCurrent(); |
| virtual bool IsOffscreen(); |
| virtual bool SwapBuffers(); |
| virtual gfx::Size GetSize(); |
| - virtual void* GetHandle(); |
| - virtual void SetSwapInterval(int interval); |
| + virtual EGLSurface GetHandle(); |
| - // Implement BaseEGLContext. |
| - virtual SharedEGLSurface* GetSurface(); |
| - |
| private: |
| - scoped_refptr<SharedEGLSurface> surface_; |
| - EGLContext context_; |
| + gfx::Size size_; |
| + EGLSurface surface_; |
| - DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext); |
| + DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL); |
| }; |
| } // namespace gfx |
| -#endif // UI_GFX_GL_GL_CONTEXT_EGL_H_ |
| +#endif // UI_GFX_GL_GL_SURFACE_EGL_H_ |