wlr_buffer: Introduce prerelease

The prerelease signal lets users do things things at the last moment
that would be inappropriate to do on the release signal. Inside the
prerelease signal, it is allowed to lock the buffer and also
upload/import the contents of the buffer to a texture.
This commit is contained in:
Alexander Orzechowski 2023-04-21 20:56:23 +02:00 committed by Alexander Orzechowski
parent 48874c9e86
commit d9f6ec080f
2 changed files with 6 additions and 0 deletions

View file

@ -56,6 +56,7 @@ struct wlr_buffer {
struct {
struct wl_signal destroy;
struct wl_signal release;
struct wl_signal prerelease;
} events;
struct wlr_addon_set addons;

View file

@ -19,6 +19,7 @@ void wlr_buffer_init(struct wlr_buffer *buffer,
};
wl_signal_init(&buffer->events.destroy);
wl_signal_init(&buffer->events.release);
wl_signal_init(&buffer->events.prerelease);
wlr_addon_set_init(&buffer->addons);
}
@ -58,6 +59,10 @@ void wlr_buffer_unlock(struct wlr_buffer *buffer) {
assert(buffer->n_locks > 0);
buffer->n_locks--;
if (buffer->n_locks == 0) {
wl_signal_emit_mutable(&buffer->events.prerelease, NULL);
}
if (buffer->n_locks == 0) {
wl_signal_emit_mutable(&buffer->events.release, NULL);
}