egl: fold X11 attrib handling like other platforms
authorEmil Velikov <emil.velikov@collabora.com>
Thu, 16 May 2019 17:01:37 +0000 (18:01 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 5 Jun 2019 17:35:21 +0000 (13:35 -0400)
Since we no longer need special handling for X11, refactor the code to
follow the style used by all other platforms.

Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/egl/main/egldisplay.c

index 418ab0ec9b871a12a80ee212cf9e44752141aeb9..422b473844e561bad09d5a32c06bfe841cadfbd0 100644 (file)
@@ -487,45 +487,22 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type)
 }
 
 #ifdef HAVE_X11_PLATFORM
-static EGLBoolean
-_eglParseX11DisplayAttribList(_EGLDisplay *display,
-                              const EGLAttrib *attrib_list)
-{
-   int i;
-
-   if (attrib_list == NULL) {
-      return EGL_TRUE;
-   }
-
-   /* EGL_EXT_platform_x11 recognizes exactly one attribute,
-    * EGL_PLATFORM_X11_SCREEN_EXT, which is optional.
-    */
-   for (i = 0; attrib_list[i] != EGL_NONE; i += 2) {
-      if (attrib_list[i] != EGL_PLATFORM_X11_SCREEN_EXT)
-         return _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
-   }
-
-   return EGL_TRUE;
-}
-
 _EGLDisplay*
 _eglGetX11Display(Display *native_display,
                   const EGLAttrib *attrib_list)
 {
-   _EGLDisplay *display = _eglFindDisplay(_EGL_PLATFORM_X11,
-                                          native_display,
-                                          attrib_list);
-
-   if (!display) {
-      _eglError(EGL_BAD_ALLOC, "eglGetPlatformDisplay");
-      return NULL;
-   }
-
-   if (!_eglParseX11DisplayAttribList(display, attrib_list)) {
-      return NULL;
+   /* EGL_EXT_platform_x11 recognizes exactly one attribute,
+    * EGL_PLATFORM_X11_SCREEN_EXT, which is optional.
+    */
+   if (attrib_list != NULL) {
+      for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
+         if (attrib_list[i] != EGL_PLATFORM_X11_SCREEN_EXT) {
+            _eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
+            return NULL;
+         }
+      }
    }
-
-   return display;
+   return _eglFindDisplay(_EGL_PLATFORM_X11, native_display, attrib_list);
 }
 #endif /* HAVE_X11_PLATFORM */