[PATCH weston 2/2] window: add a note about freeing shm buffers

Pekka Paalanen ppaalanen at gmail.com
Tue Dec 4 06:01:16 PST 2012


After a client has been double-buffering, and then switches to
single-buffering, it should release the 2nd buffer. That never happens
in practice here, so just add a comment and a check in case it ever
occurs in the future.

If we implemented the releasing now, it would be difficult to test.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 clients/window.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index c7767ae..29f6c87 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -833,6 +833,14 @@ shm_surface_buffer_release(void *data, struct wl_buffer *buffer)
 	struct shm_surface_leaf *leaf = data;
 
 	leaf->busy = 0;
+
+	/* If both leaves are now free, we should call
+	 * shm_surface_leaf_release(shm_surface::leaf[1]).
+	 * However, none of Weston's backends switch dynamically
+	 * between early buffer release and requiring double-buffering,
+	 * so if both leaves are free, we never used the second
+	 * leaf to begin with.
+	 */
 }
 
 static const struct wl_buffer_listener shm_surface_buffer_listener = {
@@ -851,6 +859,13 @@ shm_surface_prepare(struct toysurface *base, int dx, int dy,
 	surface->dx = dx;
 	surface->dy = dy;
 
+	/* See shm_surface_buffer_release() */
+	if (!surface->leaf[0].busy && !surface->leaf[1].busy &&
+	    surface->leaf[1].cairo_surface) {
+		fprintf(stderr, "window.c:%s: TODO: release leaf[1]\n",
+			__func__);
+	}
+
 	/* pick a free buffer from the two */
 	if (!surface->leaf[0].busy)
 		leaf = &surface->leaf[0];
-- 
1.7.8.6



More information about the wayland-devel mailing list