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 <ppaalanen@gmail.com>
Pekka Paalanen 12 years ago committed by Kristian Høgsberg
parent aac1c13332
commit 4dd0c412db
  1. 15
      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];

Loading…
Cancel
Save