opt: optimize client scale offset

This commit is contained in:
DreamMaoMao 2025-07-13 09:11:43 +08:00
parent 7485fa1b7e
commit 80c399fa81

View file

@ -487,7 +487,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
return offset;
}
void client_apply_clip(Client *c) {
void client_apply_clip(Client *c, float factor) {
if (c->iskilling || !client_surface(c)->mapped)
return;
@ -590,11 +590,19 @@ void client_apply_clip(Client *c) {
scale_data.should_scale = true;
scale_data.width = clip_box.width;
scale_data.height = clip_box.height;
scale_data.width_scale = (float)scale_data.width / acutal_surface_width;
scale_data.height_scale = (float)scale_data.height / acutal_surface_height;
scale_data.corner_location = current_corner_location;
scale_data.percent = percent;
scale_data.opacity = opacity;
if (factor == 1.0) {
scale_data.width_scale = 1.0;
scale_data.height_scale = 1.0;
} else {
scale_data.width_scale = (float)scale_data.width / acutal_surface_width;
scale_data.height_scale =
(float)scale_data.height / acutal_surface_height;
}
buffer_set_effect(c, scale_data);
}
@ -723,6 +731,8 @@ void client_animation_next_tick(Client *c) {
} else {
c->animation.passed_frames++;
}
client_apply_clip(c, factor);
}
void init_fadeout_client(Client *c) {
@ -1001,13 +1011,12 @@ bool client_draw_frame(Client *c) {
if (animations && c->animation.running) {
client_animation_next_tick(c);
client_apply_clip(c);
} else {
wlr_scene_node_set_position(&c->scene->node, c->pending.x,
c->pending.y);
c->animation.current = c->animainit_geom = c->animation.initial =
c->pending = c->current = c->geom;
client_apply_clip(c);
client_apply_clip(c, 1.0);
c->need_output_flush = false;
}
return true;