diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 04:25:11 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-04 04:25:11 +0000 |
commit | 0bf9472475c27b921b18c55dad34f9d7ad15d18e (patch) | |
tree | 5a7df801dd78b8aeb3b242588a86a88c176cfce0 /cc/layer_tree_host.cc | |
parent | 9ec9dcf80862cac08862e9e8a99121aedf45d23a (diff) | |
download | chromium_src-0bf9472475c27b921b18c55dad34f9d7ad15d18e.zip chromium_src-0bf9472475c27b921b18c55dad34f9d7ad15d18e.tar.gz chromium_src-0bf9472475c27b921b18c55dad34f9d7ad15d18e.tar.bz2 |
Only do full tree sync if tree is actually changed, otherwise just push properties
We only have to run the complete tree synchronization algorithm if the cc::Layer tree's
structure is actually changed, otherwise we can just push properties over since the
cc::LayerImpl tree structure is never changed outside of commit.
Since scroll offset updates are tied into the tree synchronization algorithm, we currently
have to do a full tree sync for scroll updates. Fixing this will speed up scroll operations
but requires a bit more work.
Speeds up cc_perftests tenTenSingleThread by 7.3%
BUG=161166
Review URL: https://chromiumcodereview.appspot.com/11316297
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170881 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host.cc')
-rw-r--r-- | cc/layer_tree_host.cc | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index c1d3a97..d52422e 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -161,6 +161,7 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::create(LayerTreeHostClient* client, con LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, const LayerTreeSettings& settings) : m_animating(false) , m_needsAnimateLayers(false) + , m_needsFullTreeSync(true) , m_client(client) , m_commitNumber(0) , m_renderingStats() @@ -310,6 +311,28 @@ void LayerTreeHost::beginCommitOnImplThread(LayerTreeHostImpl* hostImpl) TRACE_EVENT0("cc", "LayerTreeHost::commitTo"); } +static void pushPropertiesRecursive(Layer* layer, LayerImpl* layerImpl) +{ + if (!layer) { + DCHECK(!layerImpl); + return; + } + + DCHECK_EQ(layer->id(), layerImpl->id()); + layer->pushPropertiesTo(layerImpl); + + pushPropertiesRecursive(layer->maskLayer(), layerImpl->maskLayer()); + pushPropertiesRecursive(layer->replicaLayer(), layerImpl->replicaLayer()); + + const std::vector<scoped_refptr<Layer> >& children = layer->children(); + const ScopedPtrVector<LayerImpl>& implChildren = layerImpl->children(); + DCHECK_EQ(children.size(), implChildren.size()); + + for (size_t i = 0; i < children.size(); ++i) { + pushPropertiesRecursive(children[i].get(), implChildren[i]); + } +} + // This function commits the LayerTreeHost to an impl tree. When modifying // this function, keep in mind that the function *runs* on the impl thread! Any // code that is logically a main thread operation, e.g. deletion of a Layer, @@ -322,7 +345,13 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl) m_contentsTextureManager->updateBackingsInDrawingImplTree(); m_contentsTextureManager->reduceMemory(hostImpl->resourceProvider()); - hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->detachLayerTree(), hostImpl)); + if (m_needsFullTreeSync) { + hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->detachLayerTree(), hostImpl)); + } else { + TRACE_EVENT0("cc", "LayerTreeHost::pushPropertiesRecursive"); + pushPropertiesRecursive(rootLayer(), hostImpl->rootLayer()); + } + m_needsFullTreeSync = false; if (m_rootLayer && m_hudLayer) hostImpl->setHudLayer(static_cast<HeadsUpDisplayLayerImpl*>(LayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id()))); @@ -443,6 +472,12 @@ void LayerTreeHost::setNeedsCommit() m_proxy->setNeedsCommit(); } +void LayerTreeHost::setNeedsFullTreeSync() +{ + m_needsFullTreeSync = true; + setNeedsCommit(); +} + void LayerTreeHost::setNeedsRedraw() { m_proxy->setNeedsRedraw(); @@ -481,7 +516,7 @@ void LayerTreeHost::setRootLayer(scoped_refptr<Layer> rootLayer) if (m_hudLayer) m_hudLayer->removeFromParent(); - setNeedsCommit(); + setNeedsFullTreeSync(); } void LayerTreeHost::setDebugState(const LayerTreeDebugState& debugState) |