Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2614)

Unified Diff: ui/gl/gl_surface_egl.cc

Issue 49533003: Add support for Khr_surfaceless_context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review Fix: Use SurfacelessEGL only if requested size is 0,0. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7c31dd22d443503241056671bb0ab216d3b3cad0 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;
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698