mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	output: allow tearing with atomic mode setting
Additionally, track errors and abandon the tearing allowance when it cannot be set for two-seconds' worth of consecutive frames.
This commit is contained in:
		
							parent
							
								
									14d9bbab90
								
							
						
					
					
						commit
						d033a2fbf6
					
				
					 4 changed files with 42 additions and 15 deletions
				
			
		
							
								
								
									
										37
									
								
								src/output.c
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								src/output.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -30,6 +30,14 @@
 | 
			
		|||
#include "view.h"
 | 
			
		||||
#include "xwayland.h"
 | 
			
		||||
 | 
			
		||||
static unsigned int
 | 
			
		||||
get_tearing_retry_count(struct output *output)
 | 
			
		||||
{
 | 
			
		||||
	/* Two seconds worth of frames, guessing 60Hz if refresh is invalid */
 | 
			
		||||
	int refresh = output->wlr_output->refresh;
 | 
			
		||||
	return refresh > 0 ? refresh / 500 : 120;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool
 | 
			
		||||
get_tearing_preference(struct output *output)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -45,6 +53,11 @@ get_tearing_preference(struct output *output)
 | 
			
		|||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Tearing should not have failed too many times */
 | 
			
		||||
	if (output->nr_tearing_failures >= get_tearing_retry_count(output)) {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* If the active view requests tearing, or it is toggled on with action, allow it */
 | 
			
		||||
	return server->active_view->tearing_hint;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -112,11 +125,27 @@ output_frame_notify(struct wl_listener *listener, void *data)
 | 
			
		|||
		 */
 | 
			
		||||
		output_apply_gamma(output);
 | 
			
		||||
	} else {
 | 
			
		||||
		output->pending.tearing_page_flip =
 | 
			
		||||
			get_tearing_preference(output);
 | 
			
		||||
		struct wlr_scene_output *scene_output = output->scene_output;
 | 
			
		||||
		struct wlr_output_state *pending = &output->pending;
 | 
			
		||||
 | 
			
		||||
		lab_wlr_scene_output_commit(output->scene_output,
 | 
			
		||||
			&output->pending);
 | 
			
		||||
		pending->tearing_page_flip = get_tearing_preference(output);
 | 
			
		||||
 | 
			
		||||
		bool committed =
 | 
			
		||||
			lab_wlr_scene_output_commit(scene_output, pending);
 | 
			
		||||
 | 
			
		||||
		if (pending->tearing_page_flip) {
 | 
			
		||||
			if (committed) {
 | 
			
		||||
				output->nr_tearing_failures = 0;
 | 
			
		||||
			} else {
 | 
			
		||||
				if (++output->nr_tearing_failures >=
 | 
			
		||||
						get_tearing_retry_count(output)) {
 | 
			
		||||
					wlr_log(WLR_INFO, "setting tearing allowance failed "
 | 
			
		||||
						"for two consecutive seconds, disabling");
 | 
			
		||||
				}
 | 
			
		||||
				pending->tearing_page_flip = false;
 | 
			
		||||
				lab_wlr_scene_output_commit(scene_output, pending);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	struct timespec now = { 0 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue