From c79ed0706d91261490aae570d86807675fa7c6cb Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 12 Mar 2024 12:11:35 +0100 Subject: [PATCH] scene: simplify scene_node_update() condition when setting buffer --- types/scene/wlr_scene.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 3a97cdaa..59b992df 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -666,17 +666,16 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff // coordinates. assert(buffer || !damage); - bool update = false; - if (buffer) { - // if this node used to not be mapped or its previous displayed - // buffer region will be different from what the new buffer would - // produce we need to update the node. - update = (!scene_buffer->buffer && !scene_buffer->texture) || - (scene_buffer->dst_width == 0 && scene_buffer->dst_height == 0 && - (scene_buffer->buffer_width != buffer->width || - scene_buffer->buffer_height != buffer->height)); - } else { - update = true; + bool mapped = buffer != NULL; + bool prev_mapped = scene_buffer->buffer != NULL || scene_buffer->texture != NULL; + + // if this node used to not be mapped or its previous displayed + // buffer region will be different from what the new buffer would + // produce we need to update the node. + bool update = mapped != prev_mapped; + if (buffer != NULL && scene_buffer->dst_width == 0 && scene_buffer->dst_height == 0) { + update = update || scene_buffer->buffer_width != buffer->width || + scene_buffer->buffer_height != buffer->height; } wlr_texture_destroy(scene_buffer->texture);