frame-clock: Pass timestamp to frame callback

The timestamp comes from the GSource, meaning it's a more accurate
representation of when the frame started to be dispatched compared to
getting the current time in any callback.

Currently unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-03-25 18:14:05 +01:00
parent 9676db4dbf
commit 3c4efd13c1
3 changed files with 20 additions and 7 deletions

View File

@ -307,10 +307,10 @@ clutter_frame_clock_schedule_update (ClutterFrameClock *frame_clock)
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_SCHEDULED;
}
static gboolean
clutter_frame_clock_dispatch (gpointer user_data)
static void
clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock,
int64_t time_us)
{
ClutterFrameClock *frame_clock = user_data;
int64_t frame_count;
ClutterFrameResult result;
@ -334,6 +334,7 @@ clutter_frame_clock_dispatch (gpointer user_data)
COGL_TRACE_BEGIN (ClutterFrameClockFrame, "Frame Clock (frame)");
result = frame_clock->listener.iface->frame (frame_clock,
frame_count,
time_us,
frame_clock->listener.user_data);
COGL_TRACE_END (ClutterFrameClockFrame);
@ -358,8 +359,6 @@ clutter_frame_clock_dispatch (gpointer user_data)
}
break;
}
return G_SOURCE_CONTINUE;
}
static gboolean
@ -367,7 +366,14 @@ frame_clock_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
return callback (user_data);
ClutterClockSource *clock_source = (ClutterClockSource *) source;
ClutterFrameClock *frame_clock = clock_source->frame_clock;
int64_t dispatch_time_us;
dispatch_time_us = g_source_get_time (source);
clutter_frame_clock_dispatch (frame_clock, dispatch_time_us);
return G_SOURCE_CONTINUE;
}
static GSourceFuncs frame_clock_source_funcs = {
@ -391,7 +397,6 @@ init_frame_clock_source (ClutterFrameClock *frame_clock)
g_source_set_name (source, name);
g_source_set_priority (source, CLUTTER_PRIORITY_REDRAW);
g_source_set_can_recurse (source, FALSE);
g_source_set_callback (source, clutter_frame_clock_dispatch, frame_clock, NULL);
clock_source->frame_clock = frame_clock;
frame_clock->source = source;

View File

@ -43,6 +43,7 @@ typedef struct _ClutterFrameListenerIface
gpointer user_data);
ClutterFrameResult (* frame) (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data);
} ClutterFrameListenerIface;

View File

@ -78,6 +78,7 @@ fake_hw_clock_new (ClutterFrameClock *frame_clock,
static ClutterFrameResult
frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
FrameClockTest *test = user_data;
@ -171,6 +172,7 @@ schedule_update_idle (gpointer user_data)
static ClutterFrameResult
immediate_frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
GMainLoop *main_loop = user_data;
@ -242,6 +244,7 @@ schedule_update_timeout (gpointer user_data)
static ClutterFrameResult
delayed_damage_frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
FrameClockTest *test = user_data;
@ -314,6 +317,7 @@ frame_clock_delayed_damage (void)
static ClutterFrameResult
no_damage_frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
g_assert_not_reached ();
@ -366,6 +370,7 @@ typedef struct _UpdateNowFrameClockTest
static ClutterFrameResult
update_now_frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
UpdateNowFrameClockTest *test = user_data;
@ -471,6 +476,7 @@ before_frame_frame_clock_before_frame (ClutterFrameClock *frame_clock,
static ClutterFrameResult
before_frame_frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
int64_t *expected_frame_count = user_data;
@ -537,6 +543,7 @@ typedef struct _InhibitTest
static ClutterFrameResult
inhibit_frame_clock_frame (ClutterFrameClock *frame_clock,
int64_t frame_count,
int64_t time_us,
gpointer user_data)
{
InhibitTest *test = user_data;