summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/gl/gl_context.cc9
-rw-r--r--ui/gfx/gl/gl_context.h10
-rw-r--r--ui/gfx/gl/gl_context_egl.cc18
-rw-r--r--ui/gfx/gl/gl_context_egl.h4
-rw-r--r--ui/gfx/gl/gl_surface.h6
5 files changed, 45 insertions, 2 deletions
diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc
index 847c9bb..630925d 100644
--- a/ui/gfx/gl/gl_context.cc
+++ b/ui/gfx/gl/gl_context.cc
@@ -13,6 +13,15 @@
namespace gfx {
+void GLContext::ReleaseCurrent() {
+ // TODO(apatrick): Implement this in GLContext derivatives.
+}
+
+GLSurface* GLContext::GetSurface() {
+ // TODO(apatrick): Remove this when surfaces are split from contexts.
+ return NULL;
+}
+
unsigned int GLContext::GetBackingFrameBufferObject() {
return 0;
}
diff --git a/ui/gfx/gl/gl_context.h b/ui/gfx/gl/gl_context.h
index f39a77a..b27f8c9 100644
--- a/ui/gfx/gl/gl_context.h
+++ b/ui/gfx/gl/gl_context.h
@@ -14,6 +14,8 @@
namespace gfx {
+class GLSurface;
+
// Encapsulates an OpenGL context, hiding platform specific management.
class GLContext {
public:
@@ -26,6 +28,10 @@ class GLContext {
// Makes the GL context current on the current thread.
virtual bool MakeCurrent() = 0;
+ // Releases this GL context as current on the current thread. TODO(apatrick):
+ // implement this in the other GLContexts.
+ virtual void ReleaseCurrent();
+
// Returns true if this context is current.
virtual bool IsCurrent() = 0;
@@ -39,6 +45,10 @@ class GLContext {
// Get the size of the back buffer.
virtual gfx::Size GetSize() = 0;
+ // Get the surface. TODO(apatrick): remove this when contexts are split from
+ // surfaces.
+ virtual GLSurface* GetSurface();
+
// Get the underlying platform specific GL context "handle".
virtual void* GetHandle() = 0;
diff --git a/ui/gfx/gl/gl_context_egl.cc b/ui/gfx/gl/gl_context_egl.cc
index 8f64041..0093e7f 100644
--- a/ui/gfx/gl/gl_context_egl.cc
+++ b/ui/gfx/gl/gl_context_egl.cc
@@ -111,9 +111,20 @@ bool GLContextEGL::MakeCurrent() {
return true;
}
+void GLContextEGL::ReleaseCurrent() {
+ if (!IsCurrent())
+ return;
+
+ eglMakeCurrent(GLSurfaceEGL::GetDisplay(),
+ EGL_NO_SURFACE,
+ EGL_NO_SURFACE,
+ EGL_NO_CONTEXT);
+}
+
bool GLContextEGL::IsCurrent() {
DCHECK(context_);
- return context_ == eglGetCurrentContext();
+ return context_ == eglGetCurrentContext() &&
+ surface_->GetHandle() == eglGetCurrentSurface(EGL_DRAW);
}
bool GLContextEGL::IsOffscreen() {
@@ -131,6 +142,11 @@ gfx::Size GLContextEGL::GetSize() {
return surface_->GetSize();
}
+GLSurface* GLContextEGL::GetSurface() {
+ // TODO(apatrick): remove this from GLContext interface.
+ return surface_.get();
+}
+
void* GLContextEGL::GetHandle() {
return context_;
}
diff --git a/ui/gfx/gl/gl_context_egl.h b/ui/gfx/gl/gl_context_egl.h
index 43cbe922..7337d22 100644
--- a/ui/gfx/gl/gl_context_egl.h
+++ b/ui/gfx/gl/gl_context_egl.h
@@ -18,7 +18,7 @@ namespace gfx {
class GLSurfaceEGL;
-// Encapsulates an EGL OpenGL ES context that renders to a view.
+// Encapsulates an EGL OpenGL ES context.
class GLContextEGL : public GLContext {
public:
// Takes ownership of surface. TODO(apatrick): separate notion of surface
@@ -33,10 +33,12 @@ class GLContextEGL : public GLContext {
// Implement GLContext.
virtual void Destroy();
virtual bool MakeCurrent();
+ virtual void ReleaseCurrent();
virtual bool IsCurrent();
virtual bool IsOffscreen();
virtual bool SwapBuffers();
virtual gfx::Size GetSize();
+ virtual GLSurface* GetSurface();
virtual void* GetHandle();
virtual void SetSwapInterval(int interval);
virtual std::string GetExtensions();
diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h
index 811b232..dde0883 100644
--- a/ui/gfx/gl/gl_surface.h
+++ b/ui/gfx/gl/gl_surface.h
@@ -19,6 +19,12 @@ class GLSurface {
GLSurface() {}
virtual ~GLSurface() {}
+ // (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the
+ // EGL surface associated to be recreated without destroying the associated
+ // context. The implementation of this function for other GLSurface derived
+ // classes is in a pending changelist.
+ virtual bool Initialize() { return true; }
+
// Destroys the surface.
virtual void Destroy() = 0;