From 6d1b8b376d1e4a5e1b4b07e53487533711988136 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Tue, 16 Aug 2022 07:06:17 -0400 Subject: [PATCH] wlr_scene: Only enable black rect optimization if culling is enabled If culling is not enabled, there is no longer any guarantee that the elements behind the rect won't be rendered. We must render the black rect in all circumstances to cover up anything rendered. This fixes the WLR_SCENE_DISABLE_VISIBILTY option. --- types/scene/wlr_scene.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index ddd09a35..5c14aa66 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -1322,6 +1322,7 @@ static bool scene_node_invisible(struct wlr_scene_node *node) { struct render_list_constructor_data { struct wlr_box box; struct wl_array *render_list; + bool calculate_visibility; }; static bool construct_render_list_iterator(struct wlr_scene_node *node, @@ -1335,7 +1336,7 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node, // while rendering, the background should always be black. // If we see a black rect, we can ignore rendering everything under the rect // and even the rect itself. - if (node->type == WLR_SCENE_NODE_RECT) { + if (node->type == WLR_SCENE_NODE_RECT && data->calculate_visibility) { struct wlr_scene_rect *rect = scene_rect_from_node(node); float *black = (float[4]){ 0.f, 0.f, 0.f, 1.f }; @@ -1430,6 +1431,7 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) { struct render_list_constructor_data list_con = { .box = { .x = scene_output->x, .y = scene_output->y }, .render_list = &scene_output->render_list, + .calculate_visibility = scene_output->scene->calculate_visibility, }; wlr_output_effective_resolution(output, &list_con.box.width, &list_con.box.height);