From 4dd0c412db50e451e2bea04d60e6b7a2b6c9e9da Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 4 Dec 2012 16:01:16 +0200 Subject: [PATCH] window: add a note about freeing shm buffers 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 --- clients/window.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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]; -- 2.7.4