[chromium] Times in the cc should be expressed in seconds.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 02:15:48 +0000 (02:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 02:15:48 +0000 (02:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80514

Patch by Ian Vollick <vollick@chromium.org> on 2012-03-19
Reviewed by James Robinson.

Source/WebCore:

Updated timer tests to use seconds.

* platform/TouchFlingPlatformGestureCurve.h:
(TouchFlingPlatformGestureCurve):
* platform/graphics/chromium/cc/CCActiveGestureAnimation.cpp:
(WebCore::CCActiveGestureAnimation::animate):
* platform/graphics/chromium/cc/CCActiveGestureAnimation.h:
(CCActiveGestureAnimation):
* platform/graphics/chromium/cc/CCDelayBasedTimeSource.cpp:
(WebCore::CCDelayBasedTimeSource::create):
(WebCore::CCDelayBasedTimeSource::CCDelayBasedTimeSource):
(WebCore::CCDelayBasedTimeSource::setActive):
(WebCore::CCDelayBasedTimeSource::onTimerFired):
(WebCore::CCDelayBasedTimeSource::monotonicallyIncreasingTime):
(WebCore):
(WebCore::CCDelayBasedTimeSource::postNextTickTask):
* platform/graphics/chromium/cc/CCDelayBasedTimeSource.h:
(CCDelayBasedTimeSource):
* platform/graphics/chromium/cc/CCGestureCurve.h:
(CCGestureCurve):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WTF):
(WebCore::CCThreadProxy::beginContextRecreation):
(WebCore::CCThreadProxy::tryToRecreateContext):
(WebCore::CCThreadProxy::initializeImplOnImplThread):
* platform/graphics/chromium/cc/CCTimer.cpp:
(WebCore::CCTimer::startOneShot):
* platform/graphics/chromium/cc/CCTimer.h:
(CCTimer):

Source/WebKit/chromium:

* tests/CCDelayBasedTimeSourceTest.cpp:
(WebKitTests::TEST):
* tests/CCFrameRateControllerTest.cpp:
(WebKitTests::TEST):
* tests/CCSchedulerTestCommon.h:
(WebKitTests::FakeCCThread::pendingDelayMs):
(WebKitTests::FakeCCDelayBasedTimeSource::create):
(WebKitTests::FakeCCDelayBasedTimeSource::setMonotonicallyIncreasingTime):
(WebKitTests::FakeCCDelayBasedTimeSource::monotonicallyIncreasingTime):
(WebKitTests::FakeCCDelayBasedTimeSource::FakeCCDelayBasedTimeSource):
(FakeCCDelayBasedTimeSource):
* tests/CCTimerTest.cpp:
(WebKitTests::TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111308 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/TouchFlingPlatformGestureCurve.h
Source/WebCore/platform/graphics/chromium/cc/CCActiveGestureAnimation.cpp
Source/WebCore/platform/graphics/chromium/cc/CCActiveGestureAnimation.h
Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.cpp
Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.h
Source/WebCore/platform/graphics/chromium/cc/CCGestureCurve.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTimer.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTimer.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp
Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
Source/WebKit/chromium/tests/CCSchedulerTestCommon.h
Source/WebKit/chromium/tests/CCTimerTest.cpp

index 6051729aac8420aeeb7c134f56e44c38d91a174e..6b4ab673dde00520ee62a8e7c456cc6d479dfa3d 100644 (file)
@@ -1,3 +1,40 @@
+2012-03-19  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] Times in the cc should be expressed in seconds.
+        https://bugs.webkit.org/show_bug.cgi?id=80514
+
+        Reviewed by James Robinson.
+
+        Updated timer tests to use seconds.
+
+        * platform/TouchFlingPlatformGestureCurve.h:
+        (TouchFlingPlatformGestureCurve):
+        * platform/graphics/chromium/cc/CCActiveGestureAnimation.cpp:
+        (WebCore::CCActiveGestureAnimation::animate):
+        * platform/graphics/chromium/cc/CCActiveGestureAnimation.h:
+        (CCActiveGestureAnimation):
+        * platform/graphics/chromium/cc/CCDelayBasedTimeSource.cpp:
+        (WebCore::CCDelayBasedTimeSource::create):
+        (WebCore::CCDelayBasedTimeSource::CCDelayBasedTimeSource):
+        (WebCore::CCDelayBasedTimeSource::setActive):
+        (WebCore::CCDelayBasedTimeSource::onTimerFired):
+        (WebCore::CCDelayBasedTimeSource::monotonicallyIncreasingTime):
+        (WebCore):
+        (WebCore::CCDelayBasedTimeSource::postNextTickTask):
+        * platform/graphics/chromium/cc/CCDelayBasedTimeSource.h:
+        (CCDelayBasedTimeSource):
+        * platform/graphics/chromium/cc/CCGestureCurve.h:
+        (CCGestureCurve):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WTF):
+        (WebCore::CCThreadProxy::beginContextRecreation):
+        (WebCore::CCThreadProxy::tryToRecreateContext):
+        (WebCore::CCThreadProxy::initializeImplOnImplThread):
+        * platform/graphics/chromium/cc/CCTimer.cpp:
+        (WebCore::CCTimer::startOneShot):
+        * platform/graphics/chromium/cc/CCTimer.h:
+        (CCTimer):
+
 2012-03-19  Florin Malita  <fmalita@google.com>
 
         Relative-height block SVG root not layed out on container height change
index fd52bc4ec74c0b52b75845b4669f656f07d250ee..a7e1cec101e012acee2b1fc21d9c53060a17c34e 100644 (file)
@@ -43,7 +43,7 @@ public:
     static PassOwnPtr<PlatformGestureCurve> create(const FloatPoint& velocity);
     virtual ~TouchFlingPlatformGestureCurve();
 
-    virtual bool apply(double time, PlatformGestureCurveTarget*);
+    virtual bool apply(double monotonicTime, PlatformGestureCurveTarget*);
 
 private:
     explicit TouchFlingPlatformGestureCurve(const FloatPoint& velocity);
index a4af3e59bc5577a886f029be592fc499ad43ba01..dafeca6e753d4ef69c80870d732440e5aae3711f 100644 (file)
@@ -47,15 +47,15 @@ CCActiveGestureAnimation::~CCActiveGestureAnimation()
 {
 }
 
-bool CCActiveGestureAnimation::animate(double time)
+bool CCActiveGestureAnimation::animate(double monotonicTime)
 {
     if (m_waitingForFirstTick) {
-        m_startTime = time;
+        m_startTime = monotonicTime;
         m_waitingForFirstTick = false;
     }
 
     // CCGestureCurves used zero-based time, so subtract start-time.
-    return m_gestureCurve->apply(time - m_startTime, m_gestureCurveTarget);
+    return m_gestureCurve->apply(monotonicTime - m_startTime, m_gestureCurveTarget);
 }
 
 } // namespace WebCore
index 9bcd753704c3594e23bed36b6b654940a854d70d..000ed424b2d55936b0793bc6ef131ac0d40df183 100644 (file)
@@ -40,7 +40,7 @@ public:
     static PassOwnPtr<CCActiveGestureAnimation> create(PassOwnPtr<CCGestureCurve>, CCGestureCurveTarget*);
     ~CCActiveGestureAnimation();
 
-    bool animate(double time);
+    bool animate(double monotonicTime);
 
 private:
     CCActiveGestureAnimation(PassOwnPtr<CCGestureCurve>, CCGestureCurveTarget*);
index e7b19a760504ef74c843406053af40c933340354..b688a78a27c57951dd8d6beffee766c5d24f23e4 100644 (file)
 
 namespace WebCore {
 
-PassRefPtr<CCDelayBasedTimeSource> CCDelayBasedTimeSource::create(double intervalMs, CCThread* thread)
+PassRefPtr<CCDelayBasedTimeSource> CCDelayBasedTimeSource::create(double interval, CCThread* thread)
 {
-    return adoptRef(new CCDelayBasedTimeSource(intervalMs, thread));
+    return adoptRef(new CCDelayBasedTimeSource(interval, thread));
 }
 
-CCDelayBasedTimeSource::CCDelayBasedTimeSource(double intervalMs, CCThread* thread)
+CCDelayBasedTimeSource::CCDelayBasedTimeSource(double intervalSeconds, CCThread* thread)
     : m_client(0)
     , m_hasTickTarget(false)
-    , m_intervalMs(intervalMs)
+    , m_intervalSeconds(intervalSeconds)
     , m_tickTarget(0)
     , m_state(STATE_INACTIVE)
     , m_timer(thread, this)
@@ -70,32 +70,32 @@ void CCDelayBasedTimeSource::setActive(bool active)
 
     m_state = STATE_ACTIVE;
 
-    double nowMs = monotonicallyIncreasingTimeMs();
-    postNextTickTask(nowMs);
+    double now = monotonicallyIncreasingTime();
+    postNextTickTask(now);
 }
 
 void CCDelayBasedTimeSource::onTimerFired()
 {
     ASSERT(m_state != STATE_INACTIVE);
 
-    double nowMs = monotonicallyIncreasingTimeMs();
+    double now = monotonicallyIncreasingTime();
 
     if (m_state == STATE_STARTING) {
         m_hasTickTarget = true;
-        m_tickTarget = nowMs;
+        m_tickTarget = now;
         m_state = STATE_ACTIVE;
     }
 
-    postNextTickTask(nowMs);
+    postNextTickTask(now);
 
     // Fire the tick
     if (m_client)
         m_client->onTimerTick();
 }
 
-double CCDelayBasedTimeSource::monotonicallyIncreasingTimeMs() const
+double CCDelayBasedTimeSource::monotonicallyIncreasingTime() const
 {
-    return WTF::monotonicallyIncreasingTime() * 1000.0;
+    return WTF::monotonicallyIncreasingTime();
 }
 
 // This code tries to achieve an average tick rate as close to m_intervalMs as possible.
@@ -141,21 +141,23 @@ double CCDelayBasedTimeSource::monotonicallyIncreasingTimeMs() const
 //
 // For the really late delay, we we move to the next logical tick. The timebase is not reset.
 //      now=37   tickTarget=16.667  newTarget=50.000  --> tick(), postDelayedTask(floor(50.000-37)) --> postDelayedTask(13)
-void CCDelayBasedTimeSource::postNextTickTask(double nowMs)
+//
+// Note, that in the above discussion, times are expressed in milliseconds, but in the code, seconds are used.
+void CCDelayBasedTimeSource::postNextTickTask(double now)
 {
-    int numIntervalsElapsed = static_cast<int>(floor((nowMs - m_tickTarget) / m_intervalMs));
-    double lastEffectiveTick = m_tickTarget + m_intervalMs * numIntervalsElapsed;
-    double newTickTarget = lastEffectiveTick + m_intervalMs;
-
-    long long delay = static_cast<long long>(newTickTarget - nowMs);
-    if (!delay) {
-        newTickTarget = newTickTarget + m_intervalMs;
-        delay = static_cast<long long>(newTickTarget - nowMs);
+    int numIntervalsElapsed = static_cast<int>(floor((now - m_tickTarget) / m_intervalSeconds));
+    double lastEffectiveTick = m_tickTarget + m_intervalSeconds * numIntervalsElapsed;
+    double newTickTarget = lastEffectiveTick + m_intervalSeconds;
+
+    long long delayMs = static_cast<long long>((newTickTarget - now) * 1000.0);
+    if (!delayMs) {
+        newTickTarget = newTickTarget + m_intervalSeconds;
+        delayMs = static_cast<long long>((newTickTarget - now) * 1000.0);
     }
 
     // Post another task *before* the tick and update state
-    ASSERT(newTickTarget > nowMs);
-    m_timer.startOneShot(delay);
+    ASSERT(newTickTarget > now);
+    m_timer.startOneShot(delayMs / 1000.0);
     m_tickTarget = newTickTarget;
 }
 
index a41aad4d8429268b2208a50c8a4258e78bcabe73..5f1b2c4f2fda7bed54f5f44350645f35f796e5df 100644 (file)
@@ -38,7 +38,7 @@ class CCThread;
 // in face of millisecond-precision delayed callbacks and random queueing delays.
 class CCDelayBasedTimeSource : public CCTimeSource, CCTimerClient {
 public:
-    static PassRefPtr<CCDelayBasedTimeSource> create(double intervalMs, CCThread*);
+    static PassRefPtr<CCDelayBasedTimeSource> create(double intervalSeconds, CCThread*);
 
     virtual ~CCDelayBasedTimeSource() { }
 
@@ -51,11 +51,11 @@ public:
     virtual void onTimerFired();
 
     // Virtual for testing.
-    virtual double monotonicallyIncreasingTimeMs() const;
+    virtual double monotonicallyIncreasingTime() const;
 
 protected:
-    CCDelayBasedTimeSource(double intervalMs, CCThread*);
-    void postNextTickTask(double nowMs);
+    CCDelayBasedTimeSource(double interval, CCThread*);
+    void postNextTickTask(double now);
 
     enum State {
         STATE_INACTIVE,
@@ -64,7 +64,7 @@ protected:
     };
     CCTimeSourceClient* m_client;
     bool m_hasTickTarget;
-    double m_intervalMs;
+    double m_intervalSeconds;
     double m_tickTarget;
     State m_state;
     CCThread* m_thread;
index 4bc1c0dd806df765e3f2472d2b663645d289c6a5..5d98af4c6c92b07482862c635659ad3d82aec73e 100644 (file)
@@ -41,7 +41,7 @@ class CCGestureCurve {
 public:
     virtual ~CCGestureCurve() { }
 
-    virtual bool apply(double time, CCGestureCurveTarget*) = 0;
+    virtual bool apply(double monotonicTime, CCGestureCurveTarget*) = 0;
 };
 
 } // namespace WebCore
index e1675223c548077bf40cbbab3dfebd9f6b2b8285..d5488f2c71d9cb50a3175b1ad77e0a7dc5d4d520 100644 (file)
@@ -47,6 +47,9 @@ namespace {
 // scheduledActionUpdateMoreResources().
 static const size_t textureUpdatesPerFrame = 32;
 
+// Measured in seconds.
+static const double contextRecreationTickRate = 0.03;
+
 } // anonymous namespace
 
 namespace WebCore {
@@ -612,8 +615,6 @@ public:
         m_proxy->tryToRecreateContext();
     }
 
-    enum Recreation { RecreationTickRateMs = 30 };
-
 private:
     explicit CCThreadProxyContextRecreationTimer(CCThreadProxy* proxy)
         : CCTimer(CCProxy::mainThread(), this)
@@ -631,7 +632,7 @@ void CCThreadProxy::beginContextRecreation()
     ASSERT(!m_contextRecreationTimer);
     m_contextRecreationTimer = CCThreadProxyContextRecreationTimer::create(this);
     m_layerTreeHost->didLoseContext();
-    m_contextRecreationTimer->startOneShot(CCThreadProxyContextRecreationTimer::RecreationTickRateMs);
+    m_contextRecreationTimer->startOneShot(contextRecreationTickRate);
 }
 
 void CCThreadProxy::tryToRecreateContext()
@@ -640,7 +641,7 @@ void CCThreadProxy::tryToRecreateContext()
     ASSERT(m_layerTreeHost);
     CCLayerTreeHost::RecreateResult result = m_layerTreeHost->recreateContext();
     if (result == CCLayerTreeHost::RecreateFailedButTryAgain)
-        m_contextRecreationTimer->startOneShot(CCThreadProxyContextRecreationTimer::RecreationTickRateMs);
+        m_contextRecreationTimer->startOneShot(contextRecreationTickRate);
     else if (result == CCLayerTreeHost::RecreateSucceeded)
         m_contextRecreationTimer.clear();
 }
@@ -650,8 +651,8 @@ void CCThreadProxy::initializeImplOnImplThread(CCCompletionEvent* completion)
     TRACE_EVENT("CCThreadProxy::initializeImplOnImplThread", this, 0);
     ASSERT(isImplThread());
     m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
-    const double displayRefreshIntervalMs = 1000.0 / 60.0;
-    OwnPtr<CCFrameRateController> frameRateController = adoptPtr(new CCFrameRateController(CCDelayBasedTimeSource::create(displayRefreshIntervalMs, CCProxy::implThread())));
+    const double displayRefreshInterval = 1.0 / 60.0;
+    OwnPtr<CCFrameRateController> frameRateController = adoptPtr(new CCFrameRateController(CCDelayBasedTimeSource::create(displayRefreshInterval, CCProxy::implThread())));
     m_schedulerOnImplThread = CCScheduler::create(this, frameRateController.release());
     m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
 
index 9fcc61305c1989eeeb7a7fcd5695bb2c20b86ded..6d6189e233bf0b60d21595ea787a960d5983feb3 100644 (file)
@@ -76,12 +76,14 @@ CCTimer::~CCTimer()
     stop();
 }
 
-void CCTimer::startOneShot(double intervalMs)
+void CCTimer::startOneShot(double intervalSeconds)
 {
     stop();
 
     m_task = new CCTimerTask(this);
-    m_thread->postDelayedTask(adoptPtr(m_task), intervalMs);
+
+    // The thread expects delays in milliseconds.
+    m_thread->postDelayedTask(adoptPtr(m_task), intervalSeconds * 1000.0);
 }
 
 void CCTimer::stop()
index b8db5e18938f08f52a11ca710bc2ae3dd2c377b1..a845190d9a5aaaebc4d2211d192761107deef553 100644 (file)
@@ -50,7 +50,7 @@ public:
     ~CCTimer();
 
     // If a previous task is pending, it will be replaced with the new one.
-    void startOneShot(double intervalMs);
+    void startOneShot(double intervalSeconds);
     void stop();
 
     bool isActive() const { return m_task; }
index b0adf8565e17fd314f2a9f0c3ad197c45383a814..ebd465474edc53f3a37333469e90685cb9a1a922 100644 (file)
@@ -1,3 +1,24 @@
+2012-03-19  Ian Vollick  <vollick@chromium.org>
+
+        [chromium] Times in the cc should be expressed in seconds.
+        https://bugs.webkit.org/show_bug.cgi?id=80514
+
+        Reviewed by James Robinson.
+
+        * tests/CCDelayBasedTimeSourceTest.cpp:
+        (WebKitTests::TEST):
+        * tests/CCFrameRateControllerTest.cpp:
+        (WebKitTests::TEST):
+        * tests/CCSchedulerTestCommon.h:
+        (WebKitTests::FakeCCThread::pendingDelayMs):
+        (WebKitTests::FakeCCDelayBasedTimeSource::create):
+        (WebKitTests::FakeCCDelayBasedTimeSource::setMonotonicallyIncreasingTime):
+        (WebKitTests::FakeCCDelayBasedTimeSource::monotonicallyIncreasingTime):
+        (WebKitTests::FakeCCDelayBasedTimeSource::FakeCCDelayBasedTimeSource):
+        (FakeCCDelayBasedTimeSource):
+        * tests/CCTimerTest.cpp:
+        (WebKitTests::TEST_F):
+
 2012-03-19  Nat Duca  <nduca@chromium.org>
 
         [chromium] Stop deriving WebCompositor from WebCompositorInputHandler
index 867d56ea87d228b949d112118b21fa37278c872d..93e84a4afb10f6e36de685ff3f9af46e35895eec 100644 (file)
@@ -41,15 +41,15 @@ TEST(CCDelayBasedTimeSourceTest, TaskPostedAndTickCalled)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
 
-    timer->setMonotonicallyIncreasingTimeMs(0);
+    timer->setMonotonicallyIncreasingTime(0);
     timer->setActive(true);
     EXPECT_TRUE(timer->active());
     EXPECT_TRUE(thread.hasPendingTask());
 
-    timer->setMonotonicallyIncreasingTimeMs(16);
+    timer->setMonotonicallyIncreasingTime(0.016);
     thread.runPendingTask();
     EXPECT_TRUE(timer->active());
     EXPECT_TRUE(client.tickCalled());
@@ -59,7 +59,7 @@ TEST(CCDelayBasedTimeSource, TickNotCalledWithTaskPosted)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     EXPECT_TRUE(thread.hasPendingTask());
@@ -72,7 +72,7 @@ TEST(CCDelayBasedTimeSource, StartTwiceEnqueuesOneTask)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     EXPECT_TRUE(thread.hasPendingTask());
@@ -85,7 +85,7 @@ TEST(CCDelayBasedTimeSource, StartWhenRunningDoesntTick)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     thread.runPendingTask();
@@ -100,19 +100,19 @@ TEST(CCDelayBasedTimeSource, NextDelaySaneWhenExactlyOnRequestedTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    double interval = 1000.0 / 60.0;
+    double interval = 1.0 / 60.0;
     RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     // Run the first task, as that activates the timer and picks up a timebase.
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 
-    timer->setMonotonicallyIncreasingTimeMs(interval);
+    timer->setMonotonicallyIncreasingTime(interval);
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 }
 
 // At 60Hz, when the tick returns at slightly after the requested next time, make sure
@@ -121,19 +121,19 @@ TEST(CCDelayBasedTimeSource, NextDelaySaneWhenSlightlyAfterRequestedTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    double interval = 1000.0 / 60.0;
+    double interval = 1.0 / 60.0;
     RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     // Run the first task, as that activates the timer and picks up a timebase.
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 
-    timer->setMonotonicallyIncreasingTimeMs(interval + 0.0001);
+    timer->setMonotonicallyIncreasingTime(interval + 0.0000001);
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 }
 
 // At 60Hz, when the tick returns at exactly 2*interval after the requested next time, make sure
@@ -142,19 +142,19 @@ TEST(CCDelayBasedTimeSource, NextDelaySaneWhenExactlyTwiceAfterRequestedTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    double interval = 1000.0 / 60.0;
+    double interval = 1.0 / 60.0;
     RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     // Run the first task, as that activates the timer and picks up a timebase.
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 
-    timer->setMonotonicallyIncreasingTimeMs(2*interval);
+    timer->setMonotonicallyIncreasingTime(2*interval);
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 }
 
 // At 60Hz, when the tick returns at 2*interval and a bit after the requested next time, make sure
@@ -163,19 +163,19 @@ TEST(CCDelayBasedTimeSource, NextDelaySaneWhenSlightlyAfterTwiceRequestedTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    double interval = 1000.0 / 60.0;
+    double interval = 1.0 / 60.0;
     RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     // Run the first task, as that activates the timer and picks up a timebase.
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 
-    timer->setMonotonicallyIncreasingTimeMs(2*interval + 0.0001);
+    timer->setMonotonicallyIncreasingTime(2*interval + 0.0000001);
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 }
 
 // At 60Hz, when the tick returns halfway to the next frame time, make sure
@@ -184,19 +184,19 @@ TEST(CCDelayBasedTimeSource, NextDelaySaneWhenHalfAfterRequestedTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    double interval = 1000.0 / 60.0;
+    double interval = 1.0 / 60.0;
     RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(interval, &thread);
     timer->setClient(&client);
     timer->setActive(true);
     // Run the first task, as that activates the timer and picks up a timebase.
     thread.runPendingTask();
 
-    EXPECT_EQ(16, thread.pendingDelay());
+    EXPECT_EQ(16, thread.pendingDelayMs());
 
-    timer->setMonotonicallyIncreasingTimeMs(interval + interval * 0.5);
+    timer->setMonotonicallyIncreasingTime(interval + interval * 0.5);
     thread.runPendingTask();
 
-    EXPECT_EQ(8, thread.pendingDelay());
+    EXPECT_EQ(8, thread.pendingDelayMs());
 }
 
 
@@ -206,31 +206,31 @@ TEST(CCDelayBasedTimeSourceTest, AchievesTargetRateWithNoNoise)
 
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
     timer->setActive(true);
 
     double totalFrameTime = 0;
     for (int i = 0; i < numIterations; ++i) {
-        long long delay = thread.pendingDelay();
+        long long delayMs = thread.pendingDelayMs();
 
         // accumulate the "delay"
-        totalFrameTime += delay;
+        totalFrameTime += delayMs / 1000.0;
 
         // Run the callback exactly when asked
-        double now = timer->monotonicallyIncreasingTimeMs() + delay;
-        timer->setMonotonicallyIncreasingTimeMs(now);
+        double now = timer->monotonicallyIncreasingTime() + delayMs / 1000.0;
+        timer->setMonotonicallyIncreasingTime(now);
         thread.runPendingTask();
     }
     double averageInterval = totalFrameTime / static_cast<double>(numIterations);
-    EXPECT_NEAR(1000.0 / 60.0, averageInterval, 0.1);
+    EXPECT_NEAR(1.0 / 60.0, averageInterval, 0.1);
 }
 
 TEST(CCDelayBasedTimeSource, TestDeactivateWhilePending)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
     timer->setActive(true); // Should post a task.
     timer->setActive(false);
@@ -242,12 +242,12 @@ TEST(CCDelayBasedTimeSource, TestDeactivateAndReactivateBeforeNextTickTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
 
     // Should run the activate task, and pick up a new timebase.
     timer->setActive(true);
-    timer->setMonotonicallyIncreasingTimeMs(0);
+    timer->setMonotonicallyIncreasingTime(0);
     thread.runPendingTask();
 
     // Stop the timer
@@ -258,21 +258,21 @@ TEST(CCDelayBasedTimeSource, TestDeactivateAndReactivateBeforeNextTickTime)
 
     // Start the timer again, but before the next tick time the timer previously
     // planned on using. That same tick time should still be targeted.
-    timer->setMonotonicallyIncreasingTimeMs(4);
+    timer->setMonotonicallyIncreasingTime(0.004);
     timer->setActive(true);
-    EXPECT_EQ(12, thread.pendingDelay());
+    EXPECT_EQ(12, thread.pendingDelayMs());
 }
 
 TEST(CCDelayBasedTimeSource, TestDeactivateAndReactivateAfterNextTickTime)
 {
     FakeCCThread thread;
     FakeCCTimeSourceClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timer = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     timer->setClient(&client);
 
     // Should run the activate task, and pick up a new timebase.
     timer->setActive(true);
-    timer->setMonotonicallyIncreasingTimeMs(0);
+    timer->setMonotonicallyIncreasingTime(0);
     thread.runPendingTask();
 
     // Stop the timer
@@ -283,9 +283,9 @@ TEST(CCDelayBasedTimeSource, TestDeactivateAndReactivateAfterNextTickTime)
 
     // Start the timer again, but before the next tick time the timer previously
     // planned on using. That same tick time should still be targeted.
-    timer->setMonotonicallyIncreasingTimeMs(20);
+    timer->setMonotonicallyIncreasingTime(0.02);
     timer->setActive(true);
-    EXPECT_EQ(13, thread.pendingDelay());
+    EXPECT_EQ(13, thread.pendingDelayMs());
 }
 
 }
index f315903901abe862b84c1093ead1dfa6e142f837..c9a60cfaa23b504804084f4c00fcaf39f7873b38 100644 (file)
@@ -53,7 +53,7 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
 {
     FakeCCThread thread;
     FakeCCFrameRateControllerClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     CCFrameRateController controller(timeSource);
 
     controller.setClient(&client);
@@ -62,8 +62,8 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
     double elapsed = 0; // Muck around with time a bit
 
     // Trigger one frame, make sure the vsync callback is called
-    elapsed += thread.pendingDelay();
-    timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+    elapsed += thread.pendingDelayMs() / 1000.0;
+    timeSource->setMonotonicallyIncreasingTime(elapsed);
     thread.runPendingTask();
     EXPECT_TRUE(client.vsyncTicked());
     client.reset();
@@ -72,13 +72,13 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
     controller.didBeginFrame();
 
     // Tell the controller the frame ended 5ms later
-    timeSource->setMonotonicallyIncreasingTimeMs(timeSource->monotonicallyIncreasingTimeMs() + 5);
+    timeSource->setMonotonicallyIncreasingTime(timeSource->monotonicallyIncreasingTime() + 0.005);
     controller.didFinishFrame();
 
     // Trigger another frame, make sure vsync runs again
-    elapsed += thread.pendingDelay();
-    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
-    timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+    elapsed += thread.pendingDelayMs() / 1000.0;
+    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+    timeSource->setMonotonicallyIncreasingTime(elapsed);
     thread.runPendingTask();
     EXPECT_TRUE(client.vsyncTicked());
 }
@@ -87,7 +87,7 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
 {
     FakeCCThread thread;
     FakeCCFrameRateControllerClient client;
-    RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+    RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
     CCFrameRateController controller(timeSource);
 
     controller.setClient(&client);
@@ -97,8 +97,8 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
     double elapsed = 0; // Muck around with time a bit
 
     // Trigger one frame, make sure the vsync callback is called
-    elapsed += thread.pendingDelay();
-    timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+    elapsed += thread.pendingDelayMs() / 1000.0;
+    timeSource->setMonotonicallyIncreasingTime(elapsed);
     thread.runPendingTask();
     EXPECT_TRUE(client.vsyncTicked());
     client.reset();
@@ -107,9 +107,9 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
     controller.didBeginFrame();
 
     // Trigger another frame, make sure vsync callback runs again
-    elapsed += thread.pendingDelay();
-    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
-    timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+    elapsed += thread.pendingDelayMs() / 1000.0;
+    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+    timeSource->setMonotonicallyIncreasingTime(elapsed);
     thread.runPendingTask();
     EXPECT_TRUE(client.vsyncTicked());
     client.reset();
@@ -118,23 +118,23 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
     controller.didBeginFrame();
 
     // Trigger another frame. Since two frames are pending, we should not draw.
-    elapsed += thread.pendingDelay();
-    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
-    timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+    elapsed += thread.pendingDelayMs() / 1000.0;
+    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+    timeSource->setMonotonicallyIncreasingTime(elapsed);
     thread.runPendingTask();
     EXPECT_FALSE(client.vsyncTicked());
 
     // Tell the controller the first frame ended 5ms later
-    timeSource->setMonotonicallyIncreasingTimeMs(timeSource->monotonicallyIncreasingTimeMs() + 5);
+    timeSource->setMonotonicallyIncreasingTime(timeSource->monotonicallyIncreasingTime() + 0.005);
     controller.didFinishFrame();
 
     // Tick should not have been called
     EXPECT_FALSE(client.vsyncTicked());
 
     // Trigger yet another frame. Since one frames is pending, another vsync callback should run.
-    elapsed += thread.pendingDelay();
-    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
-    timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+    elapsed += thread.pendingDelayMs() / 1000.0;
+    EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+    timeSource->setMonotonicallyIncreasingTime(elapsed);
     thread.runPendingTask();
     EXPECT_TRUE(client.vsyncTicked());
 }
index 9b5e0383e2ef406e1ff056f78eecffce24b3d838..39cf9e496338088dbd6545c252e1d41ea00b9405 100644 (file)
@@ -61,7 +61,7 @@ public:
         task->performTask();
     }
 
-    long long pendingDelay() const
+    long long pendingDelayMs() const
     {
         EXPECT_TRUE(hasPendingTask());
         return m_pendingTaskDelay;
@@ -107,20 +107,20 @@ protected:
 
 class FakeCCDelayBasedTimeSource : public WebCore::CCDelayBasedTimeSource {
 public:
-    static PassRefPtr<FakeCCDelayBasedTimeSource> create(double intervalMs, WebCore::CCThread* thread)
+    static PassRefPtr<FakeCCDelayBasedTimeSource> create(double interval, WebCore::CCThread* thread)
     {
-        return adoptRef(new FakeCCDelayBasedTimeSource(intervalMs, thread));
+        return adoptRef(new FakeCCDelayBasedTimeSource(interval, thread));
     }
 
-    void setMonotonicallyIncreasingTimeMs(double time) { m_monotonicallyIncreasingTimeMs = time; }
-    virtual double monotonicallyIncreasingTimeMs() const { return m_monotonicallyIncreasingTimeMs; }
+    void setMonotonicallyIncreasingTime(double time) { m_monotonicallyIncreasingTime = time; }
+    virtual double monotonicallyIncreasingTime() const { return m_monotonicallyIncreasingTime; }
 
 protected:
-    FakeCCDelayBasedTimeSource(double intervalMs, WebCore::CCThread* thread)
-        : CCDelayBasedTimeSource(intervalMs, thread)
-        , m_monotonicallyIncreasingTimeMs(0) { }
+    FakeCCDelayBasedTimeSource(double interval, WebCore::CCThread* thread)
+        : CCDelayBasedTimeSource(interval, thread)
+        , m_monotonicallyIncreasingTime(0) { }
 
-    double m_monotonicallyIncreasingTimeMs;
+    double m_monotonicallyIncreasingTime;
 };
 
 }
index 298b695628f1500d085556464c67d4a2b2436740..398fca56eb67efa677b8a8d08f353bce885066fa 100644 (file)
@@ -54,7 +54,7 @@ protected:
 TEST_F(CCTimerTest, OneShot)
 {
     CCTimer timer(&m_thread, this);
-    timer.startOneShot(1);
+    timer.startOneShot(0.001);
 
     m_thread.runPendingTask();
     EXPECT_TRUE(m_flag);
@@ -64,7 +64,7 @@ TEST_F(CCTimerTest, OneShot)
 TEST_F(CCTimerTest, StopManually)
 {
     CCTimer timer(&m_thread, this);
-    timer.startOneShot(1);
+    timer.startOneShot(0.001);
     timer.stop();
 
     m_thread.runPendingTask();
@@ -76,7 +76,7 @@ TEST_F(CCTimerTest, StopByScope)
 {
     {
         CCTimer timer(&m_thread, this);
-        timer.startOneShot(1);
+        timer.startOneShot(0.001);
     }
 
     m_thread.runPendingTask();