Skip to content

Commit c179992

Browse files
carewolfAllan Sandfeld Jensen
authored andcommitted
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 <[email protected]>
1 parent dd80dd0 commit c179992

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

src/core/gl_context_qt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void* GLContextHelper::getXConfig()
118118

119119
void* GLContextHelper::getEGLDisplay()
120120
{
121-
return resourceForContext(QByteArrayLiteral("egldisplay"));
121+
return resourceForIntegration(QByteArrayLiteral("egldisplay"));
122122
}
123123

124124
void* GLContextHelper::getXDisplay()

src/core/gl_surface_qt.cpp

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ void* g_display;
8888
const char* g_extensions = NULL;
8989

9090
bool g_egl_surfaceless_context_supported = false;
91+
92+
bool g_initializedEGL = false;
93+
9194
} // namespace
9295

9396

@@ -393,11 +396,17 @@ bool GLSurface::InitializeOneOffInternal()
393396
return GLSurfaceQtEGL::InitializeOneOff();
394397

395398
if (GetGLImplementation() == kGLImplementationDesktopGL) {
396-
#if defined(USE_X11)
397-
return GLSurfaceQtGLX::InitializeOneOff();
398-
#elif defined(OS_WIN)
399+
#if defined(OS_WIN)
399400
return GLSurfaceQtWGL::InitializeOneOff();
401+
#elif defined(USE_X11)
402+
if (GLSurfaceQtGLX::InitializeOneOff())
403+
return true;
400404
#endif
405+
// Fallback to trying EGL with desktop GL.
406+
if (GLSurfaceQtEGL::InitializeOneOff()) {
407+
g_initializedEGL = true;
408+
return true;
409+
}
401410
}
402411

403412
return false;
@@ -579,39 +588,39 @@ void* GLSurfacelessQtEGL::GetShareHandle()
579588
scoped_refptr<GLSurface>
580589
GLSurface::CreateOffscreenGLSurface(const gfx::Size& size)
581590
{
591+
scoped_refptr<GLSurface> surface;
582592
switch (GetGLImplementation()) {
583593
case kGLImplementationDesktopGL: {
584-
#if defined(USE_X11)
585-
scoped_refptr<GLSurface> surface = new GLSurfaceQtGLX(size);
586-
if (!surface->Initialize())
587-
return NULL;
588-
return surface;
589-
#elif defined(OS_WIN)
590-
scoped_refptr<GLSurface> surface = new GLSurfaceQtWGL(size);
591-
if (!surface->Initialize())
592-
return NULL;
593-
return surface;
594-
#else
595-
LOG(ERROR) << "Desktop GL is not supported on this platform.";
596-
Q_UNREACHABLE();
597-
return NULL;
594+
#if defined(OS_WIN)
595+
surface = new GLSurfaceQtWGL(size);
596+
if (surface->Initialize())
597+
return surface;
598+
break;
599+
#elif defined(USE_X11)
600+
if (!g_initializedEGL) {
601+
surface = new GLSurfaceQtGLX(size);
602+
if (surface->Initialize())
603+
return surface;
604+
}
605+
// no break
598606
#endif
599607
}
600608
case kGLImplementationEGLGLES2: {
601-
scoped_refptr<GLSurface> surface;
602609
if (g_egl_surfaceless_context_supported)
603610
surface = new GLSurfacelessQtEGL(size);
604611
else
605612
surface = new GLSurfaceQtEGL(size);
606613

607-
if (!surface->Initialize())
608-
return NULL;
609-
return surface;
614+
if (surface->Initialize())
615+
return surface;
616+
break;
610617
}
611618
default:
612-
Q_UNREACHABLE();
613-
return NULL;
619+
break;
614620
}
621+
LOG(ERROR) << "Requested OpenGL platform is not supported.";
622+
Q_UNREACHABLE();
623+
return NULL;
615624
}
616625

617626
// static

0 commit comments

Comments
 (0)