From 80c399fa8177c01347abe847035cab107a379a71 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 13 Jul 2025 09:11:43 +0800 Subject: [PATCH] opt: optimize client scale offset --- src/animation/client.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/animation/client.h b/src/animation/client.h index 46919b5..5fdd5e7 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -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;