summaryrefslogtreecommitdiffstats
path: root/ui/gl
diff options
context:
space:
mode:
authorkalyan.kondapally@intel.com <kalyan.kondapally@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-02 14:00:38 +0000
committerkalyan.kondapally@intel.com <kalyan.kondapally@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-02 14:00:38 +0000
commit4b0cac9dfeebb73f21a11e10e6a2bc7bddbe889b (patch)
treed8f04703dc394c4a7ba54e653f1115bacc10c706 /ui/gl
parentfea4b1f4e0c33a9bcc45aa59adc2af78bac2f23d (diff)
downloadchromium_src-4b0cac9dfeebb73f21a11e10e6a2bc7bddbe889b.zip
chromium_src-4b0cac9dfeebb73f21a11e10e6a2bc7bddbe889b.tar.gz
chromium_src-4b0cac9dfeebb73f21a11e10e6a2bc7bddbe889b.tar.bz2
Add support for Khr_surfaceless_context.
http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_surfaceless_context.txt This patch adds support in GLSurfaceEGL to be able to use surfaceless context when supported by the drivers. This avoids the creation of a dummy offscreen surface. This would also enable support for offscreen rendering on platforms (i.e Ozone-Wayland) which donot support pbuffer surfaces. BUG= Review URL: https://codereview.chromium.org/49533003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl')
-rw-r--r--ui/gl/gl_surface_egl.cc75
-rw-r--r--ui/gl/gl_surface_egl.h26
2 files changed, 99 insertions, 2 deletions
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 7401fbb..7c31dd2 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -54,6 +54,7 @@ EGLNativeDisplayType g_native_display;
const char* g_egl_extensions = NULL;
bool g_egl_create_context_robustness_supported = false;
bool g_egl_sync_control_supported = false;
+bool g_egl_surfaceless_context_supported = false;
class EGLSyncControlVSyncProvider
: public gfx::SyncControlVSyncProvider {
@@ -184,6 +185,27 @@ bool GLSurfaceEGL::InitializeOneOff() {
g_egl_sync_control_supported =
HasEGLExtension("EGL_CHROMIUM_sync_control");
+ // Check if SurfacelessEGL is supported.
+ g_egl_surfaceless_context_supported =
+ HasEGLExtension("EGL_KHR_surfaceless_context");
+ if (g_egl_surfaceless_context_supported) {
+ // EGL_KHR_surfaceless_context is supported but ensure
+ // GL_OES_surfaceless_context is also supported. We need a current context
+ // to query for supported GL extensions.
+ scoped_refptr<GLSurface> surface = new SurfacelessEGL(Size(1, 1));
+ scoped_refptr<GLContext> context = GLContext::CreateGLContext(
+ NULL, surface.get(), PreferIntegratedGpu);
+ if (!context->MakeCurrent(surface.get()))
+ g_egl_surfaceless_context_supported = false;
+
+ // Ensure context supports GL_OES_surfaceless_context.
+ if (g_egl_surfaceless_context_supported) {
+ g_egl_surfaceless_context_supported = context->HasExtension(
+ "GL_OES_surfaceless_context");
+ context->ReleaseCurrent(surface.get());
+ }
+ }
+
initialized = true;
return true;
@@ -593,6 +615,50 @@ PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
Destroy();
}
+SurfacelessEGL::SurfacelessEGL(const gfx::Size& size)
+ : size_(size) {
+}
+
+bool SurfacelessEGL::Initialize() {
+ return true;
+}
+
+void SurfacelessEGL::Destroy() {
+}
+
+EGLConfig SurfacelessEGL::GetConfig() {
+ return g_config;
+}
+
+bool SurfacelessEGL::IsOffscreen() {
+ return true;
+}
+
+bool SurfacelessEGL::SwapBuffers() {
+ LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL.";
+ return false;
+}
+
+gfx::Size SurfacelessEGL::GetSize() {
+ return size_;
+}
+
+bool SurfacelessEGL::Resize(const gfx::Size& size) {
+ size_ = size;
+ return true;
+}
+
+EGLSurface SurfacelessEGL::GetHandle() {
+ return EGL_NO_SURFACE;
+}
+
+void* SurfacelessEGL::GetShareHandle() {
+ return NULL;
+}
+
+SurfacelessEGL::~SurfacelessEGL() {
+}
+
#if defined(ANDROID) || defined(USE_OZONE)
// A thin subclass of |GLSurfaceOSMesa| that can be used in place
@@ -681,8 +747,13 @@ GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
return surface;
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<PbufferGLSurfaceEGL> surface(
- new PbufferGLSurfaceEGL(size));
+ scoped_refptr<GLSurface> surface;
+ if (g_egl_surfaceless_context_supported &&
+ (size.width() == 0 && size.height() == 0)) {
+ surface = new SurfacelessEGL(size);
+ } else
+ surface = new PbufferGLSurfaceEGL(size);
+
if (!surface->Initialize())
return NULL;
return surface;
diff --git a/ui/gl/gl_surface_egl.h b/ui/gl/gl_surface_egl.h
index 68a99af..6cdaf5d 100644
--- a/ui/gl/gl_surface_egl.h
+++ b/ui/gl/gl_surface_egl.h
@@ -111,6 +111,32 @@ class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL {
DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL);
};
+// SurfacelessEGL is used as Offscreen surface when platform supports
+// KHR_surfaceless_context and GL_OES_surfaceless_context. This would avoid the
+// need to create a dummy EGLsurface in case we render to client API targets.
+class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL {
+ public:
+ explicit SurfacelessEGL(const gfx::Size& size);
+
+ // Implement GLSurface.
+ virtual EGLConfig GetConfig() OVERRIDE;
+ virtual bool Initialize() OVERRIDE;
+ virtual void Destroy() OVERRIDE;
+ virtual bool IsOffscreen() OVERRIDE;
+ virtual bool SwapBuffers() OVERRIDE;
+ virtual gfx::Size GetSize() OVERRIDE;
+ virtual bool Resize(const gfx::Size& size) OVERRIDE;
+ virtual EGLSurface GetHandle() OVERRIDE;
+ virtual void* GetShareHandle() OVERRIDE;
+
+ protected:
+ virtual ~SurfacelessEGL();
+
+ private:
+ gfx::Size size_;
+ DISALLOW_COPY_AND_ASSIGN(SurfacelessEGL);
+};
+
} // namespace gfx
#endif // UI_GL_GL_SURFACE_EGL_H_