scaled-scene-buffer: allow multiple wlr_buffer_drops()

This allows implementations of the interface to share a single
wlr_buffer for multiple wlr_scene_buffer nodes and still make
the scaled-scene-buffer handle the buffer drops.

wlr_scene_buffer holds an implicit lock while using a wlr_buffer
and scaled-scene-buffer.c holds additional locks for as long as
a buffer is within its internal cache.

This should ensure that a shared wlr_buffer never gets actually
dropped even if wlr_buffer_drop() has been called by another
scaled-scene-buffer instance using the same wlr_buffer.
This commit is contained in:
Consolatis 2024-11-15 07:02:52 +01:00 committed by Johan Malm
parent 2df6628490
commit 71b4277852

View file

@ -41,10 +41,10 @@ _cache_entry_destroy(struct scaled_scene_buffer_cache_entry *cache_entry, bool d
wl_list_remove(&cache_entry->link);
if (cache_entry->buffer) {
/* Allow the buffer to get dropped if there are no further consumers */
wlr_buffer_unlock(cache_entry->buffer);
if (drop_buffer) {
if (drop_buffer && !cache_entry->buffer->dropped) {
wlr_buffer_drop(cache_entry->buffer);
}
wlr_buffer_unlock(cache_entry->buffer);
}
free(cache_entry);
}
@ -82,10 +82,10 @@ _update_buffer(struct scaled_scene_buffer *self, double scale)
cache_entry = wl_container_of(self->cache.prev, cache_entry, link);
if (cache_entry->buffer) {
/* Allow the old buffer to get dropped if there are no further consumers */
wlr_buffer_unlock(cache_entry->buffer);
if (self->drop_buffer) {
if (self->drop_buffer && !cache_entry->buffer->dropped) {
wlr_buffer_drop(cache_entry->buffer);
}
wlr_buffer_unlock(cache_entry->buffer);
}
wl_list_remove(&cache_entry->link);
}