egl: inline _eglMatchAndInitialize() and refactor _eglMatchDriver()
authorEric Engestrom <eric@engestrom.ch>
Tue, 21 Jul 2020 23:13:13 +0000 (01:13 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Jul 2020 23:24:30 +0000 (23:24 +0000)
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Marcin Ĺšlusarz <marcin.slusarz@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6037>

src/egl/main/egldriver.c

index e6d5098472755000df9ca513e808815982c56a40..f58b00e1a3c15649d2d814c22df374d9b4227a9a 100644 (file)
 
 extern _EGLDriver _eglDriver;
 
-static _EGLDriver *
-_eglMatchAndInitialize(_EGLDisplay *disp)
-{
-   if (_eglDriver.Initialize(&_eglDriver, disp))
-      return &_eglDriver;
-
-   return NULL;
-}
-
 /**
  * Match a display to a driver.  The matching is done by finding the first
  * driver that can initialize the display.
@@ -64,8 +55,6 @@ _eglMatchAndInitialize(_EGLDisplay *disp)
 bool
 _eglMatchDriver(_EGLDisplay *disp)
 {
-   _EGLDriver *best_drv;
-
    assert(!disp->Initialized);
 
    /* set options */
@@ -74,18 +63,22 @@ _eglMatchDriver(_EGLDisplay *disp)
    if (disp->Options.ForceSoftware)
       _eglLog(_EGL_DEBUG, "Found 'LIBGL_ALWAYS_SOFTWARE' set, will use a CPU renderer");
 
-   best_drv = _eglMatchAndInitialize(disp);
-   if (!best_drv && !disp->Options.ForceSoftware) {
-      disp->Options.ForceSoftware = EGL_TRUE;
-      best_drv = _eglMatchAndInitialize(disp);
-   }
-
-   if (best_drv) {
-      disp->Driver = best_drv;
+   if (_eglDriver.Initialize(&_eglDriver, disp)) {
+      disp->Driver = &_eglDriver;
       disp->Initialized = EGL_TRUE;
+      return true;
    }
 
-   return best_drv != NULL;
+   if (disp->Options.ForceSoftware)
+      return false;
+
+   disp->Options.ForceSoftware = EGL_TRUE;
+   if (!_eglDriver.Initialize(&_eglDriver, disp))
+      return false;
+
+   disp->Driver = &_eglDriver;
+   disp->Initialized = EGL_TRUE;
+   return true;
 }
 
 __eglMustCastToProperFunctionPointerType