egl: Convert int to attrib in eglGetPlatformDisplay
authorAdam Jackson <ajax@redhat.com>
Thu, 16 Nov 2017 18:27:27 +0000 (13:27 -0500)
committerAdam Jackson <ajax@redhat.com>
Fri, 17 Nov 2017 21:43:16 +0000 (16:43 -0500)
... because converting attrib to int truncates, and that's bad.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/egl/main/eglapi.c
src/egl/main/egldisplay.c
src/egl/main/egldisplay.h

index c1bf5bbfe19b3172429e09070d7ed297d805303a..cec67425e13e018477bbc6874aed6155743bc25a 100644 (file)
@@ -376,7 +376,7 @@ eglGetDisplay(EGLNativeDisplayType nativeDisplay)
 
 static EGLDisplay
 _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display,
-                             const EGLint *attrib_list)
+                             const EGLAttrib *attrib_list)
 {
    _EGLDisplay *dpy;
 
@@ -412,28 +412,27 @@ _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display,
 
 static EGLDisplay EGLAPIENTRY
 eglGetPlatformDisplayEXT(EGLenum platform, void *native_display,
-                         const EGLint *attrib_list)
+                         const EGLint *int_attribs)
 {
+   EGLAttrib *attrib_list;
+   EGLDisplay display;
+
    _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL, EGL_NO_DISPLAY);
-   return _eglGetPlatformDisplayCommon(platform, native_display, attrib_list);
+
+   if (_eglConvertIntsToAttribs(int_attribs, &attrib_list) != EGL_SUCCESS)
+      RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, NULL);
+
+   display = _eglGetPlatformDisplayCommon(platform, native_display, attrib_list);
+   free(attrib_list);
+   return display;
 }
 
 EGLDisplay EGLAPIENTRY
 eglGetPlatformDisplay(EGLenum platform, void *native_display,
                       const EGLAttrib *attrib_list)
 {
-   EGLDisplay display;
-   EGLint *int_attribs;
-
    _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL, EGL_NO_DISPLAY);
-
-   int_attribs = _eglConvertAttribsToInt(attrib_list);
-   if (attrib_list && !int_attribs)
-      RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, NULL);
-
-   display = _eglGetPlatformDisplayCommon(platform, native_display, int_attribs);
-   free(int_attribs);
-   return display;
+   return _eglGetPlatformDisplayCommon(platform, native_display, attrib_list);
 }
 
 /**
index 690728d2f709d62315d6093dfc1443cc9aeca404..fe963c805ef366b2c4cda92004854211db3e2066 100644 (file)
@@ -447,7 +447,8 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type)
 
 #ifdef HAVE_X11_PLATFORM
 static EGLBoolean
-_eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list)
+_eglParseX11DisplayAttribList(_EGLDisplay *display,
+                              const EGLAttrib *attrib_list)
 {
    int i;
 
@@ -456,8 +457,8 @@ _eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list)
    }
 
    for (i = 0; attrib_list[i] != EGL_NONE; i += 2) {
-      EGLint attrib = attrib_list[i];
-      EGLint value = attrib_list[i + 1];
+      EGLAttrib attrib = attrib_list[i];
+      EGLAttrib value = attrib_list[i + 1];
 
       /* EGL_EXT_platform_x11 recognizes exactly one attribute,
        * EGL_PLATFORM_X11_SCREEN_EXT, which is optional.
@@ -473,7 +474,7 @@ _eglParseX11DisplayAttribList(_EGLDisplay *display, const EGLint *attrib_list)
 
 _EGLDisplay*
 _eglGetX11Display(Display *native_display,
-                  const EGLint *attrib_list)
+                  const EGLAttrib *attrib_list)
 {
    _EGLDisplay *display = _eglFindDisplay(_EGL_PLATFORM_X11,
                                           native_display);
@@ -494,7 +495,7 @@ _eglGetX11Display(Display *native_display,
 #ifdef HAVE_DRM_PLATFORM
 _EGLDisplay*
 _eglGetGbmDisplay(struct gbm_device *native_display,
-                  const EGLint *attrib_list)
+                  const EGLAttrib *attrib_list)
 {
    /* EGL_MESA_platform_gbm recognizes no attributes. */
    if (attrib_list != NULL && attrib_list[0] != EGL_NONE) {
@@ -509,7 +510,7 @@ _eglGetGbmDisplay(struct gbm_device *native_display,
 #ifdef HAVE_WAYLAND_PLATFORM
 _EGLDisplay*
 _eglGetWaylandDisplay(struct wl_display *native_display,
-                      const EGLint *attrib_list)
+                      const EGLAttrib *attrib_list)
 {
    /* EGL_EXT_platform_wayland recognizes no attributes. */
    if (attrib_list != NULL && attrib_list[0] != EGL_NONE) {
@@ -524,7 +525,7 @@ _eglGetWaylandDisplay(struct wl_display *native_display,
 #ifdef HAVE_SURFACELESS_PLATFORM
 _EGLDisplay*
 _eglGetSurfacelessDisplay(void *native_display,
-                          const EGLint *attrib_list)
+                          const EGLAttrib *attrib_list)
 {
    /* This platform has no native display. */
    if (native_display != NULL) {
index 0f57680b21f1c01e82904c30fcef453ad54f4219..52fb4ce21bb7923824536400c1893c793ded68ed 100644 (file)
@@ -266,7 +266,7 @@ _eglIsResourceLinked(_EGLResource *res)
 
 #ifdef HAVE_X11_PLATFORM
 _EGLDisplay*
-_eglGetX11Display(Display *native_display, const EGLint *attrib_list);
+_eglGetX11Display(Display *native_display, const EGLAttrib *attrib_list);
 #endif
 
 #ifdef HAVE_DRM_PLATFORM
@@ -274,7 +274,7 @@ struct gbm_device;
 
 _EGLDisplay*
 _eglGetGbmDisplay(struct gbm_device *native_display,
-                  const EGLint *attrib_list);
+                  const EGLAttrib *attrib_list);
 #endif
 
 #ifdef HAVE_WAYLAND_PLATFORM
@@ -282,13 +282,13 @@ struct wl_display;
 
 _EGLDisplay*
 _eglGetWaylandDisplay(struct wl_display *native_display,
-                      const EGLint *attrib_list);
+                      const EGLAttrib *attrib_list);
 #endif
 
 #ifdef HAVE_SURFACELESS_PLATFORM
 _EGLDisplay*
 _eglGetSurfacelessDisplay(void *native_display,
-                          const EGLint *attrib_list);
+                          const EGLAttrib *attrib_list);
 #endif
 
 #ifdef __cplusplus