From 72bb0857730483a2ee8b53c59469762bf116db7d Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Mon, 8 Sep 2025 08:21:01 +0800 Subject: [PATCH] opt: optimize frame count when total_frame is 0 --- src/animation/client.h | 8 ++++++-- src/animation/layer.h | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/animation/client.h b/src/animation/client.h index f4c0713..7b825a7 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -492,7 +492,9 @@ void fadeout_client_animation_next_tick(Client *c) { BufferData buffer_data; double animation_passed = - (double)c->animation.passed_frames / c->animation.total_frames; + c->animation.total_frames + ? (double)c->animation.passed_frames / c->animation.total_frames + : 1.0; int type = c->animation.action = c->animation.action; double factor = find_animation_curve_at(animation_passed, type); unsigned int width = @@ -548,7 +550,9 @@ void fadeout_client_animation_next_tick(Client *c) { void client_animation_next_tick(Client *c) { double animation_passed = - (double)c->animation.passed_frames / c->animation.total_frames; + c->animation.total_frames + ? (double)c->animation.passed_frames / c->animation.total_frames + : 1.0; int type = c->animation.action == NONE ? MOVE : c->animation.action; double factor = find_animation_curve_at(animation_passed, type); diff --git a/src/animation/layer.h b/src/animation/layer.h index 921fac8..3b3a73a 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -186,7 +186,9 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) { return; double animation_passed = - (double)l->animation.passed_frames / l->animation.total_frames; + l->animation.total_frames + ? (double)l->animation.passed_frames / l->animation.total_frames + : 1.0; int type = l->animation.action = l->animation.action; double factor = find_animation_curve_at(animation_passed, type); unsigned int width = @@ -245,7 +247,9 @@ void layer_animation_next_tick(LayerSurface *l) { return; double animation_passed = - (double)l->animation.passed_frames / l->animation.total_frames; + l->animation.total_frames + ? (double)l->animation.passed_frames / l->animation.total_frames + : 1.0; int type = l->animation.action == NONE ? MOVE : l->animation.action; double factor = find_animation_curve_at(animation_passed, type);