compositor: Don't return repaint times in the past

If we're late to present, just return the current time instead of a time in
the past.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2025-12-12 10:37:26 -06:00
parent 75f2ec4747
commit 2dce06179f
2 changed files with 11 additions and 3 deletions

View file

@ -3862,6 +3862,7 @@ out:
/** Calculate when we should start a repaint to hit a presentation time
*
* \param output The output
* \param now The current time from the presentation clock
* \param present_time The target presentation time
*
* Using the specified output's refresh rate and configuration, calculate
@ -3872,15 +3873,20 @@ out:
*/
struct timespec
weston_output_repaint_from_present(const struct weston_output *output,
const struct timespec *now,
const struct timespec *present_time)
{
struct timespec repaint_time;
bool late = false;
if (timespec_sub_to_nsec(now, present_time) > 0)
late = true;
if (output->frame_flags & WESTON_FINISH_FRAME_TEARING)
return *present_time;
return late ? *now : *present_time;
if (output->vrr_mode == WESTON_VRR_MODE_GAME)
return *present_time;
return late ? *now : *present_time;
timespec_add_msec(&repaint_time, present_time,
-output->compositor->repaint_msec);
@ -4250,7 +4256,8 @@ weston_output_finish_frame(struct weston_output *output,
refresh_nsec);
out:
output->next_repaint = weston_output_repaint_from_present(output, &output->next_present);
output->next_repaint = weston_output_repaint_from_present(output, &now,
&output->next_present);
output->repaint_status = REPAINT_SCHEDULED;
output_repaint_timer_arm(compositor);
}

View file

@ -871,5 +871,6 @@ weston_compositor_apply_transactions(struct weston_compositor *compositor);
struct timespec
weston_output_repaint_from_present(const struct weston_output *output,
const struct timespec *now,
const struct timespec *present_time);
#endif