Commit fbf77513 authored by enne@chromium.org's avatar enne@chromium.org

cc: Block the main thread for texture layers during impl-side painting

This patch adds an additional completion event to thread proxy.  Right now, it checks for the lack of a pending tree after drawing (which is currently where tree activation is triggered).

R=nduca@chromium.org
BUG=164993


Review URL: https://chromiumcodereview.appspot.com/11710004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177218 0039d316-1c4b-4281-b951-d872f2087c98
parent 2f64f355
......@@ -132,6 +132,22 @@ bool Layer::canClipSelf() const
return false;
}
bool Layer::blocksPendingCommitRecursive() const
{
if (blocksPendingCommit())
return true;
if (maskLayer() && maskLayer()->blocksPendingCommitRecursive())
return true;
if (replicaLayer() && replicaLayer()->blocksPendingCommitRecursive())
return true;
for (size_t i = 0; i < m_children.size(); ++i)
{
if (m_children[i]->blocksPendingCommitRecursive())
return true;
}
return false;
}
void Layer::setParent(Layer* layer)
{
DCHECK(!layer || !layer->hasAncestor(this));
......
......@@ -286,6 +286,8 @@ public:
// compatible with the main thread running freely, such as a double-buffered
// canvas that doesn't want to be triple-buffered across all three trees.
virtual bool blocksPendingCommit() const;
// Returns true if anything in this tree blocksPendingCommit.
bool blocksPendingCommitRecursive() const;
virtual bool canClipSelf() const;
......
......@@ -843,6 +843,13 @@ void LayerTreeHost::setDeviceScaleFactor(float deviceScaleFactor)
setNeedsCommit();
}
bool LayerTreeHost::blocksPendingCommit() const
{
if (!m_rootLayer)
return false;
return m_rootLayer->blocksPendingCommitRecursive();
}
void LayerTreeHost::animateLayers(base::TimeTicks time)
{
if (!m_settings.acceleratedAnimationEnabled || m_animationRegistrar->active_animation_controllers().empty())
......
......@@ -203,6 +203,8 @@ public:
skia::RefPtr<SkPicture> capturePicture();
bool blocksPendingCommit() const;
protected:
LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&);
bool initialize(scoped_ptr<Thread> implThread);
......
......@@ -195,7 +195,7 @@ bool TextureLayer::blocksPendingCommit() const
// Double-buffered texture layers need to be blocked until they can be made
// triple-buffered. Single-buffered layers already prevent draws, so
// can block too for simplicity.
return true;
return drawsContent();
}
bool TextureLayer::canClipSelf() const
......
......@@ -720,8 +720,17 @@ void ThreadProxy::scheduledActionCommit()
m_nextFrameIsNewlyCommittedFrameOnImplThread = true;
m_commitCompletionEventOnImplThread->signal();
m_commitCompletionEventOnImplThread = 0;
if (m_layerTreeHost->settings().implSidePainting && m_layerTreeHost->blocksPendingCommit())
{
// For some layer types in impl-side painting, the commit is held until
// the pending tree is activated.
TRACE_EVENT_INSTANT0("cc", "HoldCommit");
}
else
{
m_commitCompletionEventOnImplThread->signal();
m_commitCompletionEventOnImplThread = 0;
}
// SetVisible kicks off the next scheduler action, so this must be last.
m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
......@@ -780,6 +789,15 @@ ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal
}
m_layerTreeHostImpl->didDrawAllLayers(frame);
// Check for tree activation.
if (m_commitCompletionEventOnImplThread && !m_layerTreeHostImpl->pendingTree())
{
TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation");
DCHECK(m_layerTreeHostImpl->settings().implSidePainting);
m_commitCompletionEventOnImplThread->signal();
m_commitCompletionEventOnImplThread = 0;
}
// Check for a pending compositeAndReadback.
if (m_readbackRequestOnImplThread) {
m_readbackRequestOnImplThread->success = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment