From c1799923be3fb6d68391d5d4729c2d542424a734 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 11 Oct 2016 12:36:38 +0200 Subject: Make Linux QPA combinations more robust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use resourceForIntegration to get egldisplay since not all QPA return a egldisplay for context (in particular xcb_egl). Implement EGL fallback for linux desktop builds, to make Wayland work without an X11 server present. Change-Id: Idcead42250fa00a36e50c082711f5618fd213556 Reviewed-by: Michael BrĂ¼ning --- src/core/gl_context_qt.cpp | 2 +- src/core/gl_surface_qt.cpp | 55 +++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp index 0cf873631..b7d82e77a 100644 --- a/src/core/gl_context_qt.cpp +++ b/src/core/gl_context_qt.cpp @@ -118,7 +118,7 @@ void* GLContextHelper::getXConfig() void* GLContextHelper::getEGLDisplay() { - return resourceForContext(QByteArrayLiteral("egldisplay")); + return resourceForIntegration(QByteArrayLiteral("egldisplay")); } void* GLContextHelper::getXDisplay() diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp index f499d853e..a82143525 100644 --- a/src/core/gl_surface_qt.cpp +++ b/src/core/gl_surface_qt.cpp @@ -88,6 +88,9 @@ void* g_display; const char* g_extensions = NULL; bool g_egl_surfaceless_context_supported = false; + +bool g_initializedEGL = false; + } // namespace @@ -393,11 +396,17 @@ bool GLSurface::InitializeOneOffInternal() return GLSurfaceQtEGL::InitializeOneOff(); if (GetGLImplementation() == kGLImplementationDesktopGL) { -#if defined(USE_X11) - return GLSurfaceQtGLX::InitializeOneOff(); -#elif defined(OS_WIN) +#if defined(OS_WIN) return GLSurfaceQtWGL::InitializeOneOff(); +#elif defined(USE_X11) + if (GLSurfaceQtGLX::InitializeOneOff()) + return true; #endif + // Fallback to trying EGL with desktop GL. + if (GLSurfaceQtEGL::InitializeOneOff()) { + g_initializedEGL = true; + return true; + } } return false; @@ -579,39 +588,39 @@ void* GLSurfacelessQtEGL::GetShareHandle() scoped_refptr GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { + scoped_refptr surface; switch (GetGLImplementation()) { case kGLImplementationDesktopGL: { -#if defined(USE_X11) - scoped_refptr surface = new GLSurfaceQtGLX(size); - if (!surface->Initialize()) - return NULL; - return surface; -#elif defined(OS_WIN) - scoped_refptr surface = new GLSurfaceQtWGL(size); - if (!surface->Initialize()) - return NULL; - return surface; -#else - LOG(ERROR) << "Desktop GL is not supported on this platform."; - Q_UNREACHABLE(); - return NULL; +#if defined(OS_WIN) + surface = new GLSurfaceQtWGL(size); + if (surface->Initialize()) + return surface; + break; +#elif defined(USE_X11) + if (!g_initializedEGL) { + surface = new GLSurfaceQtGLX(size); + if (surface->Initialize()) + return surface; + } + // no break #endif } case kGLImplementationEGLGLES2: { - scoped_refptr surface; if (g_egl_surfaceless_context_supported) surface = new GLSurfacelessQtEGL(size); else surface = new GLSurfaceQtEGL(size); - if (!surface->Initialize()) - return NULL; - return surface; + if (surface->Initialize()) + return surface; + break; } default: - Q_UNREACHABLE(); - return NULL; + break; } + LOG(ERROR) << "Requested OpenGL platform is not supported."; + Q_UNREACHABLE(); + return NULL; } // static -- cgit v1.2.3