summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers
diff options
context:
space:
mode:
authorMiguel A. Vico <[email protected]>2017-07-19 17:27:12 -0700
committerEmil Velikov <[email protected]>2017-07-24 10:27:52 +0100
commit2d5d61bc491b6cef08ced8f1ad57b154d4fa5f66 (patch)
treee03926206e5097cbda26e5d7007004ff47fa0eca /src/egl/drivers
parent63c251e38f9b4ac3606094a72c8c5b658402f3d0 (diff)
wayland-egl: Make wl_egl_window a versioned struct
We need wl_egl_window to be a versioned struct in order to keep track of ABI changes. This change makes the first member of wl_egl_window the version number. An heuristic in the wayland driver is added so that we don't break backwards compatibility: - If the first field (version) is an actual pointer, it is an old implementation of wl_egl_window, and version points to the wl_surface proxy. - Else, the first field is the version number, and we have wl_egl_window::surface pointing to the wl_surface proxy. Signed-off-by: Miguel A. Vico <[email protected]> Reviewed-by: James Jones <[email protected]> Acked-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 211036f45f4..f4c09ac0bc1 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -43,6 +43,7 @@
#include "egl_dri2_fallbacks.h"
#include "loader.h"
#include "util/u_vector.h"
+#include "eglglobals.h"
#include <wayland-client.h>
#include "wayland-drm-client-protocol.h"
@@ -111,6 +112,19 @@ destroy_window_callback(void *data)
dri2_surf->wl_win = NULL;
}
+static struct wl_surface *
+get_wl_surface_proxy(struct wl_egl_window *window)
+{
+ /* Version 3 of wl_egl_window introduced a version field at the same
+ * location where a pointer to wl_surface was stored. Thus, if
+ * window->version is dereferencable, we've been given an older version of
+ * wl_egl_window, and window->version points to wl_surface */
+ if (_eglPointerIsDereferencable((void *)(window->version))) {
+ return wl_proxy_create_wrapper((void *)(window->version));
+ }
+ return wl_proxy_create_wrapper(window->surface);
+}
+
/**
* Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
*/
@@ -182,7 +196,7 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
wl_proxy_set_queue((struct wl_proxy *)dri2_surf->wl_dpy_wrapper,
dri2_surf->wl_queue);
- dri2_surf->wl_surface_wrapper = wl_proxy_create_wrapper(window->surface);
+ dri2_surf->wl_surface_wrapper = get_wl_surface_proxy(window);
if (!dri2_surf->wl_surface_wrapper) {
_eglError(EGL_BAD_ALLOC, "dri2_create_surface");
goto cleanup_drm;