From 69a59359fa8590074717e211d332c1077d8f277f Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 28 Apr 2022 13:28:26 +0300 Subject: [PATCH] pixman-renderer: Unref the pixman image when wl_shm_buffer is gone Even if the weston_buffer_reference is still alive in situations like when we have closing animations, the underyling buffer (wl_shm_buffer) is no longer available. Call the appropriate destroy handler to invalidate the pixman image and avoid touch the shm_buffer. Fixes: #613 Signed-off-by: Marius Vlad --- libweston/pixman-renderer.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libweston/pixman-renderer.c b/libweston/pixman-renderer.c index 636d9d91..d93e7ed2 100644 --- a/libweston/pixman-renderer.c +++ b/libweston/pixman-renderer.c @@ -36,6 +36,7 @@ #include "color.h" #include "pixel-formats.h" #include "shared/helpers.h" +#include "shared/signal.h" #include @@ -489,6 +490,19 @@ draw_paint_node(struct weston_paint_node *pnode, if (!ps->image) return; + /* if we still have a reference, but the underlying buffer is no longer + * available signal that we should unref image_t as well. This happens + * when using close animations, with the reference surviving the + * animation while the underlying buffer went away as the client was + * terminated. This is a particular use-case and should probably be + * refactored to provide some analogue with the GL-renderer (as in, to + * still maintain the buffer and let the compositor dispose of it). */ + if (ps->buffer_ref.buffer && !ps->buffer_ref.buffer->shm_buffer) { + pixman_image_unref(ps->image); + ps->image = NULL; + return; + } + pixman_region32_init(&repaint); pixman_region32_intersect(&repaint, &pnode->view->transform.boundingbox, damage);