diff --git a/docs/env_vars.md b/docs/env_vars.md index e36cdc781..263eb8945 100644 --- a/docs/env_vars.md +++ b/docs/env_vars.md @@ -58,6 +58,10 @@ wlroots reads these environment variables * *WLR_SCENE_DISABLE_VISIBILITY*: If set to 1, the visibility of all scene nodes will be considered to be the full node. Intelligent visibility canculations will be disabled. +* *WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION*: Highlights regions of scene buffers + that are advertised as transparent through wlr_scene_buffer_set_opaque_region(). + This can be used to debug issues with clients advertizing bogus opaque regions + with scene based compositors. # Generic diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 2f57ecfc3..a8fc21595 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -108,6 +108,7 @@ struct wlr_scene { enum wlr_scene_debug_damage_option debug_damage_option; bool direct_scanout; bool calculate_visibility; + bool highlight_transparent_region; }; /** A scene-graph node displaying a single surface. */ diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 1d6d7ab9b..da851bf31 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -172,6 +172,7 @@ struct wlr_scene *wlr_scene_create(void) { scene->debug_damage_option = env_parse_switch("WLR_SCENE_DEBUG_DAMAGE", debug_damage_options); scene->direct_scanout = !env_parse_bool("WLR_SCENE_DISABLE_DIRECT_SCANOUT"); scene->calculate_visibility = !env_parse_bool("WLR_SCENE_DISABLE_VISIBILITY"); + scene->highlight_transparent_region = env_parse_bool("WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION"); return scene; } @@ -1164,6 +1165,7 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node, struct render_list_entry { struct wlr_scene_node *node; bool sent_dmabuf_feedback; + bool highlight_transparent_region; int x, y; }; @@ -1249,6 +1251,15 @@ static void scene_entry_render(struct render_list_entry *entry, const struct ren .direct_scanout = false, }; wl_signal_emit_mutable(&scene_buffer->events.output_sample, &sample_event); + + if (entry->highlight_transparent_region) { + wlr_render_pass_add_rect(data->render_pass, &(struct wlr_render_rect_options){ + .box = dst_box, + .color = { .r = 0, .g = 0.3, .b = 0, .a = 0.3 }, + .clip = &opaque, + }); + } + break; } @@ -1492,6 +1503,7 @@ struct render_list_constructor_data { struct wlr_box box; struct wl_array *render_list; bool calculate_visibility; + bool highlight_transparent_region; }; static bool construct_render_list_iterator(struct wlr_scene_node *node, @@ -1535,6 +1547,7 @@ static bool construct_render_list_iterator(struct wlr_scene_node *node, .node = node, .x = lx, .y = ly, + .highlight_transparent_region = data->highlight_transparent_region, }; return false; @@ -1759,6 +1772,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output, .box = render_data.logical, .render_list = &scene_output->render_list, .calculate_visibility = scene_output->scene->calculate_visibility, + .highlight_transparent_region = scene_output->scene->highlight_transparent_region, }; list_con.render_list->size = 0;