mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
Start using the monotonic API in GLib ≥ 2.27
Starting from the 2.27 cycle, GLib is exposing a monotonic clock with microseconds granularity throughout the time-based API. We can start using it, given that the old, non-monotonic version is going to be deprecated by the same cycle.
This commit is contained in:
parent
68d7a5e847
commit
8f60d5a3a2
@ -144,11 +144,17 @@ clutter_frame_source_prepare (GSource *source,
|
||||
gint *delay)
|
||||
{
|
||||
ClutterFrameSource *frame_source = (ClutterFrameSource *) source;
|
||||
GTimeVal source_time;
|
||||
gint64 current_time;
|
||||
|
||||
g_source_get_current_time (source, &source_time);
|
||||
current_time = source_time.tv_sec * 1000 + source_time.tv_usec / 1000;
|
||||
#if GLIB_CHECK_VERSION (2, 27, 3)
|
||||
current_time = g_source_get_time (source) / 1000;
|
||||
#else
|
||||
{
|
||||
GTimeVal source_time;
|
||||
g_source_get_current_time (source, &source_time);
|
||||
current_time = source_time.tv_sec * 1000 + source_time.tv_usec / 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
return _clutter_timeout_interval_prepare (current_time,
|
||||
&frame_source->timeout,
|
||||
|
@ -170,7 +170,6 @@ master_clock_is_running (ClutterMasterClock *master_clock)
|
||||
static gint
|
||||
master_clock_next_frame_delay (ClutterMasterClock *master_clock)
|
||||
{
|
||||
GTimeVal source_time;
|
||||
gint64 now, next;
|
||||
|
||||
if (!master_clock_is_running (master_clock))
|
||||
@ -207,8 +206,16 @@ master_clock_next_frame_delay (ClutterMasterClock *master_clock)
|
||||
/* Otherwise, wait at least 1/frame_rate seconds since we last
|
||||
* started a frame
|
||||
*/
|
||||
g_source_get_current_time (master_clock->source, &source_time);
|
||||
now = source_time.tv_sec * 1000000L + source_time.tv_usec;
|
||||
#if GLIB_CHECK_VERSION (2, 27, 3)
|
||||
now = g_source_get_time (master_clock->source);
|
||||
#else
|
||||
{
|
||||
GTimeVal source_time;
|
||||
g_source_get_current_time (master_clock->source, &source_time);
|
||||
now = source_time.tv_sec * 1000000L + source_time.tv_usec;
|
||||
}
|
||||
#endif
|
||||
|
||||
next = master_clock->prev_tick;
|
||||
|
||||
/* If time has gone backwards then there's no way of knowing how
|
||||
@ -301,7 +308,6 @@ clutter_clock_dispatch (GSource *source,
|
||||
ClutterMasterClock *master_clock = clock_source->master_clock;
|
||||
ClutterStageManager *stage_manager = clutter_stage_manager_get_default ();
|
||||
gboolean stages_updated = FALSE;
|
||||
GTimeVal source_time;
|
||||
GSList *stages, *l;
|
||||
|
||||
CLUTTER_STATIC_TIMER (master_dispatch_timer,
|
||||
@ -322,9 +328,16 @@ clutter_clock_dispatch (GSource *source,
|
||||
clutter_threads_enter ();
|
||||
|
||||
/* Get the time to use for this frame */
|
||||
g_source_get_current_time (source, &source_time);
|
||||
master_clock->cur_tick = source_time.tv_sec * 1000000L
|
||||
+ source_time.tv_usec;
|
||||
#if GLIB_CHECK_VERSION (2, 27, 3)
|
||||
master_clock->cur_tick = g_source_get_time (source);
|
||||
#else
|
||||
{
|
||||
GTimeVal source_time;
|
||||
g_source_get_current_time (source, &source_time);
|
||||
master_clock->cur_tick = source_time.tv_sec * 1000000L
|
||||
+ source_time.tv_usec;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We need to protect ourselves against stages being destroyed during
|
||||
* event handling
|
||||
|
@ -34,12 +34,17 @@ void
|
||||
_clutter_timeout_interval_init (ClutterTimeoutInterval *interval,
|
||||
guint fps)
|
||||
{
|
||||
GTimeVal start_time;
|
||||
#if GLIB_CHECK_VERSION (2, 27, 3)
|
||||
interval->start_time = g_get_monotonic_time () / 1000;
|
||||
#else
|
||||
{
|
||||
GTimeVal start_time;
|
||||
g_get_current_time (&start_time);
|
||||
interval->start_time = start_time.tv_sec * 1000
|
||||
+ start_time.tv_usec / 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_get_current_time (&start_time);
|
||||
|
||||
interval->start_time = start_time.tv_sec * 1000
|
||||
+ start_time.tv_usec / 1000;
|
||||
interval->fps = fps;
|
||||
interval->frame_count = 0;
|
||||
}
|
||||
|
@ -136,11 +136,18 @@ clutter_timeout_prepare (ClutterTimeoutPool *pool,
|
||||
ClutterTimeout *timeout,
|
||||
gint *next_timeout)
|
||||
{
|
||||
GTimeVal source_time;
|
||||
GSource *source = (GSource *) pool;
|
||||
gint64 now;
|
||||
|
||||
g_source_get_current_time (&pool->source, &source_time);
|
||||
now = source_time.tv_sec * 1000 + source_time.tv_usec / 1000;
|
||||
#if GLIB_CHECK_VERSION (2, 27, 3)
|
||||
now = g_source_get_time (source) / 1000;
|
||||
#else
|
||||
{
|
||||
GTimeVal source_time;
|
||||
g_source_get_current_time (source, &source_time);
|
||||
now = source_time.tv_sec * 1000 + source_time.tv_usec / 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
return _clutter_timeout_interval_prepare (now,
|
||||
&timeout->interval,
|
||||
|
Loading…
Reference in New Issue
Block a user