Add gdk_frame_timings_get_predicted_presentation_time()

For an operation like synchronizing audio to video playback, we need to
be able to predict the time that a frame will be presented. The details
of this depend on the windowing system, so make the backend predict
a presentation time for ::begin-frame and set it on the GdkFrameTimings.

The timing algorithm of GdkFrameClockIdle is adjusted to give predictable
presentation times for frames that are not throttled by the windowing
system.

Helper functions:

 gdk_frame_clock_get_current_frame_timings()
 gdk_frame_clock_get_refresh_info()

are added for operations that would otherwise be needed multiple times
in different locations.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
This commit is contained in:
Owen W. Taylor
2012-11-15 14:11:41 -05:00
parent 8855bf052d
commit fb44ea8a85
9 changed files with 201 additions and 19 deletions

View File

@ -29,6 +29,7 @@ struct _GdkFrameTimings
gint64 drawn_time;
gint64 presentation_time;
gint64 refresh_interval;
gint64 predicted_presentation_time;
#ifdef G_ENABLE_DEBUG
gint64 layout_start_time;
@ -187,6 +188,23 @@ gdk_frame_timings_set_presentation_time (GdkFrameTimings *timings,
timings->presentation_time = presentation_time;
}
gint64
gdk_frame_timings_get_predicted_presentation_time (GdkFrameTimings *timings)
{
g_return_val_if_fail (timings != NULL, 0);
return timings->predicted_presentation_time;
}
void
gdk_frame_timings_set_predicted_presentation_time (GdkFrameTimings *timings,
gint64 predicted_presentation_time)
{
g_return_if_fail (timings != NULL);
timings->predicted_presentation_time = predicted_presentation_time;
}
gint64
gdk_frame_timings_get_refresh_interval (GdkFrameTimings *timings)
{