[Chromium] Unnecessary delay when starting to update resources with an inactive vsync...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 15:42:33 +0000 (15:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 15:42:33 +0000 (15:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94719

Patch by David Reveman <reveman@chromium.org> on 2012-08-23
Reviewed by James Robinson.

Source/WebCore:

Replace nextTickTime() with nextTickTimeIfActivated() and return
appropriate value when timer is inactive.

No new tests.

* platform/graphics/chromium/cc/CCDelayBasedTimeSource.cpp:
(WebCore::CCDelayBasedTimeSource::nextTickTimeIfActivated):
(WebCore::CCDelayBasedTimeSource::nextTickTarget):
(WebCore):
(WebCore::CCDelayBasedTimeSource::postNextTickTask):
* platform/graphics/chromium/cc/CCDelayBasedTimeSource.h:
* platform/graphics/chromium/cc/CCFrameRateController.cpp:
(WebCore::CCFrameRateController::nextTickTimeIfActivated):
* platform/graphics/chromium/cc/CCFrameRateController.h:
(CCFrameRateController):
* platform/graphics/chromium/cc/CCScheduler.cpp:
(WebCore::CCScheduler::processScheduledActions):
* platform/graphics/chromium/cc/CCTimeSource.h:
(CCTimeSource):

Source/WebKit/chromium:

* tests/CCSchedulerTestCommon.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.cpp
Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.h
Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.cpp
Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.h
Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTimeSource.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCSchedulerTestCommon.h

index 0d4f8e0..b0de82c 100644 (file)
@@ -1,3 +1,30 @@
+2012-08-23  David Reveman  <reveman@chromium.org>
+
+        [Chromium] Unnecessary delay when starting to update resources with an inactive vsync timer.
+        https://bugs.webkit.org/show_bug.cgi?id=94719
+
+        Reviewed by James Robinson.
+
+        Replace nextTickTime() with nextTickTimeIfActivated() and return
+        appropriate value when timer is inactive.
+
+        No new tests.
+
+        * platform/graphics/chromium/cc/CCDelayBasedTimeSource.cpp:
+        (WebCore::CCDelayBasedTimeSource::nextTickTimeIfActivated):
+        (WebCore::CCDelayBasedTimeSource::nextTickTarget):
+        (WebCore):
+        (WebCore::CCDelayBasedTimeSource::postNextTickTask):
+        * platform/graphics/chromium/cc/CCDelayBasedTimeSource.h:
+        * platform/graphics/chromium/cc/CCFrameRateController.cpp:
+        (WebCore::CCFrameRateController::nextTickTimeIfActivated):
+        * platform/graphics/chromium/cc/CCFrameRateController.h:
+        (CCFrameRateController):
+        * platform/graphics/chromium/cc/CCScheduler.cpp:
+        (WebCore::CCScheduler::processScheduledActions):
+        * platform/graphics/chromium/cc/CCTimeSource.h:
+        (CCTimeSource):
+
 2012-08-23  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: make treeoutline.js compiler-friendly
index 2711740..c2a8892 100644 (file)
@@ -97,9 +97,9 @@ double CCDelayBasedTimeSource::lastTickTime()
     return m_lastTickTime;
 }
 
-double CCDelayBasedTimeSource::nextTickTime()
+double CCDelayBasedTimeSource::nextTickTimeIfActivated()
 {
-    return active() ? m_currentParameters.tickTarget : 0.0;
+    return active() ? m_currentParameters.tickTarget : nextTickTarget(monotonicTimeNow());
 }
 
 void CCDelayBasedTimeSource::onTimerFired()
@@ -207,7 +207,7 @@ double CCDelayBasedTimeSource::monotonicTimeNow() const
 //      now=37   tickTarget=16.667  newTarget=50.000  --> tick(), postDelayedTask(floor(50.000-37)) --> postDelayedTask(13)
 //
 // Note, that in the above discussion, times are expressed in milliseconds, but in the code, seconds are used.
-void CCDelayBasedTimeSource::postNextTickTask(double now)
+double CCDelayBasedTimeSource::nextTickTarget(double now)
 {
     double newInterval = m_nextParameters.interval;
     double intervalsElapsed = floor((now - m_nextParameters.tickTarget) / newInterval);
@@ -221,9 +221,16 @@ void CCDelayBasedTimeSource::postNextTickTask(double now)
     if (newTickTarget - m_lastTickTime <= newInterval * doubleTickThreshold)
         newTickTarget += newInterval;
 
+    return newTickTarget;
+}
+
+void CCDelayBasedTimeSource::postNextTickTask(double now)
+{
+    double newTickTarget = nextTickTarget(now);
+
     // Post another task *before* the tick and update state
     double delay = newTickTarget - now;
-    ASSERT(delay <= newInterval * (1.0 + doubleTickThreshold));
+    ASSERT(delay <= m_nextParameters.interval * (1.0 + doubleTickThreshold));
     m_timer.startOneShot(delay);
 
     m_nextParameters.tickTarget = newTickTarget;
index f998374..c68dc0b 100644 (file)
@@ -50,9 +50,8 @@ public:
     virtual bool active() const OVERRIDE { return m_state != STATE_INACTIVE; }
 
     // Get the last and next tick times.
-    // If not active, nextTickTime will return 0.
     virtual double lastTickTime() OVERRIDE;
-    virtual double nextTickTime() OVERRIDE;
+    virtual double nextTickTimeIfActivated() OVERRIDE;
 
     // CCTimerClient implementation.
     virtual void onTimerFired() OVERRIDE;
@@ -62,6 +61,7 @@ public:
 
 protected:
     CCDelayBasedTimeSource(double interval, CCThread*);
+    double nextTickTarget(double now);
     void postNextTickTask(double now);
 
     enum State {
index 5b00fef..8d85fb3 100644 (file)
@@ -151,10 +151,10 @@ void CCFrameRateController::didAbortAllPendingFrames()
     m_numFramesPending = 0;
 }
 
-double CCFrameRateController::nextTickTime()
+double CCFrameRateController::nextTickTimeIfActivated()
 {
     if (m_isTimeSourceThrottling)
-        return m_timeSource->nextTickTime();
+        return m_timeSource->nextTickTimeIfActivated();
 
     return monotonicallyIncreasingTime();
 }
index 13d853b..11b29a7 100644 (file)
@@ -67,7 +67,7 @@ public:
     void didFinishFrame();
     void didAbortAllPendingFrames();
     void setMaxFramesPending(int); // 0 for unlimited.
-    double nextTickTime();
+    double nextTickTimeIfActivated();
 
     void setTimebaseAndInterval(double timebase, double intervalSeconds);
 
index fa3dbe1..999a08e 100644 (file)
@@ -175,7 +175,7 @@ void CCScheduler::processScheduledActions()
             break;
         case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES:
             if (m_client->hasMoreResourceUpdates()) {
-                m_client->scheduledActionUpdateMoreResources(m_frameRateController->nextTickTime());
+                m_client->scheduledActionUpdateMoreResources(m_frameRateController->nextTickTimeIfActivated());
                 m_updateMoreResourcesPending = true;
             } else
                 m_stateMachine.beginUpdateMoreResourcesComplete(false);
index c6309d2..426a253 100644 (file)
@@ -52,7 +52,7 @@ public:
     virtual bool active() const = 0;
     virtual void setTimebaseAndInterval(double timebase, double intervalSeconds) = 0;
     virtual double lastTickTime() = 0;
-    virtual double nextTickTime() = 0;
+    virtual double nextTickTimeIfActivated() = 0;
 };
 
 }
index 396cc11..af50068 100644 (file)
@@ -1,3 +1,12 @@
+2012-08-23  David Reveman  <reveman@chromium.org>
+
+        [Chromium] Unnecessary delay when starting to update resources with an inactive vsync timer.
+        https://bugs.webkit.org/show_bug.cgi?id=94719
+
+        Reviewed by James Robinson.
+
+        * tests/CCSchedulerTestCommon.h:
+
 2012-08-23  Peter Beverloo  <peter@chromium.org>
 
         Unreviewed.  Rolled DEPS.
index 824af26..a504b60 100644 (file)
@@ -106,7 +106,7 @@ public:
     virtual bool active() const OVERRIDE { return m_active; }
     virtual void setTimebaseAndInterval(double timebase, double interval) OVERRIDE { }
     virtual double lastTickTime() OVERRIDE { return 0; }
-    virtual double nextTickTime() OVERRIDE { return 0; }
+    virtual double nextTickTimeIfActivated() OVERRIDE { return 0; }
 
     void tick()
     {