From 5b5ad2079394880ab3379ba2e6fb7f9295490627 Mon Sep 17 00:00:00 2001 From: Clemens Buchacher Date: Wed, 1 Jan 2014 16:40:13 +0100 Subject: fix compile with Mesa 10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mesa 10.0 replaces struct wl_buffer with struct wl_resource in the eglQueryWaylandBufferWL signature. The structures are binary compatible (struct wl_buffer is a superset of struct wl_resource), but C++ complains about the type mismatch: error: cannot convert ‘wl_buffer*’ to ‘wl_resource*’ in argument passing We are already using struct wl_resource on our side, so removing the now redundant reinterpret_cast would fix it. But then we could not compile with Mesa versions older than 10.0 any more, and those are still common in mainstream distributions today. A compile-time switch for different Mesa versions is possible, but unnecessarily clumsy. Instead, re-declare the new signature and use that independently of the Mesa version. The duplicate declaration can be removed when backwards compatibility is no longer needed. Change-Id: I3d0e326f5a0eb88d125b8c9fd23147682e23b94b Reviewed-by: Robin Burchell --- .../wayland-egl/waylandeglclientbufferintegration.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index c9b8c9e4..ede8a9ab 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -54,10 +54,12 @@ #include #include +/* Needed for compatibility with Mesa older than 10.0. */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL_compat) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); + #ifndef EGL_WL_bind_wayland_display typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWL) (EGLDisplay dpy, struct wl_display *display); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWL) (EGLDisplay dpy, struct wl_buffer *buffer, EGLint attribute, EGLint *value); #endif #ifndef EGL_KHR_image @@ -91,7 +93,7 @@ public: bool display_bound; PFNEGLBINDWAYLANDDISPLAYWL egl_bind_wayland_display; PFNEGLUNBINDWAYLANDDISPLAYWL egl_unbind_wayland_display; - PFNEGLQUERYWAYLANDBUFFERWL egl_query_wayland_buffer; + PFNEGLQUERYWAYLANDBUFFERWL_compat egl_query_wayland_buffer; PFNEGLCREATEIMAGEKHRPROC egl_create_image; PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image; @@ -136,7 +138,7 @@ void WaylandEglClientBufferIntegration::initializeHardware(QtWayland::Display *w return; } - d->egl_query_wayland_buffer = reinterpret_cast(eglGetProcAddress("eglQueryWaylandBufferWL")); + d->egl_query_wayland_buffer = reinterpret_cast(eglGetProcAddress("eglQueryWaylandBufferWL")); if (!d->egl_query_wayland_buffer) { qWarning("Failed to initialize egl display. Could not find eglQueryWaylandBufferWL.\n"); return; @@ -197,7 +199,7 @@ bool WaylandEglClientBufferIntegration::isYInverted(struct ::wl_resource *buffer EGLint isYInverted; EGLBoolean ret; - ret = d->egl_query_wayland_buffer(d->egl_display, reinterpret_cast(buffer), EGL_WAYLAND_Y_INVERTED_WL, &isYInverted); + ret = d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_WAYLAND_Y_INVERTED_WL, &isYInverted); // Yes, this looks strange, but the specification says that EGL_FALSE return // value (not supported) should be treated the same as EGL_TRUE return value @@ -233,8 +235,8 @@ QSize WaylandEglClientBufferIntegration::bufferSize(struct ::wl_resource *buffer Q_D(const WaylandEglClientBufferIntegration); int width, height; - d->egl_query_wayland_buffer(d->egl_display, reinterpret_cast(buffer), EGL_WIDTH, &width); - d->egl_query_wayland_buffer(d->egl_display, reinterpret_cast(buffer), EGL_HEIGHT, &height); + d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_WIDTH, &width); + d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_HEIGHT, &height); return QSize(width, height); } -- cgit v1.2.1