summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-02-03 00:43:20 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-02-03 00:43:20 +0000
commit4013c98af15779e71d3a86ac03dd18796cbdf0e6 (patch)
treebe6cb872fd26149354b77d14e475ce31b7ebd468 /src/lib
parent9890c2b135f85fbbd3bf1ccfed90597ff65cfa71 (diff)
ecore_x - vsync ... this handles time going backwards
yes - time went backwards. we get time from the device driver and vsync events... this is so incredibly wrong ... it should not have ever happened... but it did and that caused all sorts of bad things to happen to animators. this guards against that and tries to get the system clock time and if that doesnt work it just takes last time + 0.901. @fix
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_x/ecore_x_vsync.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/ecore_x/ecore_x_vsync.c b/src/lib/ecore_x/ecore_x_vsync.c
index 07abbabcca..26454a2ae9 100644
--- a/src/lib/ecore_x/ecore_x_vsync.c
+++ b/src/lib/ecore_x/ecore_x_vsync.c
@@ -290,7 +290,16 @@ _drm_send_time(double t)
290{ 290{
291 if (threaded_vsync) 291 if (threaded_vsync)
292 { 292 {
293 static double t_last = 0.0;
293 double *tim = malloc(sizeof(*tim)); 294 double *tim = malloc(sizeof(*tim));
295
296 // you won't believe this
297 if (t <= t_last)
298 {
299 fprintf(stderr, "EEEEEEK! time went backwards! %1.5f -> %1.5f\n", t_last, t);
300 t = ecore_time_get();
301 if (t <= t_last) t = t_last + 0.001;
302 }
294 if (tim) 303 if (tim)
295 { 304 {
296 *tim = t; 305 *tim = t;
@@ -301,7 +310,6 @@ _drm_send_time(double t)
301 // this is and this varies... so for now this will do.a 310 // this is and this varies... so for now this will do.a
302 if (_ecore_x_vsync_animator_tick_delay > 0.0) 311 if (_ecore_x_vsync_animator_tick_delay > 0.0)
303 { 312 {
304 static double t_last = 0.0;
305 static double t_delta_hist[10] = { 0.0 }; 313 static double t_delta_hist[10] = { 0.0 };
306 double t_delta = t - t_last; 314 double t_delta = t - t_last;
307 double t_delta_min = 0.0; 315 double t_delta_min = 0.0;
@@ -325,8 +333,7 @@ _drm_send_time(double t)
325 // if w'ere sleeping too long - don't sleep at all. 333 // if w'ere sleeping too long - don't sleep at all.
326 if (t_sleep > (1.0 / 20.0)) t_sleep = 0.0; 334 if (t_sleep > (1.0 / 20.0)) t_sleep = 0.0;
327 } 335 }
328 usleep(t_sleep * 1000000.0); 336 if (t_sleep > 0.0) usleep(t_sleep * 1000000.0);
329 t_last = t;
330 } 337 }
331 D(" @%1.5f ... send %1.8f\n", ecore_time_get(), t); 338 D(" @%1.5f ... send %1.8f\n", ecore_time_get(), t);
332 eina_spinlock_take(&tick_queue_lock); 339 eina_spinlock_take(&tick_queue_lock);
@@ -334,6 +341,7 @@ _drm_send_time(double t)
334 eina_spinlock_release(&tick_queue_lock); 341 eina_spinlock_release(&tick_queue_lock);
335 ecore_thread_feedback(drm_thread, tim); 342 ecore_thread_feedback(drm_thread, tim);
336 } 343 }
344 t_last = t;
337 } 345 }
338 else 346 else
339 { 347 {