diff --git a/cogl/cogl/cogl-frame-info-private.h b/cogl/cogl/cogl-frame-info-private.h index 675b6da45..81904f7a4 100644 --- a/cogl/cogl/cogl-frame-info-private.h +++ b/cogl/cogl/cogl-frame-info-private.h @@ -48,6 +48,14 @@ typedef enum _CoglFrameInfoFlag * fullscreen surface and a surface on a hardware overlay. */ COGL_FRAME_INFO_FLAG_ZERO_COPY = 1 << 2, + /* + * The presentation was synchronized to the "vertical retrace" by the display + * hardware such that tearing does not happen. Relying on user space + * scheduling is not acceptable for this flag. If presentation is done by a + * copy to the active frontbuffer, then it must guarantee that tearing cannot + * happen. + */ + COGL_FRAME_INFO_FLAG_VSYNC = 1 << 3, } CoglFrameInfoFlag; struct _CoglFrameInfo diff --git a/cogl/cogl/cogl-frame-info.c b/cogl/cogl/cogl-frame-info.c index 24a100bfa..a31d91689 100644 --- a/cogl/cogl/cogl-frame-info.c +++ b/cogl/cogl/cogl-frame-info.c @@ -101,6 +101,12 @@ cogl_frame_info_is_zero_copy (CoglFrameInfo *info) return !!(info->flags & COGL_FRAME_INFO_FLAG_ZERO_COPY); } +gboolean +cogl_frame_info_is_vsync (CoglFrameInfo *info) +{ + return !!(info->flags & COGL_FRAME_INFO_FLAG_VSYNC); +} + unsigned int cogl_frame_info_get_sequence (CoglFrameInfo *info) { diff --git a/cogl/cogl/cogl-frame-info.h b/cogl/cogl/cogl-frame-info.h index 62a9bb0ea..7278a08ca 100644 --- a/cogl/cogl/cogl-frame-info.h +++ b/cogl/cogl/cogl-frame-info.h @@ -144,6 +144,9 @@ gboolean cogl_frame_info_is_hw_clock (CoglFrameInfo *info); COGL_EXPORT gboolean cogl_frame_info_is_zero_copy (CoglFrameInfo *info); +COGL_EXPORT +gboolean cogl_frame_info_is_vsync (CoglFrameInfo *info); + COGL_EXPORT unsigned int cogl_frame_info_get_sequence (CoglFrameInfo *info); diff --git a/cogl/cogl/winsys/cogl-onscreen-glx.c b/cogl/cogl/winsys/cogl-onscreen-glx.c index df8922b5d..8bbb508b7 100644 --- a/cogl/cogl/winsys/cogl-onscreen-glx.c +++ b/cogl/cogl/winsys/cogl-onscreen-glx.c @@ -472,6 +472,7 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen) if (glx_display->can_vblank_wait) { CoglFrameInfo *info = cogl_onscreen_peek_tail_frame_info (onscreen); + info->flags |= COGL_FRAME_INFO_FLAG_VSYNC; if (glx_renderer->glXWaitForMsc) { @@ -987,6 +988,7 @@ cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen *onscreen, set_sync_pending (onscreen); info = cogl_onscreen_peek_head_frame_info (onscreen); + info->flags |= COGL_FRAME_INFO_FLAG_VSYNC; ust_is_monotonic = is_ust_monotonic (context->display->renderer, onscreen_glx->glxwin); diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index a69f31c73..ff2b3a054 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -265,7 +265,7 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc, MetaCrtc *crtc; MetaGpuKms *gpu_kms; int64_t presentation_time_us; - CoglFrameInfoFlag flags = COGL_FRAME_INFO_FLAG_NONE; + CoglFrameInfoFlag flags = COGL_FRAME_INFO_FLAG_VSYNC; page_flip_time = (struct timeval) { .tv_sec = tv_sec,