summaryrefslogtreecommitdiffstats
path: root/app/gfx/gl/gl_context_egl.h
diff options
context:
space:
mode:
Diffstat (limited to 'app/gfx/gl/gl_context_egl.h')
-rw-r--r--app/gfx/gl/gl_context_egl.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/app/gfx/gl/gl_context_egl.h b/app/gfx/gl/gl_context_egl.h
new file mode 100644
index 0000000..4bfff9b
--- /dev/null
+++ b/app/gfx/gl/gl_context_egl.h
@@ -0,0 +1,93 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_GFX_GL_GL_CONTEXT_EGL_H_
+#define APP_GFX_GL_GL_CONTEXT_EGL_H_
+
+#include "gfx/size.h"
+#include "app/gfx/gl/gl_context.h"
+
+typedef void *EGLContext;
+typedef void* EGLSurface;
+
+namespace gfx {
+
+// Interface for EGL contexts. Adds an EGL specific accessor for retreiving
+// the surface.
+class BaseEGLContext : public GLContext {
+ public:
+ BaseEGLContext() {}
+ virtual ~BaseEGLContext() {}
+
+ // Implement GLContext.
+ virtual EGLSurface GetSurface() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BaseEGLContext);
+};
+
+// Encapsulates an EGL OpenGL ES context that renders to a view.
+class NativeViewEGLContext : public BaseEGLContext {
+ public:
+ explicit NativeViewEGLContext(void* window);
+ virtual ~NativeViewEGLContext();
+
+ // Initialize an EGL context.
+ bool Initialize();
+
+ // Implement GLContext.
+ virtual void Destroy();
+ virtual bool MakeCurrent();
+ virtual bool IsCurrent();
+ virtual bool IsOffscreen();
+ virtual void SwapBuffers();
+ virtual gfx::Size GetSize();
+ virtual void* GetHandle();
+
+ // Implement BaseEGLContext.
+ virtual EGLSurface GetSurface();
+
+ private:
+ void* window_;
+ EGLSurface 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 and will render to it. The caller
+// must bind an FBO to prevent this. Not using pbuffers because ANGLE does not
+// support them.
+class SecondaryEGLContext : public BaseEGLContext {
+ public:
+ SecondaryEGLContext();
+ virtual ~SecondaryEGLContext();
+
+ // Initialize an EGL context that shares a namespace with another.
+ bool Initialize(GLContext* shared_context);
+
+ // Implement GLContext.
+ virtual void Destroy();
+ virtual bool MakeCurrent();
+ virtual bool IsCurrent();
+ virtual bool IsOffscreen();
+ virtual void SwapBuffers();
+ virtual gfx::Size GetSize();
+ virtual void* GetHandle();
+
+ // Implement BaseEGLContext.
+ virtual EGLSurface GetSurface();
+
+ private:
+ // All offscreen
+ EGLSurface surface_;
+ EGLContext context_;
+
+ DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext);
+};
+
+} // namespace gfx
+
+#endif // APP_GFX_GL_GL_CONTEXT_EGL_H_