diff --git a/cogl/cogl/cogl-frame-info-private.h b/cogl/cogl/cogl-frame-info-private.h index 1c8fdc5cf..784965afd 100644 --- a/cogl/cogl/cogl-frame-info-private.h +++ b/cogl/cogl/cogl-frame-info-private.h @@ -38,6 +38,8 @@ typedef enum _CoglFrameInfoFlag { COGL_FRAME_INFO_FLAG_NONE = 0, COGL_FRAME_INFO_FLAG_SYMBOLIC = 1 << 0, + /* presentation_time timestamp was provided by the hardware */ + COGL_FRAME_INFO_FLAG_HW_CLOCK = 1 << 1, } CoglFrameInfoFlag; struct _CoglFrameInfo diff --git a/cogl/cogl/cogl-frame-info.c b/cogl/cogl/cogl-frame-info.c index c4547d086..ab64854f7 100644 --- a/cogl/cogl/cogl-frame-info.c +++ b/cogl/cogl/cogl-frame-info.c @@ -88,3 +88,9 @@ cogl_frame_info_get_is_symbolic (CoglFrameInfo *info) { return !!(info->flags & COGL_FRAME_INFO_FLAG_SYMBOLIC); } + +gboolean +cogl_frame_info_is_hw_clock (CoglFrameInfo *info) +{ + return !!(info->flags & COGL_FRAME_INFO_FLAG_HW_CLOCK); +} diff --git a/cogl/cogl/cogl-frame-info.h b/cogl/cogl/cogl-frame-info.h index e2f9ff3bd..7413f01e6 100644 --- a/cogl/cogl/cogl-frame-info.h +++ b/cogl/cogl/cogl-frame-info.h @@ -140,6 +140,9 @@ int64_t cogl_frame_info_get_global_frame_counter (CoglFrameInfo *info); COGL_EXPORT gboolean cogl_frame_info_get_is_symbolic (CoglFrameInfo *info); +COGL_EXPORT +gboolean cogl_frame_info_is_hw_clock (CoglFrameInfo *info); + G_END_DECLS #endif /* __COGL_FRAME_INFO_H */ diff --git a/cogl/cogl/winsys/cogl-onscreen-glx.c b/cogl/cogl/winsys/cogl-onscreen-glx.c index dd33f622c..6fbf7126e 100644 --- a/cogl/cogl/winsys/cogl-onscreen-glx.c +++ b/cogl/cogl/winsys/cogl-onscreen-glx.c @@ -485,6 +485,7 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen) info->presentation_time = ust_to_nanoseconds (ctx->display->renderer, drawable, ust); + info->flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK; } else { @@ -978,6 +979,7 @@ cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen *onscreen, ust_to_nanoseconds (context->display->renderer, onscreen_glx->glxwin, swap_event->ust); + info->flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK; } set_complete_pending (onscreen); diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index b0230d453..b37a3e581 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -167,9 +167,10 @@ meta_onscreen_native_swap_drm_fb (CoglOnscreen *onscreen) } static void -maybe_update_frame_info (MetaCrtc *crtc, - CoglFrameInfo *frame_info, - int64_t time_ns) +maybe_update_frame_info (MetaCrtc *crtc, + CoglFrameInfo *frame_info, + int64_t time_ns, + CoglFrameInfoFlag flags) { const MetaCrtcConfig *crtc_config; const MetaCrtcModeInfo *crtc_mode_info; @@ -187,6 +188,7 @@ maybe_update_frame_info (MetaCrtc *crtc, { frame_info->presentation_time = time_ns; frame_info->refresh_rate = refresh_rate; + frame_info->flags |= flags; } } @@ -207,7 +209,8 @@ meta_onscreen_native_notify_frame_complete (CoglOnscreen *onscreen) static void notify_view_crtc_presented (MetaRendererView *view, MetaKmsCrtc *kms_crtc, - int64_t time_ns) + int64_t time_ns, + CoglFrameInfoFlag flags) { ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view); CoglFramebuffer *framebuffer = @@ -222,7 +225,7 @@ notify_view_crtc_presented (MetaRendererView *view, frame_info = cogl_onscreen_peek_head_frame_info (onscreen); crtc = META_CRTC (meta_crtc_kms_from_kms_crtc (kms_crtc)); - maybe_update_frame_info (crtc, frame_info, time_ns); + maybe_update_frame_info (crtc, frame_info, time_ns, flags); meta_onscreen_native_notify_frame_complete (onscreen); @@ -266,7 +269,8 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc, }; notify_view_crtc_presented (view, kms_crtc, - timeval_to_nanoseconds (&page_flip_time)); + timeval_to_nanoseconds (&page_flip_time), + COGL_FRAME_INFO_FLAG_HW_CLOCK); } static void @@ -303,7 +307,7 @@ page_flip_feedback_mode_set_fallback (MetaKmsCrtc *kms_crtc, gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (crtc)); now_ns = meta_gpu_kms_get_current_time_ns (gpu_kms); - notify_view_crtc_presented (view, kms_crtc, now_ns); + notify_view_crtc_presented (view, kms_crtc, now_ns, COGL_FRAME_INFO_FLAG_NONE); } static void @@ -331,7 +335,7 @@ page_flip_feedback_discarded (MetaKmsCrtc *kms_crtc, gpu_kms = META_GPU_KMS (meta_crtc_get_gpu (crtc)); now_ns = meta_gpu_kms_get_current_time_ns (gpu_kms); - notify_view_crtc_presented (view, kms_crtc, now_ns); + notify_view_crtc_presented (view, kms_crtc, now_ns, COGL_FRAME_INFO_FLAG_NONE); } static const MetaKmsPageFlipListenerVtable page_flip_listener_vtable = {