wlr_scene: Add WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION env

This commit is contained in:
Alexander Orzechowski 2024-05-04 19:03:36 -04:00 committed by Kirill Primak
parent 8fdf9dc4f0
commit 53be443f39
3 changed files with 19 additions and 0 deletions

View File

@ -58,6 +58,10 @@ wlroots reads these environment variables
* *WLR_SCENE_DISABLE_VISIBILITY*: If set to 1, the visibility of all scene nodes * *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 will be considered to be the full node. Intelligent visibility canculations will
be disabled. 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 # Generic

View File

@ -108,6 +108,7 @@ struct wlr_scene {
enum wlr_scene_debug_damage_option debug_damage_option; enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout; bool direct_scanout;
bool calculate_visibility; bool calculate_visibility;
bool highlight_transparent_region;
}; };
/** A scene-graph node displaying a single surface. */ /** A scene-graph node displaying a single surface. */

View File

@ -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->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->direct_scanout = !env_parse_bool("WLR_SCENE_DISABLE_DIRECT_SCANOUT");
scene->calculate_visibility = !env_parse_bool("WLR_SCENE_DISABLE_VISIBILITY"); scene->calculate_visibility = !env_parse_bool("WLR_SCENE_DISABLE_VISIBILITY");
scene->highlight_transparent_region = env_parse_bool("WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION");
return scene; return scene;
} }
@ -1164,6 +1165,7 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
struct render_list_entry { struct render_list_entry {
struct wlr_scene_node *node; struct wlr_scene_node *node;
bool sent_dmabuf_feedback; bool sent_dmabuf_feedback;
bool highlight_transparent_region;
int x, y; int x, y;
}; };
@ -1249,6 +1251,15 @@ static void scene_entry_render(struct render_list_entry *entry, const struct ren
.direct_scanout = false, .direct_scanout = false,
}; };
wl_signal_emit_mutable(&scene_buffer->events.output_sample, &sample_event); 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; break;
} }
@ -1492,6 +1503,7 @@ struct render_list_constructor_data {
struct wlr_box box; struct wlr_box box;
struct wl_array *render_list; struct wl_array *render_list;
bool calculate_visibility; bool calculate_visibility;
bool highlight_transparent_region;
}; };
static bool construct_render_list_iterator(struct wlr_scene_node *node, 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, .node = node,
.x = lx, .x = lx,
.y = ly, .y = ly,
.highlight_transparent_region = data->highlight_transparent_region,
}; };
return false; return false;
@ -1759,6 +1772,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
.box = render_data.logical, .box = render_data.logical,
.render_list = &scene_output->render_list, .render_list = &scene_output->render_list,
.calculate_visibility = scene_output->scene->calculate_visibility, .calculate_visibility = scene_output->scene->calculate_visibility,
.highlight_transparent_region = scene_output->scene->highlight_transparent_region,
}; };
list_con.render_list->size = 0; list_con.render_list->size = 0;