ecore_anim: fix animator ticking logic to gain accuarte
authorWonki Kim <wonki_.kim@samsung.com>
Sat, 11 Apr 2020 03:51:24 +0000 (12:51 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Fri, 17 Apr 2020 23:00:11 +0000 (08:00 +0900)
ecore_loop_time has set by a improper timestamp just before animator callback is invoked.

ecore_animator is built over ecore_thread. ticking is handled in 'thread_func'
and a tick is fired by calling ecore_thread_feedback with a timestamp argument.

In notify func, ecore_time_loop_set has take place with the argument from thread func.
the argument could be unacceptable because notify function is invoked asynchronously.
if there were many thing to do in the loop, time gap must be incresed.

animator tick leads elm logic to calculate next position in animating.
so it is neccessary to use actual time for the calculating.

this patch fixes the animator to set loop time by a actual time.

Change-Id: I1f00a5d074a78da5a87fba55bc1ab13a4f1311df

src/lib/ecore/ecore_anim.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_vsync.c

index 003dca0..eaf6648 100644 (file)
@@ -118,18 +118,13 @@ _tick_send(signed char val)
 }
 
 static void
-_timer_send_time(double t, Ecore_Thread *thread)
+_timer_send_time(Ecore_Thread *thread)
 {
-   double *tim = malloc(sizeof(*tim));
-   if (tim)
-     {
-        *tim = t;
-        DBG("   ... send %1.8f", t);
-        eina_spinlock_take(&tick_queue_lock);
-        tick_queue_count++;
-        eina_spinlock_release(&tick_queue_lock);
-        ecore_thread_feedback(thread, tim);
-     }
+   DBG("   ... send %1.8f", ecore_time_get());
+   eina_spinlock_take(&tick_queue_lock);
+   tick_queue_count++;
+   eina_spinlock_release(&tick_queue_lock);
+   ecore_thread_feedback(thread, NULL);
 }
 
 static void
@@ -273,7 +268,7 @@ _timer_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
                }
              else if (data_timeout)
                {
-                  if (tick) _timer_send_time(t0 - d + ft, thread);
+                  if (tick) _timer_send_time(thread);
                }
           }
      }
@@ -322,7 +317,7 @@ _timer_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
                }
              else if (data_timeout)
                {
-                  if (tick) _timer_send_time(t0 - d + ft, thread);
+                  if (tick) _timer_send_time(thread);
                }
           }
      }
@@ -346,7 +341,7 @@ done:
 }
 
 static void
-_timer_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg)
+_timer_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg EINA_UNUSED)
 {
    int tick_queued;
 
@@ -354,25 +349,25 @@ _timer_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, voi
    tick_queued = tick_queue_count;
    tick_queue_count--;
    eina_spinlock_release(&tick_queue_lock);
-   DBG("notify.... %3.3f %i", *((double *)msg), timer_event_is_busy);
+   DBG("notify.... %i", timer_event_is_busy);
    if (timer_event_is_busy)
      {
-        double *t = msg;
+        double t;
         static double pt = 0.0;
+        t = ecore_time_get();
 
-        DBG("VSYNC %1.8f = delt %1.8f", *t, *t - pt);
+        DBG("VSYNC %1.8f = delt %1.8f(%1.8f)", t, t - pt);
         if ((!tick_skip) || (tick_queued == 1))
           {
-             ecore_loop_time_set(*t);
+             ecore_loop_time_set(t);
 #ifndef _WIN32
              if (!exit_signal_received)
 #endif
                _do_tick();
              _ecore_animator_flush();
           }
-        pt = *t;
+        pt = t;
      }
-   free(msg);
 }
 
 static void
index 6273f85..004766e 100644 (file)
@@ -65,18 +65,13 @@ _tick_send(char val)
 }
 
 static void
-_tdm_send_time(double t)
+_tdm_send_time()
 {
-   double *tim = malloc(sizeof(*tim));
-   if (tim)
-     {
-        *tim = t;
-        DBG("tdm send time  @%1.5f   ... send %1.8f\n", ecore_time_get(), t);
-        eina_spinlock_take(&tick_queue_lock);
-        tick_queue_count++;
-        eina_spinlock_release(&tick_queue_lock);
-        ecore_thread_feedback(tdm_thread, tim);
-     }
+   DBG("tdm send time @%1.5f\n", ecore_time_get());
+   eina_spinlock_take(&tick_queue_lock);
+   tick_queue_count++;
+   eina_spinlock_release(&tick_queue_lock);
+   ecore_thread_feedback(tdm_thread, NULL);
 }
 
 static void
@@ -122,7 +117,7 @@ _tdm_vblank_handler(tdm_client_vblank *vblank EINA_UNUSED, tdm_error error EINA_
                   tdelta_avg = 0.0;
                   tdelta_n = 0;
                }
-             _tdm_send_time(t);
+             _tdm_send_time();
              pseq = sequence;
           }
      }
@@ -202,7 +197,7 @@ _tdm_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread)
                   if (err != TDM_ERROR_NONE) {
                        ERR("tdm_client_handle_events failed err %d\n", err);
                        vblank_wait = 0;
-                       _tdm_send_time(ecore_time_get());
+                       _tdm_send_time();
                   }
                }
              else
@@ -230,7 +225,7 @@ done:
 }
 
 static void
-_tdm_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg)
+_tdm_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg EINA_UNUSED)
 {
    int tick_queued;
 
@@ -238,26 +233,26 @@ _tdm_tick_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void
    tick_queued = tick_queue_count;
    tick_queue_count--;
    eina_spinlock_release(&tick_queue_lock);
-   DBG("notify.... %3.3f %i", *((double *)msg), tdm_event_is_busy);
+   DBG("notify.... %i", tdm_event_is_busy);
 
    if (tdm_event_is_busy)
      {
-        double *t = msg;
+        double t;
         static double pt = 0.0;
+        t = ecore_time_get();
 
-        DBG("VSYNC %1.8f = delt %1.8f", *t, *t - pt);
-        if (((!tick_skip) || (tick_skip && tick_queued == 1)) && (*t > pt))
+        DBG("VSYNC %1.8f = delt %1.8f (%1.8f)", t, t - pt);
+        if (((!tick_skip) || (tick_skip && tick_queued == 1)) && (t > pt))
           {
-             ecore_loop_time_set(*t);
+             ecore_loop_time_set(t);
              ecore_animator_custom_tick();
-             pt = *t;
+             pt = t;
           }
         else if ((tick_skip) && (tick_queued > 10))
           {
              DBG("skip this vsync for schedule queued %d\n", tick_queued);
           }
      }
-   free(msg);
 }
 
 static Eina_Bool