mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-20 07:00:09 +01:00
compositor: Pull repaint time calculation out of finish_frame
Make this into a separate functions we can call from other places to get the same results. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
f36a3a91a8
commit
75f2ec4747
2 changed files with 33 additions and 8 deletions
|
|
@ -3859,6 +3859,35 @@ out:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Calculate when we should start a repaint to hit a presentation time
|
||||||
|
*
|
||||||
|
* \param output The output
|
||||||
|
* \param present_time The target presentation time
|
||||||
|
*
|
||||||
|
* Using the specified output's refresh rate and configuration, calculate
|
||||||
|
* the target time to start a repaint to safely hit that presentation
|
||||||
|
* time without being late or early.
|
||||||
|
*
|
||||||
|
* \return The repaint time
|
||||||
|
*/
|
||||||
|
struct timespec
|
||||||
|
weston_output_repaint_from_present(const struct weston_output *output,
|
||||||
|
const struct timespec *present_time)
|
||||||
|
{
|
||||||
|
struct timespec repaint_time;
|
||||||
|
|
||||||
|
if (output->frame_flags & WESTON_FINISH_FRAME_TEARING)
|
||||||
|
return *present_time;
|
||||||
|
|
||||||
|
if (output->vrr_mode == WESTON_VRR_MODE_GAME)
|
||||||
|
return *present_time;
|
||||||
|
|
||||||
|
timespec_add_msec(&repaint_time, present_time,
|
||||||
|
-output->compositor->repaint_msec);
|
||||||
|
|
||||||
|
return repaint_time;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output_repaint_timer_arm(struct weston_compositor *compositor)
|
output_repaint_timer_arm(struct weston_compositor *compositor)
|
||||||
{
|
{
|
||||||
|
|
@ -4221,14 +4250,7 @@ weston_output_finish_frame(struct weston_output *output,
|
||||||
refresh_nsec);
|
refresh_nsec);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (presented_flags & WESTON_FINISH_FRAME_TEARING) {
|
output->next_repaint = weston_output_repaint_from_present(output, &output->next_present);
|
||||||
output->next_repaint = output->next_present;
|
|
||||||
} else if (output->vrr_mode == WESTON_VRR_MODE_GAME) {
|
|
||||||
output->next_repaint = output->next_present;
|
|
||||||
} else {
|
|
||||||
timespec_add_msec(&output->next_repaint, &output->next_present,
|
|
||||||
-compositor->repaint_msec);
|
|
||||||
}
|
|
||||||
output->repaint_status = REPAINT_SCHEDULED;
|
output->repaint_status = REPAINT_SCHEDULED;
|
||||||
output_repaint_timer_arm(compositor);
|
output_repaint_timer_arm(compositor);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -869,4 +869,7 @@ weston_surface_visibility_mask(struct weston_surface *surface);
|
||||||
void
|
void
|
||||||
weston_compositor_apply_transactions(struct weston_compositor *compositor);
|
weston_compositor_apply_transactions(struct weston_compositor *compositor);
|
||||||
|
|
||||||
|
struct timespec
|
||||||
|
weston_output_repaint_from_present(const struct weston_output *output,
|
||||||
|
const struct timespec *present_time);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue