backend: invert color and dim doesn't need reg_op
We only ever invert color of or dim the entire image, so just remove the ability to do region based inversion and dimming. Making implementing image_op easier. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
60c10790d7
commit
6ff0facae6
|
@ -203,14 +203,12 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
®_bound_local);
|
®_bound_local);
|
||||||
|
|
||||||
// A region covers the entire window
|
// A region covers the entire window
|
||||||
region_t reg_win;
|
|
||||||
pixman_region32_init_rect(®_win, 0, 0, w->g.width, w->g.height);
|
|
||||||
auto new_img = ps->backend_data->ops->copy(
|
auto new_img = ps->backend_data->ops->copy(
|
||||||
ps->backend_data, w->win_image, ®_visible_local);
|
ps->backend_data, w->win_image, ®_visible_local);
|
||||||
if (w->invert_color) {
|
if (w->invert_color) {
|
||||||
ps->backend_data->ops->image_op(
|
ps->backend_data->ops->image_op(
|
||||||
ps->backend_data, IMAGE_OP_INVERT_COLOR, new_img,
|
ps->backend_data, IMAGE_OP_INVERT_COLOR_ALL, new_img,
|
||||||
®_win, ®_visible_local, NULL);
|
NULL, ®_visible_local, NULL);
|
||||||
}
|
}
|
||||||
if (w->dim) {
|
if (w->dim) {
|
||||||
double dim_opacity = ps->o.inactive_dim;
|
double dim_opacity = ps->o.inactive_dim;
|
||||||
|
@ -218,7 +216,7 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
dim_opacity *= w->opacity;
|
dim_opacity *= w->opacity;
|
||||||
}
|
}
|
||||||
ps->backend_data->ops->image_op(
|
ps->backend_data->ops->image_op(
|
||||||
ps->backend_data, IMAGE_OP_DIM, new_img, ®_win,
|
ps->backend_data, IMAGE_OP_DIM_ALL, new_img, NULL,
|
||||||
®_visible_local, (double[]){dim_opacity});
|
®_visible_local, (double[]){dim_opacity});
|
||||||
}
|
}
|
||||||
if (w->frame_opacity != 1) {
|
if (w->frame_opacity != 1) {
|
||||||
|
@ -236,7 +234,6 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
ps->backend_data->ops->compose(ps->backend_data, new_img, w->g.x,
|
ps->backend_data->ops->compose(ps->backend_data, new_img, w->g.x,
|
||||||
w->g.y, ®_paint, ®_visible);
|
w->g.y, ®_paint, ®_visible);
|
||||||
ps->backend_data->ops->release_image(ps->backend_data, new_img);
|
ps->backend_data->ops->release_image(ps->backend_data, new_img);
|
||||||
pixman_region32_fini(®_win);
|
|
||||||
pixman_region32_fini(®_visible_local);
|
pixman_region32_fini(®_visible_local);
|
||||||
pixman_region32_fini(®_bound_local);
|
pixman_region32_fini(®_bound_local);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@ typedef struct backend_base {
|
||||||
} backend_t;
|
} backend_t;
|
||||||
|
|
||||||
enum image_operations {
|
enum image_operations {
|
||||||
// Invert the color of the image
|
// Invert the color of the entire image, `reg_op` ignored
|
||||||
IMAGE_OP_INVERT_COLOR,
|
IMAGE_OP_INVERT_COLOR_ALL,
|
||||||
// Dim the image, argument is the percentage
|
// Dim the entire image, argument is the percentage. `reg_op` ignored
|
||||||
IMAGE_OP_DIM,
|
IMAGE_OP_DIM_ALL,
|
||||||
// Multiply the alpha channel by the argument
|
// Multiply the alpha channel by the argument
|
||||||
IMAGE_OP_APPLY_ALPHA,
|
IMAGE_OP_APPLY_ALPHA,
|
||||||
// Same as APPLY_ALPHA, but `reg_op` is ignored and the operation applies to the
|
// Same as APPLY_ALPHA, but `reg_op` is ignored and the operation applies to the
|
||||||
|
|
|
@ -351,15 +351,10 @@ static bool image_op(backend_t *base, enum image_operations op, void *image,
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_init(®);
|
pixman_region32_init(®);
|
||||||
pixman_region32_intersect(®, (region_t *)reg_op, (region_t *)reg_visible);
|
|
||||||
if (!pixman_region32_not_empty(®)) {
|
|
||||||
pixman_region32_fini(®);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case IMAGE_OP_INVERT_COLOR:
|
case IMAGE_OP_INVERT_COLOR_ALL:
|
||||||
x_set_picture_clip_region(base->c, img->pict, 0, 0, ®);
|
x_set_picture_clip_region(base->c, img->pict, 0, 0, reg_visible);
|
||||||
if (img->has_alpha) {
|
if (img->has_alpha) {
|
||||||
auto tmp_pict =
|
auto tmp_pict =
|
||||||
x_create_picture_with_visual(base->c, base->root, img->width,
|
x_create_picture_with_visual(base->c, base->root, img->width,
|
||||||
|
@ -383,8 +378,8 @@ static bool image_op(backend_t *base, enum image_operations op, void *image,
|
||||||
0, 0, 0, 0, img->width, img->height);
|
0, 0, 0, 0, img->width, img->height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IMAGE_OP_DIM:
|
case IMAGE_OP_DIM_ALL:
|
||||||
x_set_picture_clip_region(base->c, img->pict, 0, 0, ®);
|
x_set_picture_clip_region(base->c, img->pict, 0, 0, reg_visible);
|
||||||
dim_opacity = *(double *)arg;
|
dim_opacity = *(double *)arg;
|
||||||
|
|
||||||
xcb_render_color_t color = {
|
xcb_render_color_t color = {
|
||||||
|
@ -402,6 +397,12 @@ static bool image_op(backend_t *base, enum image_operations op, void *image,
|
||||||
color, 1, &rect);
|
color, 1, &rect);
|
||||||
break;
|
break;
|
||||||
case IMAGE_OP_APPLY_ALPHA:
|
case IMAGE_OP_APPLY_ALPHA:
|
||||||
|
assert(reg_op);
|
||||||
|
pixman_region32_intersect(®, (region_t *)reg_op, (region_t *)reg_visible);
|
||||||
|
if (!pixman_region32_not_empty(®)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
alpha_multiplier = *(double *)arg;
|
alpha_multiplier = *(double *)arg;
|
||||||
if (alpha_multiplier == 1) {
|
if (alpha_multiplier == 1) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue