From e097bc8353f70fb47d5b2b40d2a7b12c7fc29855 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 8 Feb 2016 16:07:34 -0500 Subject: [PATCH] wayland: get rid of buffer->copied_data boolean We currently track whether or not a buffer can be released early by looking at the copied_data boolean on the buffer. This boolean is, practically speaking, always set to TRUE for shm buffers and is always false otherwise. We can just as easily check if the buffer is a shm buffer to decide whether or not to do an early release. That's better from a theoretical point of view since copied_data assumes a 1-to-1 relationship between surface and buffer, which may not actually hold. This commit drops copied_data and changes the check to instead see if the buffer is shm. https://bugzilla.gnome.org/show_bug.cgi?id=761613 --- src/wayland/meta-wayland-buffer.c | 3 --- src/wayland/meta-wayland-buffer.h | 1 - src/wayland/meta-wayland-surface.c | 11 ++++++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c index 1d9b0c3b1..bb0e8d234 100644 --- a/src/wayland/meta-wayland-buffer.c +++ b/src/wayland/meta-wayland-buffer.c @@ -140,9 +140,6 @@ meta_wayland_buffer_ensure_texture (MetaWaylandBuffer *buffer) buffer->texture = texture; - if (shm_buffer) - buffer->copied_data = TRUE; - out: return buffer->texture; } diff --git a/src/wayland/meta-wayland-buffer.h b/src/wayland/meta-wayland-buffer.h index 22cbcc1f4..9f6a5bf83 100644 --- a/src/wayland/meta-wayland-buffer.h +++ b/src/wayland/meta-wayland-buffer.h @@ -41,7 +41,6 @@ struct _MetaWaylandBuffer uint32_t ref_count; uint32_t accessible : 1; - uint32_t copied_data : 1; }; MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource); diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index aa9824655..fc884d9ef 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -648,6 +648,8 @@ static void apply_pending_state (MetaWaylandSurface *surface, MetaWaylandPendingState *pending) { + gboolean release_new_buffer = FALSE; + if (pending->newly_attached) { if (!surface->buffer && surface->window) @@ -657,9 +659,16 @@ apply_pending_state (MetaWaylandSurface *surface, if (pending->buffer) { + struct wl_shm_buffer *shm_buffer = wl_shm_buffer_get (pending->buffer->resource); + meta_wayland_buffer_take_control (pending->buffer); CoglTexture *texture = meta_wayland_buffer_ensure_texture (pending->buffer); meta_surface_actor_wayland_set_texture (META_SURFACE_ACTOR_WAYLAND (surface->surface_actor), texture); + + /* Release the buffer as soon as possible, so the client can reuse it + */ + if (shm_buffer) + release_new_buffer = TRUE; } } @@ -669,7 +678,7 @@ apply_pending_state (MetaWaylandSurface *surface, if (!cairo_region_is_empty (pending->damage)) surface_process_damage (surface, pending->damage); - if (pending->buffer && pending->buffer->copied_data) + if (release_new_buffer) meta_wayland_buffer_release_control (pending->buffer); surface->offset_x += pending->dx;