Diff
Modified: trunk/Source/WebCore/ChangeLog (104843 => 104844)
--- trunk/Source/WebCore/ChangeLog 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/ChangeLog 2012-01-12 20:14:49 UTC (rev 104844)
@@ -1,3 +1,25 @@
+2012-01-12 Nat Duca <[email protected]>
+
+ [chromium] Turn off FrameRateController timesource when it is not needed
+ https://bugs.webkit.org/show_bug.cgi?id=76149
+
+ Reviewed by James Robinson.
+
+ * platform/graphics/chromium/cc/CCDelayBasedTimeSource.h:
+ (WebCore::CCDelayBasedTimeSource::active):
+ * platform/graphics/chromium/cc/CCFrameRateController.cpp:
+ (WebCore::CCFrameRateController::setActive):
+ (WebCore::CCFrameRateController::onTimerTick):
+ * platform/graphics/chromium/cc/CCFrameRateController.h:
+ * platform/graphics/chromium/cc/CCScheduler.cpp:
+ (WebCore::CCScheduler::CCScheduler):
+ (WebCore::CCScheduler::setVisible):
+ (WebCore::CCScheduler::processScheduledActions):
+ * platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp:
+ (WebCore::CCSchedulerStateMachine::vsyncCallbackNeeded):
+ * platform/graphics/chromium/cc/CCSchedulerStateMachine.h:
+ * platform/graphics/chromium/cc/CCTimeSource.h:
+
2012-01-12 Anders Carlsson <[email protected]>
Move snapRubberBandTimerFired to ScrollElasticityController
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.h (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.h 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCDelayBasedTimeSource.h 2012-01-12 20:14:49 UTC (rev 104844)
@@ -45,6 +45,7 @@
virtual void setClient(CCTimeSourceClient* client) { m_client = client; }
virtual void setActive(bool);
+ virtual bool active() const { return m_state != STATE_INACTIVE; }
// CCTimerClient implementation.
virtual void onTimerFired();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.cpp (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.cpp 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.cpp 2012-01-12 20:14:49 UTC (rev 104844)
@@ -26,6 +26,7 @@
#include "cc/CCFrameRateController.h"
+#include "TraceEvent.h"
#include "cc/CCThread.h"
#include "cc/CCThreadTask.h"
@@ -62,6 +63,14 @@
m_timeSource->setActive(false);
}
+void CCFrameRateController::setActive(bool active)
+{
+ if (m_timeSource->active() == active)
+ return;
+ TRACE_EVENT("CCFrameRateController::setActive", 0, (active ? "active" : "inactive"));
+ m_timeSource->setActive(active);
+}
+
void CCFrameRateController::setMaxFramesPending(int maxFramesPending)
{
m_maxFramesPending = maxFramesPending;
@@ -69,9 +78,13 @@
void CCFrameRateController::onTimerTick()
{
+ ASSERT(m_timeSource->active());
+
// Don't forward the tick if we have too many frames in flight.
- if (m_maxFramesPending && m_numFramesPending >= m_maxFramesPending)
+ if (m_maxFramesPending && m_numFramesPending >= m_maxFramesPending) {
+ TRACE_EVENT("CCFrameRateController::onTimerTickButMaxFramesPending", 0, 0);
return;
+ }
if (m_client)
m_client->beginFrame();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.h (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.h 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFrameRateController.h 2012-01-12 20:14:49 UTC (rev 104844)
@@ -50,9 +50,10 @@
void setClient(CCFrameRateControllerClient* client) { m_client = client; }
- void setActive(bool active) { m_timeSource->setActive(active); }
+ void setActive(bool);
void setMaxPendingFrames(int);
+
// Use the following methods to adjust target frame rate.
//
// Multiple frames can be in-progress, but for every didBeginFrame, a
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp 2012-01-12 20:14:49 UTC (rev 104844)
@@ -36,9 +36,7 @@
{
ASSERT(m_client);
m_frameRateController->setClient(this);
-
- // FIXME: make the CCSchedulerStateMachine turn off FrameRateController it isn't needed.
- m_frameRateController->setActive(true);
+ m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
}
CCScheduler::~CCScheduler()
@@ -49,7 +47,9 @@
void CCScheduler::setVisible(bool visible)
{
m_stateMachine.setVisible(visible);
+ processScheduledActions();
}
+
void CCScheduler::setNeedsCommit()
{
m_stateMachine.setNeedsCommit();
@@ -114,8 +114,10 @@
void CCScheduler::processScheduledActions()
{
// Early out so we don't spam TRACE_EVENTS with useless processScheduledActions.
- if (nextAction() == CCSchedulerStateMachine::ACTION_NONE)
+ if (nextAction() == CCSchedulerStateMachine::ACTION_NONE) {
+ m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
return;
+ }
// This function can re-enter itself. For example, draw may call
// setNeedsCommit. Proceeed with caution.
@@ -151,6 +153,9 @@
break;
}
} while (action != CCSchedulerStateMachine::ACTION_NONE);
+
+ // Activate or deactivate the frame rate controller.
+ m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp 2012-01-12 20:14:49 UTC (rev 104844)
@@ -118,6 +118,18 @@
}
}
+bool CCSchedulerStateMachine::vsyncCallbackNeeded() const
+{
+ if (!m_visible) {
+ if (m_needsForcedRedraw)
+ return true;
+
+ return false;
+ }
+
+ return m_needsRedraw || m_needsForcedRedraw || m_updateMoreResourcesPending;
+}
+
void CCSchedulerStateMachine::didEnterVSync()
{
m_insideVSync = true;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h 2012-01-12 20:14:49 UTC (rev 104844)
@@ -68,6 +68,10 @@
Action nextAction() const;
void updateState(Action);
+ // Indicates whether the scheduler needs a vsync callback in order to make
+ // progress.
+ bool vsyncCallbackNeeded() const;
+
// Indicates that the system has entered and left a vsync callback.
// The scheduler will not draw more than once in a given vsync callback.
void didEnterVSync();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTimeSource.h (104843 => 104844)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTimeSource.h 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTimeSource.h 2012-01-12 20:14:49 UTC (rev 104844)
@@ -49,6 +49,7 @@
virtual ~CCTimeSource() { }
virtual void setClient(CCTimeSourceClient*) = 0;
virtual void setActive(bool) = 0;
+ virtual bool active() const = 0;
};
}
Modified: trunk/Source/WebKit/chromium/ChangeLog (104843 => 104844)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-01-12 20:14:49 UTC (rev 104844)
@@ -1,3 +1,21 @@
+2012-01-12 Nat Duca <[email protected]>
+
+ [chromium] Turn off FrameRateController timesource when it is not needed
+ https://bugs.webkit.org/show_bug.cgi?id=76149
+
+ Reviewed by James Robinson.
+
+ * tests/CCDelayBasedTimeSourceTest.cpp:
+ (WebKitTests::TEST):
+ * tests/CCLayerTreeHostTest.cpp:
+ (WTF::CCLayerTreeHostTest::timeout):
+ * tests/CCSchedulerStateMachineTest.cpp:
+ (WebCore::TEST):
+ * tests/CCSchedulerTest.cpp:
+ (WebKitTests::TEST):
+ * tests/CCSchedulerTestCommon.h:
+ (WebKitTests::FakeCCTimeSource::active):
+
2012-01-12 Sheriff Bot <[email protected]>
Unreviewed. Rolled DEPS.
Modified: trunk/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp (104843 => 104844)
--- trunk/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebKit/chromium/tests/CCDelayBasedTimeSourceTest.cpp 2012-01-12 20:14:49 UTC (rev 104844)
@@ -46,10 +46,12 @@
timer->setMonotonicallyIncreasingTimeMs(0);
timer->setActive(true);
+ EXPECT_TRUE(timer->active());
EXPECT_TRUE(thread.hasPendingTask());
timer->setMonotonicallyIncreasingTimeMs(16);
thread.runPendingTask();
+ EXPECT_TRUE(timer->active());
EXPECT_TRUE(client.tickCalled());
}
Modified: trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp (104843 => 104844)
--- trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp 2012-01-12 20:14:49 UTC (rev 104844)
@@ -77,8 +77,11 @@
state.setUpdateMoreResourcesPending(false);
state.setVisible(true);
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
+
state.didLeaveVSync();
EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
state.didEnterVSync();
EXPECT_EQ(CCSchedulerStateMachine::ACTION_NONE, state.nextAction());
}
@@ -91,6 +94,7 @@
state.setNeedsCommit(true);
state.setUpdateMoreResourcesPending(false);
state.setVisible(true);
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
}
// Begin the frame, make sure needsCommit and commitState update correctly.
@@ -100,6 +104,7 @@
state.updateState(CCSchedulerStateMachine::ACTION_BEGIN_FRAME);
EXPECT_EQ(CCSchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, state.commitState());
EXPECT_FALSE(state.needsCommit());
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
}
}
@@ -108,6 +113,7 @@
CCSchedulerStateMachine state;
state.setNeedsForcedRedraw();
EXPECT_FALSE(state.redrawPending());
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
}
TEST(CCSchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame)
@@ -115,6 +121,7 @@
CCSchedulerStateMachine state;
state.setVisible(true);
state.setNeedsRedraw();
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
state.didEnterVSync();
EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
state.updateState(CCSchedulerStateMachine::ACTION_DRAW);
@@ -126,10 +133,12 @@
// Move to another frame. This should now draw.
state.didLeaveVSync();
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
state.didEnterVSync();
EXPECT_EQ(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
state.updateState(CCSchedulerStateMachine::ACTION_DRAW);
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
}
TEST(CCSchedulerStateMachineTest, TestNextActionDrawsOnVSync)
@@ -140,34 +149,42 @@
for (unsigned j = 0; j < 2; ++j) {
StateMachine state;
state.setCommitState(allCommitStates[i]);
- if (!j) {
+ bool visible = j;
+ if (!visible) {
state.didEnterVSync();
state.setVisible(false);
- }
+ } else
+ state.setVisible(true);
// Case 1: needsCommit=false updateMoreResourcesPending=false.
state.setNeedsCommit(false);
state.setUpdateMoreResourcesPending(false);
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
// Case 2: needsCommit=false updateMoreResourcesPending=true.
state.setNeedsCommit(false);
state.setUpdateMoreResourcesPending(true);
+ if (visible)
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
// Case 3: needsCommit=true updateMoreResourcesPending=false.
state.setNeedsCommit(true);
state.setUpdateMoreResourcesPending(false);
+ EXPECT_FALSE(state.vsyncCallbackNeeded());
EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
// Case 4: needsCommit=true updateMoreResourcesPending=true.
state.setNeedsCommit(true);
state.setUpdateMoreResourcesPending(true);
+ if (visible)
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
}
}
- // When on vsync, or not on vsync but needsForcedRedraw set, should always draw expect if you're ready to commit, in which case commit.
+ // When on vsync, or not on vsync but needsForcedRedraw set, should always draw except if you're ready to commit, in which case commit.
for (size_t i = 0; i < numCommitStates; ++i) {
for (unsigned j = 0; j < 2; ++j) {
StateMachine state;
@@ -188,21 +205,25 @@
// Case 1: needsCommit=false updateMoreResourcesPending=false.
state.setNeedsCommit(false);
state.setUpdateMoreResourcesPending(false);
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_EQ(expectedAction, state.nextAction());
// Case 2: needsCommit=false updateMoreResourcesPending=true.
state.setNeedsCommit(false);
state.setUpdateMoreResourcesPending(true);
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_EQ(expectedAction, state.nextAction());
// Case 3: needsCommit=true updateMoreResourcesPending=false.
state.setNeedsCommit(true);
state.setUpdateMoreResourcesPending(false);
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_EQ(expectedAction, state.nextAction());
// Case 4: needsCommit=true updateMoreResourcesPending=true.
state.setNeedsCommit(true);
state.setUpdateMoreResourcesPending(true);
+ EXPECT_TRUE(state.vsyncCallbackNeeded());
EXPECT_EQ(expectedAction, state.nextAction());
}
}
Modified: trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp (104843 => 104844)
--- trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp 2012-01-12 20:14:49 UTC (rev 104844)
@@ -77,6 +77,7 @@
scheduler->setNeedsCommit();
EXPECT_EQ(1, client.numActions());
EXPECT_STREQ("scheduledActionBeginFrame", client.action(0));
+ EXPECT_FALSE(timeSource->active());
client.reset();
// Since, hasMoreResourceUpdates is set to false,
@@ -86,17 +87,18 @@
EXPECT_EQ(2, client.numActions());
EXPECT_STREQ("scheduledActionUpdateMoreResources", client.action(0));
EXPECT_STREQ("scheduledActionCommit", client.action(1));
+ EXPECT_TRUE(timeSource->active());
client.reset();
// Tick should draw.
timeSource->tick();
EXPECT_EQ(1, client.numActions());
EXPECT_STREQ("scheduledActionDrawAndSwap", client.action(0));
+ EXPECT_FALSE(timeSource->active());
client.reset();
- // Tick should do nothing.
- timeSource->tick();
- EXPECT_EQ(0, client.numActions());
+ // Timer should be off.
+ EXPECT_FALSE(timeSource->active());
}
TEST(CCSchedulerTest, RequestCommitAfterBeginFrame)
@@ -126,6 +128,7 @@
// Tick should draw but then begin another frame.
timeSource->tick();
+ EXPECT_FALSE(timeSource->active());
EXPECT_EQ(2, client.numActions());
EXPECT_STREQ("scheduledActionDrawAndSwap", client.action(0));
EXPECT_STREQ("scheduledActionBeginFrame", client.action(1));
@@ -175,15 +178,18 @@
scheduler->setNeedsRedraw();
EXPECT_TRUE(scheduler->redrawPending());
+ EXPECT_TRUE(timeSource->active());
EXPECT_EQ(0, client.numDraws());
timeSource->tick();
EXPECT_EQ(1, client.numDraws());
EXPECT_TRUE(scheduler->redrawPending());
+ EXPECT_TRUE(timeSource->active());
timeSource->tick();
EXPECT_EQ(2, client.numDraws());
EXPECT_FALSE(scheduler->redrawPending());
+ EXPECT_FALSE(timeSource->active());
}
class SchedulerClientThatSetNeedsCommitInsideDraw : public CCSchedulerClient {
@@ -228,14 +234,17 @@
scheduler->setNeedsRedraw();
EXPECT_TRUE(scheduler->redrawPending());
EXPECT_EQ(0, client.numDraws());
+ EXPECT_TRUE(timeSource->active());
timeSource->tick();
+ EXPECT_FALSE(timeSource->active());
EXPECT_EQ(1, client.numDraws());
EXPECT_TRUE(scheduler->commitPending());
scheduler->beginFrameComplete();
timeSource->tick();
EXPECT_EQ(2, client.numDraws());
+ EXPECT_FALSE(timeSource->active());
EXPECT_FALSE(scheduler->redrawPending());
}
Modified: trunk/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h (104843 => 104844)
--- trunk/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h 2012-01-12 20:06:34 UTC (rev 104843)
+++ trunk/Source/WebKit/chromium/tests/CCSchedulerTestCommon.h 2012-01-12 20:14:49 UTC (rev 104844)
@@ -91,6 +91,7 @@
virtual void setClient(WebCore::CCTimeSourceClient* client) { m_client = client; }
virtual void setActive(bool b) { m_active = b; }
+ virtual bool active() const { return m_active; }
void tick()
{