@@ -88,6 +88,9 @@ void* g_display;
88
88
const char * g_extensions = NULL ;
89
89
90
90
bool g_egl_surfaceless_context_supported = false ;
91
+
92
+ bool g_initializedEGL = false ;
93
+
91
94
} // namespace
92
95
93
96
@@ -393,11 +396,17 @@ bool GLSurface::InitializeOneOffInternal()
393
396
return GLSurfaceQtEGL::InitializeOneOff ();
394
397
395
398
if (GetGLImplementation () == kGLImplementationDesktopGL ) {
396
- #if defined(USE_X11)
397
- return GLSurfaceQtGLX::InitializeOneOff ();
398
- #elif defined(OS_WIN)
399
+ #if defined(OS_WIN)
399
400
return GLSurfaceQtWGL::InitializeOneOff ();
401
+ #elif defined(USE_X11)
402
+ if (GLSurfaceQtGLX::InitializeOneOff ())
403
+ return true ;
400
404
#endif
405
+ // Fallback to trying EGL with desktop GL.
406
+ if (GLSurfaceQtEGL::InitializeOneOff ()) {
407
+ g_initializedEGL = true ;
408
+ return true ;
409
+ }
401
410
}
402
411
403
412
return false ;
@@ -579,39 +588,39 @@ void* GLSurfacelessQtEGL::GetShareHandle()
579
588
scoped_refptr<GLSurface>
580
589
GLSurface::CreateOffscreenGLSurface (const gfx::Size& size)
581
590
{
591
+ scoped_refptr<GLSurface> surface;
582
592
switch (GetGLImplementation ()) {
583
593
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
598
606
#endif
599
607
}
600
608
case kGLImplementationEGLGLES2 : {
601
- scoped_refptr<GLSurface> surface;
602
609
if (g_egl_surfaceless_context_supported)
603
610
surface = new GLSurfacelessQtEGL (size);
604
611
else
605
612
surface = new GLSurfaceQtEGL (size);
606
613
607
- if (! surface->Initialize ())
608
- return NULL ;
609
- return surface ;
614
+ if (surface->Initialize ())
615
+ return surface ;
616
+ break ;
610
617
}
611
618
default :
612
- Q_UNREACHABLE ();
613
- return NULL ;
619
+ break ;
614
620
}
621
+ LOG (ERROR) << " Requested OpenGL platform is not supported." ;
622
+ Q_UNREACHABLE ();
623
+ return NULL ;
615
624
}
616
625
617
626
// static
0 commit comments