wlr_compositor: Introduce wlr_surface_consume

If the compositor is running without a renderer, that means that
the compositor must be driven by something external that may or may not
be there. So we have two scenarios:
1. This compositor is currently being watched and driven by some
external source that is consuming buffers. This is okay, because
during the commit handler `surface->current.buffer` and
`surface->buffer_damage` will be usable and things will be handled
like normal.
2. Things break however if the compositor is not currently driven. This
however is commonly temporary. Something may not be interested right now,
but later it can be. In this case we have to accumulate state until
this external consumer is ready. Here, we have to accumulate the
`buffer_damage` and keep the buffer locked until the consumer is ready.

`wlr_surface_consume` needs to be called when the state of this surface
was consumed so that it is safe to release these resources.
This commit is contained in:
Alexander Orzechowski 2023-05-03 22:58:39 -04:00
parent 4f0058f85c
commit 7ba7f774ca
2 changed files with 21 additions and 0 deletions

View file

@ -538,6 +538,12 @@ void wlr_surface_synced_finish(struct wlr_surface_synced *synced);
void *wlr_surface_synced_get_state(struct wlr_surface_synced *synced,
const struct wlr_surface_state *state);
/*
* Consumes buffer and damage state of the buffer so that the compositor may
* drop references to any of these resources.
*/
void wlr_surface_consume(struct wlr_surface *surface);
/**
* Get a Pixman region from a wl_region resource.
*/