[gnome-todo] timeline: Remove first tick check
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] timeline: Remove first tick check
- Date: Sat, 3 Apr 2021 21:43:36 +0000 (UTC)
commit 059ca37aa1fd917e18ff5be834fa84ffb11a2c12
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Mar 7 12:49:12 2021 -0300
timeline: Remove first tick check
We can simplify this lot by removing this check.
src/animation/gtd-timeline.c | 47 ++++++++++++--------------------------------
1 file changed, 13 insertions(+), 34 deletions(-)
---
diff --git a/src/animation/gtd-timeline.c b/src/animation/gtd-timeline.c
index 73035582..52c2e4e1 100644
--- a/src/animation/gtd-timeline.c
+++ b/src/animation/gtd-timeline.c
@@ -118,7 +118,6 @@ typedef struct
/* If we've just started playing and haven't yet gotten
* a tick from the master clock
*/
- guint waiting_first_tick : 1;
guint auto_reverse : 1;
} GtdTimelinePrivate;
@@ -339,6 +338,7 @@ tick_timeline (GtdTimeline *self,
gint64 tick_time_us)
{
GtdTimelinePrivate *priv;
+ gint64 elapsed_us;
priv = gtd_timeline_get_instance_private (self);
@@ -358,40 +358,19 @@ tick_timeline (GtdTimeline *self,
if (!priv->is_playing)
return FALSE;
- if (priv->waiting_first_tick)
- {
- priv->last_frame_time_us = tick_time_us;
- priv->delta_us = 0;
- priv->waiting_first_tick = FALSE;
- return gtd_timeline_do_frame (self);
- }
- else
- {
- gint64 elapsed_us;
-
- elapsed_us = tick_time_us - priv->last_frame_time_us;
-
- /* if the clock rolled back between ticks we need to
- * account for it; the best course of action, since the
- * clock roll back can happen by any arbitrary amount
- * of milliseconds, is to drop a frame here
- */
- if (elapsed_us < 0)
- {
- priv->last_frame_time_us = elapsed_us;
- return TRUE;
- }
+ elapsed_us = tick_time_us - priv->last_frame_time_us;
+ priv->last_frame_time_us = tick_time_us;
- if (elapsed_us != 0)
- {
- /* Avoid accumulating error */
- priv->last_frame_time_us += elapsed_us;
- priv->delta_us = elapsed_us;
- return gtd_timeline_do_frame (self);
- }
- }
+ /* if the clock rolled back between ticks we need to
+ * account for it; the best course of action, since the
+ * clock roll back can happen by any arbitrary amount
+ * of milliseconds, is to drop a frame here
+ */
+ if (elapsed_us <= 0)
+ return TRUE;
- return FALSE;
+ priv->delta_us = elapsed_us;
+ return gtd_timeline_do_frame (self);
}
static gboolean
@@ -457,7 +436,7 @@ set_is_playing (GtdTimeline *self,
if (priv->is_playing)
{
- priv->waiting_first_tick = TRUE;
+ priv->last_frame_time_us = g_get_monotonic_time ();
priv->current_repeat = 0;
add_tick_callback (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]