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 <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-07-26 18:28:22 +01:00
parent 0109fe181e
commit e3b93a4f84
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 20 additions and 12 deletions

View File

@ -77,21 +77,29 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
int blur_width, blur_height; int blur_width, blur_height;
ps->backend_data->ops->get_blur_size(ps->backend_blur_context, ps->backend_data->ops->get_blur_size(ps->backend_blur_context,
&blur_width, &blur_height); &blur_width, &blur_height);
if (t) {
// The region of screen a given window influences will be smeared // The region of screen a given window influences will be smeared
// out by blur. With more windows on top of the given window, the // out by blur. With more windows on top of the given window, the
// influences region will be smeared out more. // 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 // Instead of accurately calculate how much bigger the damage
// region will be because of blur, we assume the worst case here. // 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 // That is, the damaged window is at the bottom of the stack, and
// all other windows have semi-transparent background // all other windows have semi-transparent background
resize_region_in_place(&reg_damage, blur_width * t->stacking_rank, int resize_factor = 1;
blur_height * t->stacking_rank); if (t) {
pixman_region32_intersect(&reg_damage, &reg_damage, &ps->screen_reg); resize_factor = t->stacking_rank;
} }
reg_paint = resize_region(&reg_damage, blur_width, blur_height); resize_region_in_place(&reg_damage, blur_width * resize_factor,
blur_height * resize_factor);
reg_paint = resize_region(&reg_damage, blur_width * resize_factor,
blur_height * resize_factor);
pixman_region32_intersect(&reg_paint, &reg_paint, &ps->screen_reg); pixman_region32_intersect(&reg_paint, &reg_paint, &ps->screen_reg);
pixman_region32_intersect(&reg_damage, &reg_damage, &ps->screen_reg);
} else { } else {
pixman_region32_init(&reg_paint); pixman_region32_init(&reg_paint);
pixman_region32_copy(&reg_paint, &reg_damage); pixman_region32_copy(&reg_paint, &reg_damage);