From ab840fc8555e3aef59fd11b39063c701c6525f95 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 20 Jun 2019 10:57:27 +0200 Subject: [PATCH] screen-share: move damage calculation after screen resize Calculate damage region after resizing the cache image. This avoids unnecessary calculation of damaged regions on resize, makes sure that the whole screen is considered damaged on resize and simplifies error handling. Signed-off-by: Stefan Agner --- compositor/screen-share.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/compositor/screen-share.c b/compositor/screen-share.c index 31020467..b65f8411 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -822,22 +822,6 @@ shared_output_repainted(struct wl_listener *listener, void *data) pixman_box32_t *r; uint32_t *cache_data; - /* Damage in output coordinates */ - pixman_region32_init(&damage); - pixman_region32_intersect(&damage, &so->output->region, - &so->output->previous_damage); - pixman_region32_translate(&damage, -so->output->x, -so->output->y); - - /* Apply damage to all buffers */ - wl_list_for_each(sb, &so->shm.buffers, link) - pixman_region32_union(&sb->damage, &sb->damage, &damage); - - /* Transform to buffer coordinates */ - weston_transformed_region(so->output->width, so->output->height, - so->output->transform, - so->output->current_scale, - &damage, &damage); - width = so->output->current_mode->width; height = so->output->current_mode->height; stride = width; @@ -853,12 +837,27 @@ shared_output_repainted(struct wl_listener *listener, void *data) width, height, NULL, stride); if (!so->cache_image) - goto err_pixman_init; + goto err_shared_output; - pixman_region32_fini(&damage); pixman_region32_init_rect(&damage, 0, 0, width, height); + } else { + /* Damage in output coordinates */ + pixman_region32_init(&damage); + pixman_region32_intersect(&damage, &so->output->region, + &so->output->previous_damage); + pixman_region32_translate(&damage, -so->output->x, -so->output->y); } + /* Apply damage to all buffers */ + wl_list_for_each(sb, &so->shm.buffers, link) + pixman_region32_union(&sb->damage, &sb->damage, &damage); + + /* Transform to buffer coordinates */ + weston_transformed_region(so->output->width, so->output->height, + so->output->transform, + so->output->current_scale, + &damage, &damage); + if (shared_output_ensure_tmp_data(so, &damage) < 0) goto err_pixman_init; @@ -899,6 +898,7 @@ shared_output_repainted(struct wl_listener *listener, void *data) err_pixman_init: pixman_region32_fini(&damage); +err_shared_output: shared_output_destroy(so); }