Chromium Code Reviews| Index: ui/gl/gl_surface_egl.cc |
| diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc |
| index 7401fbb320745808b18ebf6da531782b2422e1b3..3a12d6fba06d0006707f8195175e9dfe2f2e70f8 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 = false; |
|
piman
2013/10/31 20:07:54
nit: g_egl_surfaceless_context_supported for consi
kalyank
2013/10/31 22:15:27
fixed.
|
| class EGLSyncControlVSyncProvider |
| : public gfx::SyncControlVSyncProvider { |
| @@ -184,6 +185,26 @@ bool GLSurfaceEGL::InitializeOneOff() { |
| g_egl_sync_control_supported = |
| HasEGLExtension("EGL_CHROMIUM_sync_control"); |
| + // Check if SurfacelessEGL is supported. |
| + g_egl_surfaceless_context = HasEGLExtension("EGL_KHR_surfaceless_context"); |
| + if (g_egl_surfaceless_context) { |
| + // 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 = false; |
| + |
| + // Ensure context supports GL_OES_surfaceless_context. |
| + if (g_egl_surfaceless_context) { |
| + g_egl_surfaceless_context = context->HasExtension( |
| + "GL_OES_surfaceless_context"); |
| + context->ReleaseCurrent(surface.get()); |
| + } |
| + } |
| + |
| initialized = true; |
| return true; |
| @@ -593,6 +614,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() { |
| + NOTREACHED() << "Attempted to call SwapBuffers with SurfacelessEGL."; |
|
piman
2013/10/31 20:07:54
note: technically it can be reached if the (untrus
kalyank
2013/10/31 22:15:27
fixed.
|
| + 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 +746,12 @@ 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) |
| + surface = new SurfacelessEGL(size); |
|
piman
2013/10/31 20:07:54
So, what if the client really meant to have an off
kalyank
2013/10/31 22:15:27
I for now added the checks with 1,1 size. If no on
|
| + else |
| + surface = new PbufferGLSurfaceEGL(size); |
| + |
| if (!surface->Initialize()) |
| return NULL; |
| return surface; |