backend_common: fix shadow generation with opacity

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-03-04 22:58:11 +00:00
parent 3ab4107fda
commit a2ae36c1d6
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
5 changed files with 9 additions and 9 deletions

View File

@ -98,7 +98,7 @@ struct backend_operations {
/// Create a shadow image based on the parameters /// Create a shadow image based on the parameters
void *(*render_shadow)(backend_t *backend_data, int width, int height, void *(*render_shadow)(backend_t *backend_data, int width, int height,
const conv *kernel, double r, double g, double b); const conv *kernel, double r, double g, double b, double a);
// ============ Resource management =========== // ============ Resource management ===========

View File

@ -148,7 +148,7 @@ make_shadow(xcb_connection_t *c, const conv *kernel, double opacity, int width,
// Fill part 3 // Fill part 3
for (int y = r; y < height + r; y++) { for (int y = r; y < height + r; y++) {
memset(data + sstride * y + r, 255, width); memset(data + sstride * y + r, 255 * opacity, width);
} }
// Part 1 // Part 1
@ -257,13 +257,13 @@ shadow_picture_err:
} }
void *default_backend_render_shadow(backend_t *backend_data, int width, int height, void *default_backend_render_shadow(backend_t *backend_data, int width, int height,
const conv *kernel, double r, double g, double b) { const conv *kernel, double r, double g, double b, double a) {
xcb_pixmap_t shadow_pixel = solid_picture(backend_data->c, backend_data->root, xcb_pixmap_t shadow_pixel = solid_picture(backend_data->c, backend_data->root,
true, 1, r, g, b), true, 1, r, g, b),
shadow = XCB_NONE; shadow = XCB_NONE;
xcb_render_picture_t pict = XCB_NONE; xcb_render_picture_t pict = XCB_NONE;
build_shadow(backend_data->c, backend_data->root, 1, width, height, kernel, build_shadow(backend_data->c, backend_data->root, a, width, height, kernel,
shadow_pixel, &shadow, &pict); shadow_pixel, &shadow, &pict);
auto visual = x_get_visual_for_standard(backend_data->c, XCB_PICT_STANDARD_ARGB_32); auto visual = x_get_visual_for_standard(backend_data->c, XCB_PICT_STANDARD_ARGB_32);

View File

@ -32,4 +32,4 @@ bool default_is_win_transparent(void *, win *, void *);
bool default_is_frame_transparent(void *, win *, void *); bool default_is_frame_transparent(void *, win *, void *);
void *default_backend_render_shadow(backend_t *backend_data, int width, int height, void *default_backend_render_shadow(backend_t *backend_data, int width, int height,
const conv *kernel, double r, double g, double b); const conv *kernel, double r, double g, double b, double a);

View File

@ -2010,7 +2010,7 @@ redir_start(session_t *ps) {
ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb,
w->heightb, ps->gaussian_map, w->heightb, ps->gaussian_map,
ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_red, ps->o.shadow_green,
ps->o.shadow_blue); ps->o.shadow_blue, ps->o.shadow_opacity);
} }
} }
} }

View File

@ -632,7 +632,7 @@ void win_on_win_size_change(session_t *ps, win *w) {
w->shadow_image = ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, w->shadow_image = ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb,
w->heightb, ps->gaussian_map, w->heightb, ps->gaussian_map,
ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_red, ps->o.shadow_green,
ps->o.shadow_blue); ps->o.shadow_blue, ps->o.shadow_opacity);
} }
} else { } else {
assert(w->state == WSTATE_UNMAPPED); assert(w->state == WSTATE_UNMAPPED);
@ -1270,7 +1270,7 @@ void win_update_bounding_shape(session_t *ps, win *w) {
w->shadow_image = ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, w->shadow_image = ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb,
w->heightb, ps->gaussian_map, w->heightb, ps->gaussian_map,
ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_red, ps->o.shadow_green,
ps->o.shadow_blue); ps->o.shadow_blue, ps->o.shadow_opacity);
} }
} }
} else { } else {
@ -1661,7 +1661,7 @@ void map_win(session_t *ps, win *w) {
ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb,
w->heightb, ps->gaussian_map, w->heightb, ps->gaussian_map,
ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_red, ps->o.shadow_green,
ps->o.shadow_blue); ps->o.shadow_blue, ps->o.shadow_opacity);
} }
} }
log_debug("Window %#010x has opacity %f, opacity target is %f", w->id, w->opacity, w->opacity_tgt); log_debug("Window %#010x has opacity %f, opacity target is %f", w->id, w->opacity, w->opacity_tgt);