present: Round fake MSC computations intead of truncating
authorKeith Packard <keithp@keithp.com>
Thu, 7 Nov 2013 22:17:12 +0000 (14:17 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 20 Nov 2013 21:12:22 +0000 (13:12 -0800)
If the timer fired too early, we'd sometimes mis-compute the MSC for
fake vblanks. Rounding the computation to the nearest MSC fixes this nicely.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
present/present_fake.c

index a677592..e550e98 100644 (file)
@@ -42,7 +42,7 @@ present_fake_get_ust_msc(ScreenPtr screen, uint64_t *ust, uint64_t *msc)
     present_screen_priv_ptr screen_priv = present_screen_priv(screen);
 
     *ust = GetTimeInMicros();
-    *msc = *ust / screen_priv->fake_interval;
+    *msc = (*ust + screen_priv->fake_interval / 2) / screen_priv->fake_interval;
     return Success;
 }