diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 29014ffa7..7a3f2e001 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -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; diff --git a/libweston/compositor.c b/libweston/compositor.c index af245cb48..192af8df4 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -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); } }