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
This commit is contained in:
Ray Strode 2016-02-08 16:07:34 -05:00
parent 4e82a751fb
commit e097bc8353
3 changed files with 10 additions and 5 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;