bug 552020 Part 3: Enable Creation of mozilla::TimeStamp from system timestamps. r=roc
authorMason Chang <mchang@mozilla.com>
Tue, 18 Nov 2014 13:28:42 -0800
changeset 216336 f134d9b40fe8ad58c39acde5874a0f2167b84152
parent 216335 8da176df25abd64bfd0224fbd200cbce5b3cfabd
child 216337 64e7a6391916f4fee997999b827a38e44553b2cc
child 216353 ec82fb8c912775ef3dfdfc11992faee876d5ff15
push id27845
push userkwierso@gmail.com
push dateWed, 19 Nov 2014 02:08:01 +0000
treeherdermozilla-central@64e7a6391916 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs552020
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 552020 Part 3: Enable Creation of mozilla::TimeStamp from system timestamps. r=roc
widget/gonk/HwcComposer2D.cpp
widget/gonk/nsAppShell.cpp
xpcom/ds/TimeStamp.h
--- a/widget/gonk/HwcComposer2D.cpp
+++ b/widget/gonk/HwcComposer2D.cpp
@@ -226,17 +226,17 @@ HwcComposer2D::RunVsyncEventControl(bool
             device->eventControl(device, HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, aEnable);
         }
     }
 }
 
 void
 HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
 {
-    TimeStamp vsyncTime = mozilla::TimeStamp(aVsyncTimestamp);
+    TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(aVsyncTimestamp);
     nsecs_t vsyncInterval = aVsyncTimestamp - mLastVsyncTime;
     if (vsyncInterval < 16000000 || vsyncInterval > 17000000) {
       LOGE("Non-uniform vsync interval: %lld\n", vsyncInterval);
     }
     mLastVsyncTime = aVsyncTimestamp;
     VsyncDispatcher::GetInstance()->NotifyVsync(vsyncTime);
 }
 
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -710,17 +710,17 @@ addMultiTouch(MultiTouchInput& aMultiTou
 
 void
 GeckoInputDispatcher::notifyMotion(const NotifyMotionArgs* args)
 {
     uint32_t time = nanosecsToMillisecs(args->eventTime);
     int32_t action = args->action & AMOTION_EVENT_ACTION_MASK;
     int touchCount = args->pointerCount;
     MOZ_ASSERT(touchCount <= MAX_POINTERS);
-    TimeStamp timestamp = TimeStamp(args->eventTime);
+    TimeStamp timestamp = mozilla::TimeStamp::FromSystemTime(args->eventTime);
     Modifiers modifiers = getDOMModifiers(args->metaState);
 
     MultiTouchInput::MultiTouchType touchType = MultiTouchInput::MULTITOUCH_CANCEL;
     switch (action) {
     case AMOTION_EVENT_ACTION_DOWN:
     case AMOTION_EVENT_ACTION_POINTER_DOWN:
         touchType = MultiTouchInput::MULTITOUCH_START;
         break;
--- a/xpcom/ds/TimeStamp.h
+++ b/xpcom/ds/TimeStamp.h
@@ -382,21 +382,30 @@ class TimeStamp
 {
 public:
   /**
    * Initialize to the "null" moment
    */
   MOZ_CONSTEXPR TimeStamp() : mValue(0) {}
   // Default copy-constructor and assignment are OK
 
-#ifdef MOZ_WIDGET_GONK
-  TimeStamp(int64_t aAndroidTime) : mValue(aAndroidTime)
+  /**
+   * The system timestamps are the same as the TimeStamp
+   * retrieved by mozilla::TimeStamp. Since we need this for
+   * vsync timestamps, we enable the creation of mozilla::TimeStamps
+   * on platforms that support vsync aligned refresh drivers / compositors
+   * Verified true as of Nov 7, 2014: B2G and OS X
+   * UNTESTED ON OTHER PLATFORMS
+   */
+#if defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_COCOA)
+  static TimeStamp FromSystemTime(int64_t aSystemTime)
   {
-    static_assert(sizeof(aAndroidTime) == sizeof(TimeStampValue),
-                  "Android timestamp should be same units as TimeStampValue");
+    static_assert(sizeof(aSystemTime) == sizeof(TimeStampValue),
+                  "System timestamp should be same units as TimeStampValue");
+    return TimeStamp(aSystemTime);
   }
 #endif
 
   /**
    * Return true if this is the "null" moment
    */
   bool IsNull() const { return mValue == 0; }