diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 00:11:59 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 00:11:59 +0000 |
commit | 24edbd0b34b7177a781da8f5d0bbf4121d692b31 (patch) | |
tree | bf2e9f5b9e21ad74b358e48821d0dc1d63bb700c /ui/gfx/gl/gl_context_egl.h | |
parent | 866940781aa790de0a1e35f5d76163198e85e11c (diff) | |
download | chromium_src-24edbd0b34b7177a781da8f5d0bbf4121d692b31.zip chromium_src-24edbd0b34b7177a781da8f5d0bbf4121d692b31.tar.gz chromium_src-24edbd0b34b7177a781da8f5d0bbf4121d692b31.tar.bz2 |
Split EGLContext in GLContextEGL and GLSurfaceEGL.
Surfaces are independent of contexts in GL. To facilitate sharing of surfaces between processes, I have separated them from the notion of contexts because contexts cannot be shared between processes.
I have started with EGL. GLContextEGL still has a pointer to a surface and still has some surface specific operations that just forward through to it. Once I have refactored all the GLContext implementations in this way, I will remove these pointers and the surface specific opertations.
There will not be "view" and "offscreen" GL contexts. Rather there will be a single context type for each backend which can be made current with a surface that directs output either to a view or offscreen surface.
TEST=try, WebGL puppy works
BUG=none
Review URL: http://codereview.chromium.org/6839008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81512 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl/gl_context_egl.h')
-rw-r--r-- | ui/gfx/gl/gl_context_egl.h | 92 |
1 files changed, 13 insertions, 79 deletions
diff --git a/ui/gfx/gl/gl_context_egl.h b/ui/gfx/gl/gl_context_egl.h index 4250457..43cbe922 100644 --- a/ui/gfx/gl/gl_context_egl.h +++ b/ui/gfx/gl/gl_context_egl.h @@ -6,92 +6,28 @@ #define UI_GFX_GL_GL_CONTEXT_EGL_H_ #pragma once -#include "base/memory/ref_counted.h" +#include <string> + +#include "base/memory/scoped_ptr.h" #include "ui/gfx/gl/gl_context.h" #include "ui/gfx/size.h" -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> { - public: - explicit SharedEGLSurface(EGLSurface surface); - ~SharedEGLSurface(); - - 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(); - - // Get the associated EGL surface. - virtual SharedEGLSurface* GetSurface() = 0; - - // Implement GLContext. - virtual std::string GetExtensions(); - - private: - DISALLOW_COPY_AND_ASSIGN(BaseEGLContext); -}; +class GLSurfaceEGL; // Encapsulates an EGL OpenGL ES context that renders to a view. -class NativeViewEGLContext : public BaseEGLContext { +class GLContextEGL : public GLContext { public: - explicit NativeViewEGLContext(void* window); - virtual ~NativeViewEGLContext(); + // Takes ownership of surface. TODO(apatrick): separate notion of surface + // from context. + explicit GLContextEGL(GLSurfaceEGL* surface); - // Initialize an EGL context. - bool Initialize(); + virtual ~GLContextEGL(); - // Implement GLContext. - 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); - - // Implement BaseEGLContext. - virtual SharedEGLSurface* GetSurface(); - - private: - void* window_; - scoped_refptr<SharedEGLSurface> surface_; - EGLContext context_; - - DISALLOW_COPY_AND_ASSIGN(NativeViewEGLContext); -}; - -// 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 { - public: - SecondaryEGLContext(); - virtual ~SecondaryEGLContext(); - - // Initialize an EGL context that shares a namespace with another. + // Initialize an EGL context. bool Initialize(GLContext* shared_context); // Implement GLContext. @@ -103,15 +39,13 @@ class SecondaryEGLContext : public BaseEGLContext { virtual gfx::Size GetSize(); virtual void* GetHandle(); virtual void SetSwapInterval(int interval); - - // Implement BaseEGLContext. - virtual SharedEGLSurface* GetSurface(); + virtual std::string GetExtensions(); private: - scoped_refptr<SharedEGLSurface> surface_; + scoped_ptr<GLSurfaceEGL> surface_; EGLContext context_; - DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext); + DISALLOW_COPY_AND_ASSIGN(GLContextEGL); }; } // namespace gfx |