From ff246a2dc8706efbab0abccdbbabb439aeadb135 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 6 Feb 2023 11:50:00 +0100 Subject: [PATCH] clutter/frame: Add API to query minimal render time of a frame It will be used to schedule Wayland frame events independently from both update and presentation time, as the former may happen multiple times frame and the later not at all. For frame events we want a timing that is just late enough to ensure that a following commit by a Wayland client will not get included into the current frame any more. Part-of: --- clutter/clutter/clutter-frame-clock.c | 10 ++++++++-- clutter/clutter/clutter-frame-private.h | 1 + clutter/clutter/clutter-frame.c | 15 +++++++++++++++ clutter/clutter/clutter-frame.h | 4 ++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index eeba108e1..3aeb29042 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -79,6 +79,7 @@ struct _ClutterFrameClock gboolean is_next_presentation_time_valid; int64_t next_presentation_time_us; + int64_t min_render_time_allowed_us; /* Buffer must be submitted to KMS and GPU rendering must be finished * this amount of time before the next presentation time. @@ -466,7 +467,8 @@ clutter_frame_clock_compute_max_render_time_us (ClutterFrameClock *frame_clock) static void calculate_next_update_time_us (ClutterFrameClock *frame_clock, int64_t *out_next_update_time_us, - int64_t *out_next_presentation_time_us) + int64_t *out_next_presentation_time_us, + int64_t *out_min_render_time_allowed_us) { int64_t last_presentation_time_us; int64_t now_us; @@ -489,6 +491,7 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock, now_us; *out_next_presentation_time_us = 0; + *out_min_render_time_allowed_us = 0; return; } @@ -613,6 +616,7 @@ calculate_next_update_time_us (ClutterFrameClock *frame_clock, *out_next_update_time_us = next_update_time_us; *out_next_presentation_time_us = next_presentation_time_us; + *out_min_render_time_allowed_us = min_render_time_allowed_us; } void @@ -704,7 +708,8 @@ clutter_frame_clock_schedule_update (ClutterFrameClock *frame_clock) case CLUTTER_FRAME_CLOCK_STATE_IDLE: calculate_next_update_time_us (frame_clock, &next_update_time_us, - &frame_clock->next_presentation_time_us); + &frame_clock->next_presentation_time_us, + &frame_clock->min_render_time_allowed_us); frame_clock->is_next_presentation_time_valid = (frame_clock->next_presentation_time_us != 0); break; @@ -775,6 +780,7 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock, frame->frame_count = frame_count; frame->has_target_presentation_time = frame_clock->is_next_presentation_time_valid; frame->target_presentation_time_us = frame_clock->next_presentation_time_us; + frame->min_render_time_allowed_us = frame_clock->min_render_time_allowed_us; COGL_TRACE_BEGIN (ClutterFrameClockEvents, "Frame Clock (before frame)"); if (iface->before_frame) diff --git a/clutter/clutter/clutter-frame-private.h b/clutter/clutter/clutter-frame-private.h index 41dc9b3b7..1eceb8bc0 100644 --- a/clutter/clutter/clutter-frame-private.h +++ b/clutter/clutter/clutter-frame-private.h @@ -31,6 +31,7 @@ struct _ClutterFrame gboolean has_target_presentation_time; int64_t target_presentation_time_us; + int64_t min_render_time_allowed_us; gboolean has_result; ClutterFrameResult result; diff --git a/clutter/clutter/clutter-frame.c b/clutter/clutter/clutter-frame.c index 98088d716..85baef274 100644 --- a/clutter/clutter/clutter-frame.c +++ b/clutter/clutter/clutter-frame.c @@ -75,6 +75,21 @@ clutter_frame_get_target_presentation_time (ClutterFrame *frame, } } +gboolean +clutter_frame_get_min_render_time_allowed (ClutterFrame *frame, + int64_t *min_render_time_allowed_us) +{ + if (frame->has_target_presentation_time) + { + *min_render_time_allowed_us = frame->min_render_time_allowed_us; + return TRUE; + } + else + { + return FALSE; + } +} + ClutterFrameResult clutter_frame_get_result (ClutterFrame *frame) { diff --git a/clutter/clutter/clutter-frame.h b/clutter/clutter/clutter-frame.h index 1837816c3..6bac3f4e4 100644 --- a/clutter/clutter/clutter-frame.h +++ b/clutter/clutter/clutter-frame.h @@ -44,6 +44,10 @@ CLUTTER_EXPORT gboolean clutter_frame_get_target_presentation_time (ClutterFrame *frame, int64_t *target_presentation_time_us); +CLUTTER_EXPORT +gboolean clutter_frame_get_min_render_time_allowed (ClutterFrame *frame, + int64_t *min_render_time_allowed_us); + CLUTTER_EXPORT void clutter_frame_set_result (ClutterFrame *frame, ClutterFrameResult result);