cogl/frame-info: Add sequence

It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
This commit is contained in:
Ivan Molodetskikh 2021-01-30 23:27:50 +03:00 committed by Marge Bot
parent 5d8cb2786b
commit c96fb181ab
5 changed files with 34 additions and 9 deletions

View File

@ -53,6 +53,8 @@ struct _CoglFrameInfo
int64_t global_frame_counter;
CoglFrameInfoFlag flags;
unsigned int sequence;
};
COGL_EXPORT

View File

@ -94,3 +94,11 @@ cogl_frame_info_is_hw_clock (CoglFrameInfo *info)
{
return !!(info->flags & COGL_FRAME_INFO_FLAG_HW_CLOCK);
}
unsigned int
cogl_frame_info_get_sequence (CoglFrameInfo *info)
{
g_warn_if_fail (!(info->flags & COGL_FRAME_INFO_FLAG_SYMBOLIC));
return info->sequence;
}

View File

@ -141,6 +141,9 @@ gboolean cogl_frame_info_get_is_symbolic (CoglFrameInfo *info);
COGL_EXPORT
gboolean cogl_frame_info_is_hw_clock (CoglFrameInfo *info);
COGL_EXPORT
unsigned int cogl_frame_info_get_sequence (CoglFrameInfo *info);
G_END_DECLS
#endif /* __COGL_FRAME_INFO_H */

View File

@ -497,6 +497,9 @@ _cogl_winsys_wait_for_vblank (CoglOnscreen *onscreen)
{
info->presentation_time_us = g_get_monotonic_time ();
}
/* Intentionally truncating to lower 32 bits, same as DRM. */
info->sequence = msc;
}
else
{
@ -976,20 +979,20 @@ cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen *onscreen,
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
gboolean ust_is_monotonic;
CoglFrameInfo *info;
/* We only want to notify that the swap is complete when the
application calls cogl_context_dispatch so instead of immediately
notifying we'll set a flag to remember to notify later */
set_sync_pending (onscreen);
info = cogl_onscreen_peek_head_frame_info (onscreen);
ust_is_monotonic = is_ust_monotonic (context->display->renderer,
onscreen_glx->glxwin);
if (swap_event->ust != 0 && ust_is_monotonic)
{
CoglFrameInfo *info;
info = cogl_onscreen_peek_head_frame_info (onscreen);
info->presentation_time_us =
ust_to_microseconds (context->display->renderer,
onscreen_glx->glxwin,
@ -997,6 +1000,9 @@ cogl_onscreen_glx_notify_swap_buffers (CoglOnscreen *onscreen,
info->flags |= COGL_FRAME_INFO_FLAG_HW_CLOCK;
}
/* Intentionally truncating to lower 32 bits, same as DRM. */
info->sequence = swap_event->msc;
set_complete_pending (onscreen);
}

View File

@ -170,7 +170,8 @@ static void
maybe_update_frame_info (MetaCrtc *crtc,
CoglFrameInfo *frame_info,
int64_t time_us,
CoglFrameInfoFlag flags)
CoglFrameInfoFlag flags,
unsigned int sequence)
{
const MetaCrtcConfig *crtc_config;
const MetaCrtcModeInfo *crtc_mode_info;
@ -189,6 +190,7 @@ maybe_update_frame_info (MetaCrtc *crtc,
frame_info->presentation_time_us = time_us;
frame_info->refresh_rate = refresh_rate;
frame_info->flags |= flags;
frame_info->sequence = sequence;
}
}
@ -210,7 +212,8 @@ static void
notify_view_crtc_presented (MetaRendererView *view,
MetaKmsCrtc *kms_crtc,
int64_t time_us,
CoglFrameInfoFlag flags)
CoglFrameInfoFlag flags,
unsigned int sequence)
{
ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view);
CoglFramebuffer *framebuffer =
@ -225,7 +228,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_us, flags);
maybe_update_frame_info (crtc, frame_info, time_us, flags, sequence);
meta_onscreen_native_notify_frame_complete (onscreen);
@ -287,7 +290,8 @@ page_flip_feedback_flipped (MetaKmsCrtc *kms_crtc,
notify_view_crtc_presented (view, kms_crtc,
presentation_time_us,
flags);
flags,
sequence);
}
static void
@ -323,7 +327,8 @@ page_flip_feedback_mode_set_fallback (MetaKmsCrtc *kms_crtc,
notify_view_crtc_presented (view,
kms_crtc,
now_us,
COGL_FRAME_INFO_FLAG_NONE);
COGL_FRAME_INFO_FLAG_NONE,
0);
}
static void
@ -350,7 +355,8 @@ page_flip_feedback_discarded (MetaKmsCrtc *kms_crtc,
notify_view_crtc_presented (view,
kms_crtc,
now_us,
COGL_FRAME_INFO_FLAG_NONE);
COGL_FRAME_INFO_FLAG_NONE,
0);
}
static const MetaKmsPageFlipListenerVtable page_flip_listener_vtable = {