summaryrefslogtreecommitdiff
path: root/src/wayland/meta-wayland-buffer.c
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2016-01-31 15:57:29 -0500
committerRay Strode <rstrode@redhat.com>2016-02-01 14:16:17 -0500
commit0165cb697466ba0843b993416e00d4f768c00d45 (patch)
tree61186108672c91d1883a8de03e43dca9e7334ea6 /src/wayland/meta-wayland-buffer.c
parent3cdcd3e9c1f58daddf2a99bee36dffc5d86f7df8 (diff)
downloadmutter-0165cb697466ba0843b993416e00d4f768c00d45.tar.gz
wayland: release buffer after processing commit
When a client is ready for the compositor to read a surface's shared memory buffer, it tells the compositor via wl_surface_commit. From that point forward, the baton is given to the compositor: it knows it can read the buffer without worring about the client making changes out from under it. After the compositor has uploaded the pixel contents to the video card it is supposed to release the buffer back to the client so that the client can reuse it for future use. At the moment, mutter only releases the buffer when a new buffer is attached. This is problematic, since it means the client has to have a second buffer prepared before the compositor gives the first one back. Preparing the second buffer potentially involves copying megabytes of pixel data, so that's suboptimal, and there's no reason mutter couldn't release the buffer earlier. This commit changes mutter to release a surface's buffer as soon as it's done processing the commit request. https://bugzilla.gnome.org/show_bug.cgi?id=761312
Diffstat (limited to 'src/wayland/meta-wayland-buffer.c')
-rw-r--r--src/wayland/meta-wayland-buffer.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
index f2cf1e723..bb0e8d234 100644
--- a/src/wayland/meta-wayland-buffer.c
+++ b/src/wayland/meta-wayland-buffer.c
@@ -54,10 +54,31 @@ meta_wayland_buffer_unref (MetaWaylandBuffer *buffer)
if (buffer->ref_count == 0)
{
g_clear_pointer (&buffer->texture, cogl_object_unref);
- wl_resource_queue_event (buffer->resource, WL_BUFFER_RELEASE);
+
+ if (buffer->accessible)
+ meta_wayland_buffer_release_control (buffer);
}
}
+void
+meta_wayland_buffer_take_control (MetaWaylandBuffer *buffer)
+{
+ if (buffer->accessible)
+ meta_fatal ("buffer control taken twice");
+
+ buffer->accessible = TRUE;
+}
+
+void
+meta_wayland_buffer_release_control (MetaWaylandBuffer *buffer)
+{
+ if (!buffer->accessible)
+ meta_fatal ("buffer released when not in control");
+
+ wl_resource_queue_event (buffer->resource, WL_BUFFER_RELEASE);
+ buffer->accessible = FALSE;
+}
+
MetaWaylandBuffer *
meta_wayland_buffer_from_resource (struct wl_resource *resource)
{
@@ -93,6 +114,9 @@ meta_wayland_buffer_ensure_texture (MetaWaylandBuffer *buffer)
CoglTexture *texture;
struct wl_shm_buffer *shm_buffer;
+ if (!buffer->accessible)
+ meta_warning ("attempted to process damage on uncommitted buffer");
+
if (buffer->texture)
goto out;
@@ -126,6 +150,9 @@ meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
{
struct wl_shm_buffer *shm_buffer;
+ if (!buffer->accessible)
+ meta_warning ("attempted to process damage on uncommitted buffer");
+
shm_buffer = wl_shm_buffer_get (buffer->resource);
if (shm_buffer)