compositor: Track repaint time and expected presentation time

For the upcoming commit-timing protocol, we're interested in when a
scheduled repaint will be displayed, so let's keep track of both the
repaint time and the anticipated presentation time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2025-10-07 14:38:07 -05:00
parent d88efaea66
commit f1bcedd089
2 changed files with 15 additions and 2 deletions

View file

@ -433,6 +433,9 @@ struct weston_output {
/** If repaint_status is REPAINT_SCHEDULED, contains the time the
* next repaint should be run */
struct timespec next_repaint;
/** If repaint_statue is REPAINT_SCHEDULED, contains the time the
* next repaint should be displayed */
struct timespec next_present;
/** For cancelling the idle_repaint callback on output destruction. */
struct wl_event_source *idle_repaint_source;

View file

@ -4153,6 +4153,7 @@ weston_output_finish_frame(struct weston_output *output,
* repaint as soon as possible so we can get on with it. */
if (!stamp) {
output->next_repaint = now;
output->next_present = now;
goto out;
}
@ -4175,6 +4176,7 @@ weston_output_finish_frame(struct weston_output *output,
/* If we're tearing just repaint right away */
if (presented_flags & WESTON_FINISH_FRAME_TEARING) {
output->next_repaint = now;
output->next_present = now;
goto out;
}
@ -4187,11 +4189,15 @@ weston_output_finish_frame(struct weston_output *output,
*/
if (output->vrr_mode == WESTON_VRR_MODE_GAME) {
output->next_repaint = now;
/* FIXME: we should figure out if we're in Vactive to give a
* more accurate next_present time?
*/
output->next_present = now;
goto out;
}
timespec_add_nsec(&output->next_repaint, stamp, refresh_nsec);
timespec_add_msec(&output->next_repaint, &output->next_repaint,
timespec_add_nsec(&output->next_present, stamp, refresh_nsec);
timespec_add_msec(&output->next_repaint, &output->next_present,
-compositor->repaint_msec);
msec_rel = timespec_sub_to_msec(&output->next_repaint, &now);
@ -4203,6 +4209,7 @@ weston_output_finish_frame(struct weston_output *output,
output->name, (long long) msec_rel);
output->next_repaint = now;
output->next_present = now;
}
/* Called from restart_repaint_loop and restart happens already after
@ -4215,6 +4222,9 @@ weston_output_finish_frame(struct weston_output *output,
timespec_add_nsec(&output->next_repaint,
&output->next_repaint,
refresh_nsec);
timespec_add_nsec(&output->next_present,
&output->next_present,
refresh_nsec);
}
}