From 0299ccd3b9cf50817cce430ec3419c9f204b47e2 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sun, 4 Dec 2016 19:13:33 +0900 Subject: Use surfaceless context if necessary The support for surfaceless context was disabled in commit 9cc97f0c63049a8076476acc89c875c9e240abfb, which says: > Using surfaceless EGL surface on imx6 embedded device crashes webengine > with backtrace in gpu driver. It was added in commit bfcbdc3ab42880dc37ffa7174af96928ccf25f03, which says: > This patch is a port of commit 4b0cac9dfeebb73f21a11e10e6a2bc7bddbe889b > in Chromium for Qt WebEngine. > The based commit says: > (snip) > > 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. > > Some platforms supported by QPA, such as Mesa 3D DRI2 with drm and > wayland backend also don't support pbuffer surfaces. Considering those cases, this change enables surfaceless context only if pseudo surfaceless context made of surface context is not available. Change-Id: I015421ebbbc357d48313e09d4f7a0369bb956521 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Michal Klocek --- src/core/gl_surface_qt.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index 4385b38cb..e8f77e9ed 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -367,8 +367,7 @@ bool GLSurfaceQtEGL::InitializeOneOff() LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); return false; } -#if 0 -// QTBUG-57290 + g_egl_surfaceless_context_supported = ExtensionsContain(g_extensions, "EGL_KHR_surfaceless_context"); if (g_egl_surfaceless_context_supported) { scoped_refptr surface = new GLSurfacelessQtEGL(gfx::Size(1, 1)); @@ -385,7 +384,7 @@ bool GLSurfaceQtEGL::InitializeOneOff() context->ReleaseCurrent(surface.get()); } } -#endif + initialized = true; return true; } @@ -615,13 +614,19 @@ CreateOffscreenGLSurface(const gfx::Size& size) #endif } case kGLImplementationEGLGLES2: { - if (g_egl_surfaceless_context_supported) - surface = new GLSurfacelessQtEGL(size); - else - surface = new GLSurfaceQtEGL(size); - + surface = new GLSurfaceQtEGL(size); if (surface->Initialize()) return surface; + + // Surfaceless context will be used ONLY if pseudo surfaceless context + // is not available since some implementations of surfaceless context + // have problems. (e.g. QTBUG-57290) + if (g_egl_surfaceless_context_supported) { + surface = new GLSurfacelessQtEGL(size); + if (surface->Initialize()) + return surface; + } + break; } default: -- cgit v1.2.3