opt: optimize layer animaiton frame count in multi monitor

This commit is contained in:
DreamMaoMao 2025-09-07 17:48:29 +08:00
parent cd3689d557
commit f712917159
4 changed files with 10 additions and 6 deletions

View file

@ -820,7 +820,7 @@ void init_fadeout_client(Client *c) {
fadeout_cient->animation.passed_frames = 0; fadeout_cient->animation.passed_frames = 0;
fadeout_cient->animation.total_frames = fadeout_cient->animation.total_frames =
fadeout_cient->animation.duration / output_frame_duration_ms(); fadeout_cient->animation.duration / all_output_frame_duration_ms();
wlr_scene_node_set_enabled(&fadeout_cient->scene->node, true); wlr_scene_node_set_enabled(&fadeout_cient->scene->node, true);
wl_list_insert(&fadeout_clients, &fadeout_cient->fadeout_link); wl_list_insert(&fadeout_clients, &fadeout_cient->fadeout_link);
@ -840,7 +840,7 @@ void client_commit(Client *c) {
// 设置动画速度 // 设置动画速度
c->animation.passed_frames = 0; c->animation.passed_frames = 0;
c->animation.total_frames = c->animation.total_frames =
c->animation.duration / output_frame_duration_ms(); c->animation.duration / all_output_frame_duration_ms();
// 标记动画开始 // 标记动画开始
c->animation.running = true; c->animation.running = true;

View file

@ -76,7 +76,7 @@ double find_animation_curve_at(double t, int type) {
return baked_points[up].y; return baked_points[up].y;
} }
double output_frame_duration_ms() { double all_output_frame_duration_ms() {
int32_t refresh_total = 0; int32_t refresh_total = 0;
Monitor *m; Monitor *m;
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
@ -88,6 +88,10 @@ double output_frame_duration_ms() {
return 1000000.0 / refresh_total; return 1000000.0 / refresh_total;
} }
double output_frame_duration_ms(Monitor *m) {
return 1000000.0 / m->wlr_output->refresh;
}
static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly, static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
struct wlr_scene_tree *snapshot_tree) { struct wlr_scene_tree *snapshot_tree) {
if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) { if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {

View file

@ -445,7 +445,7 @@ void init_fadeout_layers(LayerSurface *l) {
// 计算动画帧数 // 计算动画帧数
fadeout_layer->animation.passed_frames = 0; fadeout_layer->animation.passed_frames = 0;
fadeout_layer->animation.total_frames = fadeout_layer->animation.total_frames =
fadeout_layer->animation.duration / output_frame_duration_ms(); fadeout_layer->animation.duration / all_output_frame_duration_ms();
// 将节点插入到关闭动画链表中,屏幕刷新哪里会检查链表中是否有节点可以应用于动画 // 将节点插入到关闭动画链表中,屏幕刷新哪里会检查链表中是否有节点可以应用于动画
wlr_scene_node_set_enabled(&fadeout_layer->scene->node, true); wlr_scene_node_set_enabled(&fadeout_layer->scene->node, true);
@ -531,7 +531,7 @@ void layer_commit(LayerSurface *l) {
// 设置动画速度 // 设置动画速度
l->animation.passed_frames = 0; l->animation.passed_frames = 0;
l->animation.total_frames = l->animation.total_frames =
l->animation.duration / output_frame_duration_ms(); l->animation.duration / output_frame_duration_ms(l->mon);
// 标记动画开始 // 标记动画开始
l->animation.running = true; l->animation.running = true;

View file

@ -684,7 +684,7 @@ static double find_animation_curve_at(double t, int type);
static void apply_opacity_to_rect_nodes(Client *c, struct wlr_scene_node *node, static void apply_opacity_to_rect_nodes(Client *c, struct wlr_scene_node *node,
double animation_passed); double animation_passed);
static enum corner_location set_client_corner_location(Client *c); static enum corner_location set_client_corner_location(Client *c);
static double output_frame_duration_ms(); static double all_output_frame_duration_ms();
static struct wlr_scene_tree * static struct wlr_scene_tree *
wlr_scene_tree_snapshot(struct wlr_scene_node *node, wlr_scene_tree_snapshot(struct wlr_scene_node *node,
struct wlr_scene_tree *parent); struct wlr_scene_tree *parent);