Mesa (master): wayland-drm: Implement wl_buffer. damage in old versions of Wayland

Kristian Høgsberg krh at kemper.freedesktop.org
Fri Apr 13 03:13:59 UTC 2012


Module: Mesa
Branch: master
Commit: 4f2eafe4dcea26d7275b121360c4f4e0b28455f5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f2eafe4dcea26d7275b121360c4f4e0b28455f5

Author: Neil Roberts <neil at linux.intel.com>
Date:   Wed Apr 11 17:07:56 2012 +0100

wayland-drm: Implement wl_buffer.damage in old versions of Wayland

Commit 272bc48976 removed the damage implementation for the
wl_buffer_interface because that has been removed from git master of
Wayland. However this breaks building with the 0.85 branch of Wayland
because it would end up initialising the struct incorrectly.

For the time being it's quite convenient for some compositors to track
the 0.85 branch of Wayland because the protocol is stable but they
will also want to track the master branch of Mesa so that they can use
the gbm surface changes.

This patch adds a compile-time check for the version of Wayland so
that it can work with either Wayland master or the 0.85 branch.

krh: Edited to also account for API changes in 6802eaa68, which
removes the timestamp argument from wl_resource_destroy().

---

 src/egl/wayland/wayland-drm/wayland-drm.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
index 101b2c4..5f831b3 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -36,6 +36,17 @@
 #include "wayland-drm.h"
 #include "wayland-drm-server-protocol.h"
 
+/* Git master of Wayland is moving towards a stable version of the
+ * protocol, but breaking from 0.85 in the process.  For the time
+ * being, it's convenient to be able to build Mesa against both master
+ * and 0.85.x of Wayland.  To make this work we'll do a compile-time
+ * version check and work around the difference in API and protocol */
+#if defined (WAYLAND_VERSION_MAJOR) &&		\
+	WAYLAND_VERSION_MAJOR == 0 &&		\
+	WAYLAND_VERSION_MINOR == 85
+#define HAS_WAYLAND_0_85
+#endif
+
 struct wl_drm {
 	struct wl_display *display;
 
@@ -67,10 +78,25 @@ destroy_buffer(struct wl_resource *resource)
 static void
 buffer_destroy(struct wl_client *client, struct wl_resource *resource)
 {
+#ifdef HAS_WAYLAND_0_85
 	wl_resource_destroy(resource, 0);
+#else
+	wl_resource_destroy(resource);
+#endif
+}
+
+#ifdef HAS_WAYLAND_0_85
+static void
+buffer_damage(struct wl_client *client, struct wl_resource *buffer,
+              int32_t x, int32_t y, int32_t width, int32_t height)
+{
 }
+#endif
 
 const static struct wl_buffer_interface drm_buffer_interface = {
+#ifdef HAS_WAYLAND_0_85
+	buffer_damage,
+#endif
 	buffer_destroy
 };
 




More information about the mesa-commit mailing list