backend: fix rendering shadow with opacity

Shadow opacity should be multiplied with the window's opacity.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2019-03-10 19:56:55 +00:00
parent 0bd08f4ab4
commit 9296706f7b
2 changed files with 25 additions and 19 deletions

View File

@ -134,9 +134,21 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
}
assert(w->shadow_image);
ps->backend_data->ops->compose(
ps->backend_data, w->shadow_image, w->g.x + w->shadow_dx,
w->g.y + w->shadow_dy, &reg_shadow, &reg_visible);
if (w->opacity == 1) {
ps->backend_data->ops->compose(
ps->backend_data, w->shadow_image, w->g.x + w->shadow_dx,
w->g.y + w->shadow_dy, &reg_shadow, &reg_visible);
} else {
auto new_img = ps->backend_data->ops->copy(
ps->backend_data, w->shadow_image, &reg_visible);
ps->backend_data->ops->image_op(
ps->backend_data, IMAGE_OP_APPLY_ALPHA_ALL, new_img,
NULL, &reg_visible, (double[]){w->opacity});
ps->backend_data->ops->compose(
ps->backend_data, new_img, w->g.x + w->shadow_dx,
w->g.y + w->shadow_dy, &reg_shadow, &reg_visible);
ps->backend_data->ops->release_image(ps->backend_data, new_img);
}
pixman_region32_fini(&reg_shadow);
}
@ -244,8 +256,7 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
if (ps->o.monitor_repaint) {
reg_damage = get_damage(ps, false);
ps->backend_data->ops->fill(
ps->backend_data, 0.5, 0, 0, 0.5, &reg_damage);
ps->backend_data->ops->fill(ps->backend_data, 0.5, 0, 0, 0.5, &reg_damage);
pixman_region32_fini(&reg_damage);
}