From fd234744979c8e7bbf54ae0358d959fcac19e3c5 Mon Sep 17 00:00:00 2001 From: Alexander Orezechowski Date: Fri, 11 Oct 2024 12:35:57 -0400 Subject: [PATCH] output: Change wlr_output_add_software_cursors_to_render_pass to take buffer coordinates Since wlr_damage_ring now only works with buffer local coordinates, this creates an inpedance mismatch for compositors that want to use this function. Instead of compositors needing to the the conversion itself, change thu function to take buffer local coordinates directly. --- include/wlr/types/wlr_output.h | 2 +- types/output/cursor.c | 23 ++++++++--------------- types/scene/wlr_scene.c | 9 +-------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index f7a7bed5..3ed99b9a 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -380,7 +380,7 @@ void wlr_output_lock_attach_render(struct wlr_output *output, bool lock); */ void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock); /** - * Render software cursors. + * Render software cursors. The damage is in buffer-local coordinate space. * * This is a utility function that can be called when compositors render. */ diff --git a/types/output/cursor.c b/types/output/cursor.c index f8f5eb64..d09a335a 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -92,12 +92,6 @@ void wlr_output_add_software_cursors_to_render_pass(struct wlr_output *output, int width, height; wlr_output_transformed_resolution(output, &width, &height); - pixman_region32_t render_damage; - pixman_region32_init_rect(&render_damage, 0, 0, width, height); - if (damage != NULL) { - pixman_region32_intersect(&render_damage, &render_damage, damage); - } - struct wlr_output_cursor *cursor; wl_list_for_each(cursor, &output->cursors, link) { if (!cursor->enabled || !cursor->visible || @@ -112,20 +106,21 @@ void wlr_output_add_software_cursors_to_render_pass(struct wlr_output *output, struct wlr_box box; output_cursor_get_box(cursor, &box); + wlr_box_transform(&box, &box, + wlr_output_transform_invert(output->transform), width, height); pixman_region32_t cursor_damage; - pixman_region32_init_rect(&cursor_damage, box.x, box.y, box.width, box.height); - pixman_region32_intersect(&cursor_damage, &cursor_damage, &render_damage); + pixman_region32_init_rect(&cursor_damage, + box.x, box.y, box.width, box.height); + if (damage != NULL) { + pixman_region32_intersect(&cursor_damage, &cursor_damage, damage); + } + if (!pixman_region32_not_empty(&cursor_damage)) { pixman_region32_fini(&cursor_damage); continue; } - enum wl_output_transform transform = - wlr_output_transform_invert(output->transform); - wlr_box_transform(&box, &box, transform, width, height); - wlr_region_transform(&cursor_damage, &cursor_damage, transform, width, height); - wlr_render_pass_add_texture(render_pass, &(struct wlr_render_texture_options) { .texture = texture, .src_box = cursor->src_box, @@ -136,8 +131,6 @@ void wlr_output_add_software_cursors_to_render_pass(struct wlr_output *output, pixman_region32_fini(&cursor_damage); } - - pixman_region32_fini(&render_damage); } static void output_cursor_damage_whole(struct wlr_output_cursor *cursor) { diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 16ed63a1..b5863f47 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -2208,14 +2208,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output, } } - pixman_region32_t cursor_damage; - pixman_region32_init(&cursor_damage); - pixman_region32_copy(&cursor_damage, &render_data.damage); - wlr_region_transform(&cursor_damage, &cursor_damage, - output->transform, resolution_width, resolution_height); - wlr_output_add_software_cursors_to_render_pass(output, render_pass, &cursor_damage); - pixman_region32_fini(&cursor_damage); - + wlr_output_add_software_cursors_to_render_pass(output, render_pass, &render_data.damage); pixman_region32_fini(&render_data.damage); if (!wlr_render_pass_submit(render_pass)) {