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.
This commit is contained in:
Alexander Orzechowski 2022-08-16 07:06:17 -04:00
parent 4d4f823263
commit 6d1b8b376d
1 changed files with 3 additions and 1 deletions

View File

@ -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);