summaryrefslogtreecommitdiffstats
path: root/src/core/gl_surface_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-10-11 12:36:38 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-11-09 17:07:28 +0000
commitc1799923be3fb6d68391d5d4729c2d542424a734 (patch)
treec200ba298e987aff0cf9d7dabdda20a4a8122600 /src/core/gl_surface_qt.cpp
parentdd80dd0e4efcdfcc33f71a4f964aa9d2d40c4af0 (diff)
Make Linux QPA combinations more robust
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 <michael.bruning@qt.io>
Diffstat (limited to 'src/core/gl_surface_qt.cpp')
-rw-r--r--src/core/gl_surface_qt.cpp55
1 files changed, 32 insertions, 23 deletions
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>
GLSurface::CreateOffscreenGLSurface(const gfx::Size& size)
{
+ scoped_refptr<GLSurface> surface;
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: {
-#if defined(USE_X11)
- scoped_refptr<GLSurface> surface = new GLSurfaceQtGLX(size);
- if (!surface->Initialize())
- return NULL;
- return surface;
-#elif defined(OS_WIN)
- scoped_refptr<GLSurface> 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<GLSurface> 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