mirror of
				https://github.com/DreamMaoMao/maomaowm.git
				synced 2025-11-03 09:01:47 -05:00 
			
		
		
		
	opt: optimize layer animaiton frame count in multi monitor
This commit is contained in:
		
							parent
							
								
									394e32dabd
								
							
						
					
					
						commit
						1e1e37e92d
					
				
					 4 changed files with 10 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -694,7 +694,7 @@ void init_fadeout_client(Client *c) {
 | 
			
		|||
 | 
			
		||||
	fadeout_cient->animation.passed_frames = 0;
 | 
			
		||||
	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);
 | 
			
		||||
	wl_list_insert(&fadeout_clients, &fadeout_cient->fadeout_link);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -714,7 +714,7 @@ void client_commit(Client *c) {
 | 
			
		|||
		// 设置动画速度
 | 
			
		||||
		c->animation.passed_frames = 0;
 | 
			
		||||
		c->animation.total_frames =
 | 
			
		||||
			c->animation.duration / output_frame_duration_ms();
 | 
			
		||||
			c->animation.duration / all_output_frame_duration_ms();
 | 
			
		||||
 | 
			
		||||
		// 标记动画开始
 | 
			
		||||
		c->animation.running = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ double find_animation_curve_at(double t, int type) {
 | 
			
		|||
	return baked_points[up].y;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
double output_frame_duration_ms() {
 | 
			
		||||
double all_output_frame_duration_ms() {
 | 
			
		||||
	int32_t refresh_total = 0;
 | 
			
		||||
	Monitor *m;
 | 
			
		||||
	wl_list_for_each(m, &mons, link) {
 | 
			
		||||
| 
						 | 
				
			
			@ -88,6 +88,10 @@ double output_frame_duration_ms() {
 | 
			
		|||
	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,
 | 
			
		||||
								struct wlr_scene_tree *snapshot_tree) {
 | 
			
		||||
	if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -396,7 +396,7 @@ void init_fadeout_layers(LayerSurface *l) {
 | 
			
		|||
	// 计算动画帧数
 | 
			
		||||
	fadeout_layer->animation.passed_frames = 0;
 | 
			
		||||
	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);
 | 
			
		||||
| 
						 | 
				
			
			@ -482,7 +482,7 @@ void layer_commit(LayerSurface *l) {
 | 
			
		|||
		// 设置动画速度
 | 
			
		||||
		l->animation.passed_frames = 0;
 | 
			
		||||
		l->animation.total_frames =
 | 
			
		||||
			l->animation.duration / output_frame_duration_ms();
 | 
			
		||||
			l->animation.duration / output_frame_duration_ms(l->mon);
 | 
			
		||||
 | 
			
		||||
		// 标记动画开始
 | 
			
		||||
		l->animation.running = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -689,7 +689,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,
 | 
			
		||||
										double animation_passed);
 | 
			
		||||
static double output_frame_duration_ms();
 | 
			
		||||
static double all_output_frame_duration_ms();
 | 
			
		||||
static struct wlr_scene_tree *
 | 
			
		||||
wlr_scene_tree_snapshot(struct wlr_scene_node *node,
 | 
			
		||||
						struct wlr_scene_tree *parent);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue