mirror of
https://github.com/yshui/picom.git
synced 2025-04-14 17:53:25 -04:00
renderer/layout: add a shadow_opacity per layer property
Prepare for making shadow opacity animatable. Also fix the fact that shadows aren't been rendered with the correct opacity currently. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
a5813b5693
commit
2328d3efd7
7 changed files with 11 additions and 7 deletions
|
@ -1012,9 +1012,6 @@ static bool paint_preprocess(session_t *ps, bool *fade_running, bool *animation,
|
|||
log_trace("|- will be painted");
|
||||
log_verbose("Window %#010x (%s) will be painted", w->base.id, w->name);
|
||||
|
||||
// Calculate shadow opacity
|
||||
w->shadow_opacity = ps->o.shadow_opacity * window_opacity * ps->o.frame_opacity;
|
||||
|
||||
// Generate ignore region for painting to reduce GPU load
|
||||
if (!w->reg_ignore) {
|
||||
w->reg_ignore = rc_region_ref(last_reg_ignore);
|
||||
|
|
|
@ -808,8 +808,10 @@ win_paint_shadow(session_t *ps, struct managed_win *w, region_t *reg_paint) {
|
|||
.x = -(w->shadow_dx),
|
||||
.y = -(w->shadow_dy),
|
||||
};
|
||||
double shadow_opacity =
|
||||
animatable_get(&w->opacity) * ps->o.shadow_opacity * ps->o.frame_opacity;
|
||||
render(ps, 0, 0, w->g.x + w->shadow_dx, w->g.y + w->shadow_dy, w->shadow_width,
|
||||
w->shadow_height, w->widthb, w->heightb, w->shadow_opacity, true, false, 0,
|
||||
w->shadow_height, w->widthb, w->heightb, shadow_opacity, true, false, 0,
|
||||
w->shadow_paint.pict, w->shadow_paint.ptex, reg_paint, NULL,
|
||||
should_clip ? &clip : NULL);
|
||||
if (td) {
|
||||
|
|
|
@ -155,7 +155,7 @@ command_for_shadow(struct layer *layer, struct backend_command *cmd,
|
|||
}
|
||||
log_region(TRACE, &cmd->mask.region);
|
||||
cmd->blit = (struct backend_blit_args){
|
||||
.opacity = layer->opacity,
|
||||
.opacity = layer->shadow_opacity,
|
||||
.max_brightness = 1,
|
||||
.mask = &cmd->mask,
|
||||
.effective_size = layer->shadow_size,
|
||||
|
|
|
@ -64,6 +64,8 @@ static bool layer_from_window(struct layer *out_layer, struct managed_win *w, iv
|
|||
|
||||
out_layer->opacity = (float)animatable_get(&w->opacity);
|
||||
out_layer->blur_opacity = (float)animatable_get(&w->blur_opacity);
|
||||
out_layer->shadow_opacity =
|
||||
(float)(out_layer->opacity * w->shadow_opacity * w->frame_opacity);
|
||||
if (out_layer->opacity == 0 && out_layer->blur_opacity == 0) {
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ struct layer {
|
|||
float opacity;
|
||||
/// Opacity of the background blur of this window
|
||||
float blur_opacity;
|
||||
/// Opacity of this window's shadow
|
||||
float shadow_opacity;
|
||||
|
||||
/// How many commands are needed to render this layer
|
||||
unsigned number_of_commands;
|
||||
|
|
|
@ -1590,7 +1590,6 @@ struct win *attr_ret_nonnull maybe_allocate_managed_win(session_t *ps, struct wi
|
|||
// No need to initialize. (or, you can think that
|
||||
// they are initialized right here).
|
||||
// The following ones are updated during paint or paint preprocess
|
||||
.shadow_opacity = 0.0,
|
||||
.to_paint = false,
|
||||
.frame_opacity = 1.0,
|
||||
.dim = false,
|
||||
|
@ -1727,6 +1726,7 @@ struct win *attr_ret_nonnull maybe_allocate_managed_win(session_t *ps, struct wi
|
|||
new->a = *a;
|
||||
new->opacity = animatable_new(0);
|
||||
new->blur_opacity = animatable_new(0);
|
||||
new->shadow_opacity = ps->o.shadow_opacity;
|
||||
pixman_region32_init(&new->bounding_shape);
|
||||
|
||||
free(a);
|
||||
|
|
|
@ -253,7 +253,8 @@ struct managed_win {
|
|||
bool shadow;
|
||||
/// Override value of window shadow state. Set by D-Bus method calls.
|
||||
switch_t shadow_force;
|
||||
/// Opacity of the shadow. Affected by window opacity and frame opacity.
|
||||
/// Window specific shadow factor. The final shadow opacity is a combination of
|
||||
/// this, the window opacity, and the window frame opacity.
|
||||
double shadow_opacity;
|
||||
/// X offset of shadow. Affected by command line argument.
|
||||
int shadow_dx;
|
||||
|
|
Loading…
Add table
Reference in a new issue