From e5602062e223c2ed079bc42d4d88b1964c0b9cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 26 Oct 2022 19:45:46 +0200 Subject: [PATCH] cogl/frame: Keep track of target presentation time It's yet to be used for anything, but will later on. Part-of: --- cogl/cogl/cogl-frame-info-private.h | 7 +++++++ cogl/cogl/cogl-frame-info.c | 8 ++++++++ src/backends/meta-stage-impl.c | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/cogl/cogl/cogl-frame-info-private.h b/cogl/cogl/cogl-frame-info-private.h index 2a59288d1..3264ae009 100644 --- a/cogl/cogl/cogl-frame-info-private.h +++ b/cogl/cogl/cogl-frame-info-private.h @@ -78,10 +78,17 @@ struct _CoglFrameInfo CoglTimestampQuery *timestamp_query; int64_t gpu_time_before_buffer_swap_ns; int64_t cpu_time_before_buffer_swap_us; + + gboolean has_target_presentation_time; + int64_t target_presentation_time_us; }; COGL_EXPORT CoglFrameInfo *cogl_frame_info_new (CoglContext *context, int64_t global_frame_counter); +COGL_EXPORT +void cogl_frame_info_set_target_presentation_time (CoglFrameInfo *info, + int64_t presentation_time_us); + #endif /* __COGL_FRAME_INFO_PRIVATE_H */ diff --git a/cogl/cogl/cogl-frame-info.c b/cogl/cogl/cogl-frame-info.c index adaf2bad9..373a2d098 100644 --- a/cogl/cogl/cogl-frame-info.c +++ b/cogl/cogl/cogl-frame-info.c @@ -142,3 +142,11 @@ cogl_frame_info_get_time_before_buffer_swap_us (CoglFrameInfo *info) { return info->cpu_time_before_buffer_swap_us; } + +void +cogl_frame_info_set_target_presentation_time (CoglFrameInfo *info, + int64_t presentation_time_us) +{ + info->has_target_presentation_time = TRUE; + info->target_presentation_time_us = presentation_time_us; +} diff --git a/src/backends/meta-stage-impl.c b/src/backends/meta-stage-impl.c index 816f63fa5..7774393e1 100644 --- a/src/backends/meta-stage-impl.c +++ b/src/backends/meta-stage-impl.c @@ -265,6 +265,7 @@ swap_framebuffer (ClutterStageWindow *stage_window, if (COGL_IS_ONSCREEN (framebuffer)) { CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer); + int64_t target_presentation_time_us; int *damage, n_rects, i; CoglFrameInfo *frame_info; @@ -285,6 +286,13 @@ swap_framebuffer (ClutterStageWindow *stage_window, cogl_frame_info_new (cogl_context, priv->global_frame_counter); priv->global_frame_counter++; + if (clutter_frame_get_target_presentation_time (frame, + &target_presentation_time_us)) + { + cogl_frame_info_set_target_presentation_time (frame_info, + target_presentation_time_us); + } + /* push on the screen */ if (n_rects > 0 && !swap_with_damage) {