Diff
Modified: trunk/Source/WebCore/ChangeLog (102875 => 102876)
--- trunk/Source/WebCore/ChangeLog 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/ChangeLog 2011-12-15 04:37:54 UTC (rev 102876)
@@ -1,3 +1,27 @@
+2011-12-14 Nat Duca <[email protected]>
+
+ [chromium] Add inhibitDraw to CCScheduler and drop root impl to prevent background flash on tab restore
+ https://bugs.webkit.org/show_bug.cgi?id=74351
+
+ Reviewed by James Robinson.
+
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::setNeedsCommit):
+ (WebCore::CCLayerTreeHost::didBecomeInvisibleOnImplThread):
+ * platform/graphics/chromium/cc/CCScheduler.cpp:
+ (WebCore::CCScheduler::getNextAction):
+ (WebCore::CCScheduler::processScheduledActions):
+ * platform/graphics/chromium/cc/CCScheduler.h:
+ * platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp:
+ (WebCore::CCSchedulerStateMachine::CCSchedulerStateMachine):
+ (WebCore::CCSchedulerStateMachine::nextAction):
+ * platform/graphics/chromium/cc/CCSchedulerStateMachine.h:
+ (WebCore::CCSchedulerStateMachine::setInhibitDraw):
+ * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+ (WebCore::CCThreadProxy::setVisibleOnImplThread):
+ (WebCore::CCThreadProxy::inhibitDraw):
+ * platform/graphics/chromium/cc/CCThreadProxy.h:
+
2011-12-14 Ken Buchanan <[email protected]>
Crash due to incorrect parsing of isolates
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -219,10 +219,9 @@
void CCLayerTreeHost::setNeedsCommit()
{
- if (CCThreadProxy::implThread()) {
- TRACE_EVENT("CCLayerTreeHost::setNeedsCommit", this, 0);
+ if (CCThreadProxy::implThread())
m_proxy->setNeedsCommit();
- } else
+ else
m_client->scheduleComposite();
}
@@ -287,6 +286,18 @@
contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes(viewportSize()));
contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
}
+
+ // Ensure that the dropped tiles are propagated to the impl tree.
+ // If the frontbuffer is cached, then clobber the impl tree. Otherwise,
+ // push over the tree changes.
+ if (m_proxy->layerRendererCapabilities().contextHasCachedFrontBuffer) {
+ hostImpl->setRootLayer(0);
+ return;
+ }
+ if (rootLayer())
+ hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->rootLayer()));
+ else
+ hostImpl->setRootLayer(0);
}
void CCLayerTreeHost::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -81,6 +81,15 @@
updateMaxScrollPosition();
}
+bool CCLayerTreeHostImpl::canDraw()
+{
+ if (!rootLayer())
+ return false;
+ if (viewportSize().isEmpty())
+ return false;
+ return true;
+}
+
GraphicsContext3D* CCLayerTreeHostImpl::context()
{
return m_layerRenderer ? m_layerRenderer->context() : 0;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h 2011-12-15 04:37:54 UTC (rev 102876)
@@ -78,6 +78,7 @@
virtual void animate(double frameDisplayTimeMs);
virtual void drawLayers();
+ bool canDraw();
GraphicsContext3D* context();
void finishAllRendering();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -105,17 +105,23 @@
m_stateMachine.didLeaveVSync();
}
+CCSchedulerStateMachine::Action CCScheduler::nextAction()
+{
+ m_stateMachine.setCanDraw(m_client->canDraw());
+ return m_stateMachine.nextAction();
+}
+
void CCScheduler::processScheduledActions()
{
// Early out so we don't spam TRACE_EVENTS with useless processScheduledActions.
- if (m_stateMachine.nextAction() == CCSchedulerStateMachine::ACTION_NONE)
+ if (nextAction() == CCSchedulerStateMachine::ACTION_NONE)
return;
// This function can re-enter itself. For example, draw may call
// setNeedsCommit. Proceeed with caution.
CCSchedulerStateMachine::Action action;
do {
- action = ""
+ action = ""
m_stateMachine.updateState(action);
switch (action) {
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScheduler.h 2011-12-15 04:37:54 UTC (rev 102876)
@@ -37,6 +37,7 @@
class CCSchedulerClient {
public:
+ virtual bool canDraw() = 0;
virtual bool hasMoreResourceUpdates() const = 0;
virtual void scheduledActionBeginFrame() = 0;
@@ -81,6 +82,7 @@
private:
CCScheduler(CCSchedulerClient*, PassOwnPtr<CCFrameRateController>);
+ CCSchedulerStateMachine::Action nextAction();
void processScheduledActions();
CCSchedulerClient* m_client;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -37,12 +37,13 @@
, m_needsCommit(false)
, m_updateMoreResourcesPending(false)
, m_insideVSync(false)
- , m_visible(false) { }
+ , m_visible(false)
+ , m_canDraw(true) { }
CCSchedulerStateMachine::Action CCSchedulerStateMachine::nextAction() const
{
bool canDraw = m_currentFrameNumber != m_lastFrameNumberWhereDrawWasCalled;
- bool shouldDraw = (m_needsRedraw && m_insideVSync && m_visible && canDraw) || m_needsForcedRedraw;
+ bool shouldDraw = (m_needsRedraw && m_insideVSync && m_visible && canDraw && m_canDraw) || m_needsForcedRedraw;
switch (m_commitState) {
case COMMIT_STATE_IDLE:
if (shouldDraw)
@@ -69,6 +70,10 @@
case COMMIT_STATE_WAITING_FOR_FIRST_DRAW:
if (shouldDraw)
return ACTION_DRAW;
+ // COMMIT_STATE_WAITING_FOR_FIRST_DRAW wants to enforce a draw. If m_canDraw is false,
+ // proceed to the next step (similar as in COMMIT_STATE_IDLE).
+ if (!m_canDraw && m_needsCommit && m_visible)
+ return ACTION_BEGIN_FRAME;
return ACTION_NONE;
}
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSchedulerStateMachine.h 2011-12-15 04:37:54 UTC (rev 102876)
@@ -98,6 +98,11 @@
// from nextState. Indicates that the specific update request completed.
void beginUpdateMoreResourcesComplete(bool morePending);
+ // Indicates whether drawing would, at this time, make sense.
+ // canDraw can be used to supress flashes or checkerboarding
+ // when such behavior would be undesirable.
+ void setCanDraw(bool can) { m_canDraw = can; }
+
protected:
CommitState m_commitState;
@@ -109,6 +114,7 @@
bool m_updateMoreResourcesPending;
bool m_insideVSync;
bool m_visible;
+ bool m_canDraw;
};
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -239,12 +239,15 @@
void CCThreadProxy::setVisibleOnImplThread(CCCompletionEvent* completion, bool visible)
{
ASSERT(isImplThread());
- if (!visible)
+ m_schedulerOnImplThread->setVisible(visible);
+ m_layerTreeHostImpl->setVisible(visible);
+ if (!visible) {
m_layerTreeHost->didBecomeInvisibleOnImplThread(m_layerTreeHostImpl.get());
- else
+ // as partial or all the textures may be evicted in didBecomeInvisibleOnImplThread,
+ // schedule a commit which will be executed when it goes to visible again.
+ m_schedulerOnImplThread->setNeedsCommit();
+ } else
m_schedulerOnImplThread->setNeedsRedraw();
- m_schedulerOnImplThread->setVisible(visible);
- m_layerTreeHostImpl->setVisible(visible);
completion->signal();
}
@@ -425,6 +428,14 @@
return m_currentTextureUpdaterOnImplThread->hasMoreUpdates();
}
+bool CCThreadProxy::canDraw()
+{
+ ASSERT(isImplThread());
+ if (!m_layerTreeHostImpl)
+ return false;
+ return m_layerTreeHostImpl->canDraw();
+}
+
void CCThreadProxy::scheduledActionUpdateMoreResources()
{
TRACE_EVENT("CCThreadProxy::scheduledActionUpdateMoreResources", this, 0);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h (102875 => 102876)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h 2011-12-15 04:37:54 UTC (rev 102876)
@@ -69,6 +69,7 @@
virtual void setNeedsCommitOnImplThread();
// CCSchedulerClient implementation
+ virtual bool canDraw();
virtual bool hasMoreResourceUpdates() const;
virtual void scheduledActionBeginFrame();
virtual void scheduledActionDrawAndSwap();
Modified: trunk/Source/WebKit/chromium/ChangeLog (102875 => 102876)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-12-15 04:37:54 UTC (rev 102876)
@@ -1,3 +1,19 @@
+2011-12-14 Nat Duca <[email protected]>
+
+ [chromium] Add inhibitDraw to CCScheduler and drop root impl to prevent background flash on tab restore
+ https://bugs.webkit.org/show_bug.cgi?id=74351
+
+ Reviewed by James Robinson.
+
+ * tests/CCSchedulerStateMachineTest.cpp:
+ (WebCore::StateMachine::inhibitDraw):
+ (WebCore::TEST):
+ * tests/CCSchedulerTest.cpp:
+ (WebKitTests::FakeCCSchedulerClient::setInhibitDraw):
+ (WebKitTests::FakeCCSchedulerClient::inhibitDraw):
+ (WebKitTests::SchedulerClientThatSetNeedsDrawInsideDraw::inhibitDraw):
+ (WebKitTests::SchedulerClientThatSetNeedsCommitInsideDraw::inhibitDraw):
+
2011-12-14 Jing Zhao <[email protected]>
Opening two popup menus by dispatchEvent() makes problems.
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (102875 => 102876)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -103,7 +103,12 @@
public:
static PassRefPtr<MockLayerTreeHost> create(TestHooks* testHooks, CCLayerTreeHostClient* client, PassRefPtr<LayerChromium> rootLayer, const CCSettings& settings)
{
- return adoptRef(new MockLayerTreeHost(testHooks, client, rootLayer, settings));
+ RefPtr<MockLayerTreeHost> layerTreeHost = adoptRef(new MockLayerTreeHost(testHooks, client, rootLayer, settings));
+
+ // LayerTreeHostImpl won't draw if it has 1x1 viewport.
+ layerTreeHost->setViewport(IntSize(1, 1));
+
+ return layerTreeHost;
}
virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient* client)
Modified: trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp (102875 => 102876)
--- trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebKit/chromium/tests/CCSchedulerStateMachineTest.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -58,6 +58,7 @@
void setNeedsForcedRedraw(bool b) { m_needsForcedRedraw = b; }
bool needsForcedRedraw() const { return m_needsForcedRedraw; }
+ bool canDraw() const { return m_canDraw; }
bool insideVSync() const { return m_insideVSync; }
bool visible() const { return m_visible; }
@@ -244,6 +245,38 @@
}
}
+TEST(CCSchedulerStateMachineTest, TestCanRedraw_StopsDraw)
+{
+ size_t numCommitStates = sizeof(allCommitStates) / sizeof(CCSchedulerStateMachine::CommitState);
+ for (size_t i = 0; i < numCommitStates; ++i) {
+ // There shouldn't be any drawing regardless of vsync.
+ for (unsigned j = 0; j < 2; ++j) {
+ StateMachine state;
+ state.setCommitState(allCommitStates[i]);
+ state.setVisible(false);
+ state.setNeedsRedraw(true);
+ state.setNeedsForcedRedraw(false);
+ if (j == 1)
+ state.didEnterVSync();
+
+ state.setCanDraw(false);
+ EXPECT_NE(CCSchedulerStateMachine::ACTION_DRAW, state.nextAction());
+ }
+ }
+}
+
+TEST(CCSchedulerStateMachineTest, TestCanRedrawWithWaitingForFirstDrawMakesProgress)
+{
+ StateMachine state;
+ state.setCommitState(CCSchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW);
+ state.setNeedsCommit(true);
+ state.setNeedsRedraw(true);
+ state.setUpdateMoreResourcesPending(false);
+ state.setVisible(true);
+ state.setCanDraw(false);
+ EXPECT_EQ(CCSchedulerStateMachine::ACTION_BEGIN_FRAME, state.nextAction());
+}
+
TEST(CCSchedulerStateMachineTest, TestUpdates_NoRedraw_OneRoundOfUpdates)
{
StateMachine state;
Modified: trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp (102875 => 102876)
--- trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp 2011-12-15 04:19:24 UTC (rev 102875)
+++ trunk/Source/WebKit/chromium/tests/CCSchedulerTest.cpp 2011-12-15 04:37:54 UTC (rev 102876)
@@ -44,13 +44,16 @@
{
m_actions.clear();
m_hasMoreResourceUpdates = false;
+ m_canDraw = true;
}
void setHasMoreResourceUpdates(bool b) { m_hasMoreResourceUpdates = b; }
+ void setCanDraw(bool b) { m_canDraw = b; }
int numActions() const { return static_cast<int>(m_actions.size()); }
const char* action(int i) const { return m_actions[i]; }
+ virtual bool canDraw() { return m_canDraw; }
virtual bool hasMoreResourceUpdates() const { return m_hasMoreResourceUpdates; }
virtual void scheduledActionBeginFrame() { m_actions.push_back("scheduledActionBeginFrame"); }
virtual void scheduledActionDrawAndSwap() { m_actions.push_back("scheduledActionDrawAndSwap"); }
@@ -59,6 +62,7 @@
protected:
bool m_hasMoreResourceUpdates;
+ bool m_canDraw;
std::vector<const char*> m_actions;
};
@@ -139,6 +143,7 @@
int numDraws() const { return m_numDraws; }
virtual bool hasMoreResourceUpdates() const { return false; }
+ virtual bool canDraw() { return true; }
virtual void scheduledActionBeginFrame() { }
virtual void scheduledActionDrawAndSwap()
{
@@ -192,6 +197,7 @@
int numDraws() const { return m_numDraws; }
virtual bool hasMoreResourceUpdates() const { return false; }
+ virtual bool canDraw() { return true; }
virtual void scheduledActionBeginFrame() { }
virtual void scheduledActionDrawAndSwap()
{