From e3b93a4f84698c9618e7f96ec54587af47a0c0d9 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 26 Jul 2019 18:28:22 +0100 Subject: [PATCH] Additional blur artifact fix There were still some artifacts left when multiple semi-transparent windows are stacked on top of each other. Signed-off-by: Yuxuan Shui --- src/backend/backend.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/backend/backend.c b/src/backend/backend.c index 054f192..8351556 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -77,21 +77,29 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { int blur_width, blur_height; ps->backend_data->ops->get_blur_size(ps->backend_blur_context, &blur_width, &blur_height); + + // The region of screen a given window influences will be smeared + // out by blur. With more windows on top of the given window, the + // influences region will be smeared out more. + // + // Also, blurring requires data slightly outside the area that needs + // to be blurred. The more semi-transparent windows are stacked on top + // of each other, the larger the area will be. + // + // Instead of accurately calculate how much bigger the damage + // region will be because of blur, we assume the worst case here. + // That is, the damaged window is at the bottom of the stack, and + // all other windows have semi-transparent background + int resize_factor = 1; if (t) { - // The region of screen a given window influences will be smeared - // out by blur. With more windows on top of the given window, the - // influences region will be smeared out more. - // - // Instead of accurately calculate how much bigger the damage - // region will be because of blur, we assume the worst case here. - // That is, the damaged window is at the bottom of the stack, and - // all other windows have semi-transparent background - resize_region_in_place(®_damage, blur_width * t->stacking_rank, - blur_height * t->stacking_rank); - pixman_region32_intersect(®_damage, ®_damage, &ps->screen_reg); + resize_factor = t->stacking_rank; } - reg_paint = resize_region(®_damage, blur_width, blur_height); + resize_region_in_place(®_damage, blur_width * resize_factor, + blur_height * resize_factor); + reg_paint = resize_region(®_damage, blur_width * resize_factor, + blur_height * resize_factor); pixman_region32_intersect(®_paint, ®_paint, &ps->screen_reg); + pixman_region32_intersect(®_damage, ®_damage, &ps->screen_reg); } else { pixman_region32_init(®_paint); pixman_region32_copy(®_paint, ®_damage);