Mesa (main): egl: dereference XCB drawable pointers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 21 15:15:53 UTC 2022


Module: Mesa
Branch: main
Commit: d7dc27645efdbc45abd249257b1374078df34b2b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d7dc27645efdbc45abd249257b1374078df34b2b

Author: Jeffrey Knockel <jeff at jeffreyknockel.com>
Date:   Sun May  1 21:15:32 2022 -0400

egl: dereference XCB drawable pointers

eglCreatePlatformWindowSurface[EXT] and
eglCreatePlatformPixmapSurface[EXT] should be passed (xcb_window_t *)
and (xcb_pixmap_t *), so we must dereference these types before using
them as drawables.  We already do something similar with X11 drawable
pointers.

Signed-off-by: Jeffrey Knockel <jeff at jeffreyknockel.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16269>

---

 src/egl/main/eglapi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index d0238fe95e4..97f5b6ab447 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -1030,6 +1030,15 @@ _fixupNativeWindow(_EGLDisplay *disp, void *native_window)
        */
       return (void *)(* (Window*) native_window);
    }
+#endif
+#ifdef HAVE_XCB_PLATFORM
+   if (disp && disp->Platform == _EGL_PLATFORM_XCB && native_window != NULL) {
+      /* Similar to with X11, we need to convert (xcb_window_t *)
+       * (i.e., uint32_t *) to xcb_window_t. We have to do an intermediate cast
+       * to uintptr_t, since uint32_t may be smaller than a pointer.
+       */
+      return (void *)(uintptr_t) (* (uint32_t*) native_window);
+   }
 #endif
    return native_window;
 }
@@ -1084,6 +1093,15 @@ _fixupNativePixmap(_EGLDisplay *disp, void *native_pixmap)
     */
    if (disp && disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL)
       return (void *)(* (Pixmap*) native_pixmap);
+#endif
+#ifdef HAVE_XCB_PLATFORM
+   if (disp && disp->Platform == _EGL_PLATFORM_XCB && native_pixmap != NULL) {
+      /* Similar to with X11, we need to convert (xcb_pixmap_t *)
+       * (i.e., uint32_t *) to xcb_pixmap_t. We have to do an intermediate cast
+       * to uintptr_t, since uint32_t may be smaller than a pointer.
+       */
+      return (void *)(uintptr_t) (* (uint32_t*) native_pixmap);
+   }
 #endif
    return native_pixmap;
 }



More information about the mesa-commit mailing list