From 6c66148faf4b637c64d0e4fb1729422cf9808fa5 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 4 Jul 2013 13:28:45 +0100 Subject: [PATCH] Update ClutterWaylandSurface to use a resource instead of wl_buffer The Wayland server API has changed so that wl_shm_buffer is no longer a type of wl_buffer and wl_buffer will become an opaque type. This changes ClutterWaylandSurface to accept resources for a wl_buffer instead of directly taking the wl_buffer so that it can do different things depending on whether the resource points to an SHM buffer or a normal buffer. This matches similar changes to Cogl: https://git.gnome.org/browse/cogl/commit/?id=9b35e1651ad0e46ed48989 https://bugzilla.gnome.org/show_bug.cgi?id=703608 --- clutter/wayland/clutter-wayland-surface.c | 25 ++++++++++++++--------- clutter/wayland/clutter-wayland-surface.h | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/clutter/wayland/clutter-wayland-surface.c b/clutter/wayland/clutter-wayland-surface.c index e16c3ff34..9ee40359a 100644 --- a/clutter/wayland/clutter-wayland-surface.c +++ b/clutter/wayland/clutter-wayland-surface.c @@ -511,7 +511,7 @@ clutter_wayland_surface_new (struct wl_surface *surface) /** * clutter_wayland_surface_attach_buffer: * @self: A #ClutterWaylandSurface actor - * @buffer: A compositor side struct wl_buffer pointer + * @buffer: A compositor side resource representing a wl_buffer * @error: A #GError * * This associates a client's buffer with the #ClutterWaylandSurface @@ -523,7 +523,7 @@ clutter_wayland_surface_new (struct wl_surface *surface) */ gboolean clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, - struct wl_buffer *buffer, + struct wl_resource *buffer, GError **error) { ClutterWaylandSurfacePrivate *priv; @@ -536,8 +536,6 @@ clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, free_surface_buffers (self); - set_size (self, buffer->width, buffer->height); - priv->buffer = cogl_wayland_texture_2d_new_from_buffer (context, buffer, error); @@ -551,13 +549,17 @@ clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, if (!priv->buffer) return FALSE; + set_size (self, + cogl_texture_get_width (COGL_TEXTURE (priv->buffer)), + cogl_texture_get_height (COGL_TEXTURE (priv->buffer))); + return TRUE; } /** * clutter_wayland_surface_damage_buffer: * @self: A #ClutterWaylandSurface actor - * @buffer: A compositor side struct wl_buffer pointer + * @buffer: A wayland resource for a buffer * @x: The x coordinate of the damaged rectangle * @y: The y coordinate of the damaged rectangle * @width: The width of the damaged rectangle @@ -575,23 +577,26 @@ clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, */ void clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self, - struct wl_buffer *buffer, + struct wl_resource *buffer, gint32 x, gint32 y, gint32 width, gint32 height) { ClutterWaylandSurfacePrivate *priv; + struct wl_shm_buffer *shm_buffer; g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self)); priv = self->priv; - if (priv->buffer && wl_buffer_is_shm (buffer)) + shm_buffer = wl_shm_buffer_get (buffer); + + if (priv->buffer && shm_buffer) { CoglPixelFormat format; - switch (wl_shm_buffer_get_format (buffer)) + switch (wl_shm_buffer_get_format (shm_buffer)) { #if G_BYTE_ORDER == G_BIG_ENDIAN case WL_SHM_FORMAT_ARGB8888: @@ -619,8 +624,8 @@ clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self, width, height, width, height, format, - wl_shm_buffer_get_stride (buffer), - wl_shm_buffer_get_data (buffer)); + wl_shm_buffer_get_stride (shm_buffer), + wl_shm_buffer_get_data (shm_buffer)); } g_signal_emit (self, signals[QUEUE_DAMAGE_REDRAW], diff --git a/clutter/wayland/clutter-wayland-surface.h b/clutter/wayland/clutter-wayland-surface.h index b68483ec7..da051e4af 100644 --- a/clutter/wayland/clutter-wayland-surface.h +++ b/clutter/wayland/clutter-wayland-surface.h @@ -95,10 +95,10 @@ void clutter_wayland_surface_set_surface (ClutterWaylandSurface * struct wl_surface *surface); struct wl_surface *clutter_wayland_surface_get_surface (ClutterWaylandSurface *self); gboolean clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, - struct wl_buffer *buffer, + struct wl_resource *buffer, GError **error); void clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self, - struct wl_buffer *buffer, + struct wl_resource *buffer, gint32 x, gint32 y, gint32 width,