egl/x11: cleanup init code
authorEric Engestrom <eric@engestrom.ch>
Thu, 8 Dec 2016 00:30:34 +0000 (00:30 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 15 Dec 2016 11:48:31 +0000 (11:48 +0000)
No functional change, just rewriting it in an easier-to-understand way.

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/egl/drivers/dri2/platform_x11.c

index df39ca8f192bc623c3904b242e19a6f2ef6e91c2..db7d3b9ed1d01f47987c3ae12553de3b5f553aa8 100644 (file)
@@ -1467,25 +1467,21 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
 EGLBoolean
 dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp)
 {
-   EGLBoolean initialized = EGL_TRUE;
+   EGLBoolean initialized = EGL_FALSE;
 
-   int x11_dri2_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
-
-   if (x11_dri2_accel) {
+   if (!getenv("LIBGL_ALWAYS_SOFTWARE")) {
 #ifdef HAVE_DRI3
-      if (getenv("LIBGL_DRI3_DISABLE") != NULL ||
-          !dri2_initialize_x11_dri3(drv, disp)) {
+      if (!getenv("LIBGL_DRI3_DISABLE"))
+         initialized = dri2_initialize_x11_dri3(drv, disp);
 #endif
-         if (!dri2_initialize_x11_dri2(drv, disp)) {
-            initialized = dri2_initialize_x11_swrast(drv, disp);
-         }
-#ifdef HAVE_DRI3
-      }
-#endif
-   } else {
-      initialized = dri2_initialize_x11_swrast(drv, disp);
+
+      if (!initialized)
+         initialized = dri2_initialize_x11_dri2(drv, disp);
    }
 
+   if (!initialized)
+      initialized = dri2_initialize_x11_swrast(drv, disp);
+
    return initialized;
 }