Chromium Code Reviews| Index: cc/trees/tree_synchronizer.cc |
| diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc |
| index cdb46f772c23ae55e4442af7150c779df5b071a0..ee113116856e636a731e15ef9d5c0ce1cddcd2b6 100644 |
| --- a/cc/trees/tree_synchronizer.cc |
| +++ b/cc/trees/tree_synchronizer.cc |
| @@ -18,8 +18,11 @@ |
| namespace cc { |
| -template <typename LayerType> |
| -void SynchronizeTreesInternal(LayerType* layer_root, LayerTreeImpl* tree_impl) { |
| +template <typename LayerType, typename LayerTreeType> |
| +void SynchronizeTreesInternal(LayerType* layer_root, |
|
jaydasika
2016/06/14 06:12:06
I think layer_root is a redundant argument for thi
ajuma
2016/06/14 12:45:26
Done. This also allowed merging PushLayerList and
|
| + LayerTreeType* source_tree, |
| + LayerTreeImpl* tree_impl, |
| + PropertyTrees* property_trees) { |
| DCHECK(tree_impl); |
| TRACE_EVENT0("cc", "TreeSynchronizer::SynchronizeTrees"); |
| @@ -31,29 +34,33 @@ void SynchronizeTreesInternal(LayerType* layer_root, LayerTreeImpl* tree_impl) { |
| PushLayerList(&old_layer_map, layer_root, tree_impl); |
| - for (auto& it : old_layer_map) { |
| - if (it.second) { |
| - // Need to ensure that layer destruction doesn't tear down other layers |
| - // linked to this LayerImpl that have been used in the new tree. |
| - it.second->ClearLinksToOtherLayers(); |
| - } |
| + for (int id : property_trees->effect_tree.mask_replica_layer_ids()) { |
| + std::unique_ptr<LayerImpl> layer_impl(ReuseOrCreateLayerImpl( |
| + &old_layer_map, source_tree->LayerById(id), tree_impl)); |
| + tree_impl->AddLayer(std::move(layer_impl)); |
| } |
| } |
| void TreeSynchronizer::SynchronizeTrees(Layer* layer_root, |
| LayerTreeImpl* tree_impl) { |
| - if (!layer_root) |
| + if (!layer_root) { |
| tree_impl->DetachLayers(); |
| - else |
| - SynchronizeTreesInternal(layer_root, tree_impl); |
| + } else { |
| + SynchronizeTreesInternal(layer_root, layer_root->layer_tree_host(), |
| + tree_impl, |
| + layer_root->layer_tree_host()->property_trees()); |
| + } |
| } |
| void TreeSynchronizer::SynchronizeTrees(LayerImpl* layer_root, |
| LayerTreeImpl* tree_impl) { |
| - if (!layer_root) |
| + if (!layer_root) { |
| tree_impl->DetachLayers(); |
| - else |
| - SynchronizeTreesInternal(layer_root, tree_impl); |
| + } else { |
| + SynchronizeTreesInternal(layer_root, layer_root->layer_tree_impl(), |
| + tree_impl, |
| + layer_root->layer_tree_impl()->property_trees()); |
| + } |
| } |
| template <typename LayerType> |
| @@ -68,31 +75,6 @@ std::unique_ptr<LayerImpl> ReuseOrCreateLayerImpl(OwnedLayerImplMap* old_layers, |
| return layer_impl; |
| } |
| -static void SynchronizeReplicaLayer(LayerImpl* layer_impl, |
| - std::unique_ptr<LayerImpl> new_replica, |
| - LayerTreeImpl* tree_impl) { |
| - if (layer_impl->replica_layer() && |
| - layer_impl->replica_layer() == new_replica.get()) { |
| - // In this case, we only need to update the ownership, as we're essentially |
| - // just resetting the replica layer. |
| - tree_impl->AddLayer(std::move(new_replica)); |
| - } else { |
| - layer_impl->SetReplicaLayer(std::move(new_replica)); |
| - } |
| -} |
| - |
| -static void SynchronizeMaskLayer(LayerImpl* layer_impl, |
| - std::unique_ptr<LayerImpl> new_mask, |
| - LayerTreeImpl* tree_impl) { |
| - if (layer_impl->mask_layer() && layer_impl->mask_layer() == new_mask.get()) { |
| - // In this case, we only need to update the ownership, as we're essentially |
| - // just resetting the mask layer. |
| - tree_impl->AddLayer(std::move(new_mask)); |
| - } else { |
| - layer_impl->SetMaskLayer(std::move(new_mask)); |
| - } |
| -} |
| - |
| template <typename LayerTreeType> |
| void PushLayerListInternal(OwnedLayerImplMap* old_layers, |
| LayerTreeType* host, |
| @@ -102,20 +84,6 @@ void PushLayerListInternal(OwnedLayerImplMap* old_layers, |
| std::unique_ptr<LayerImpl> layer_impl( |
| ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); |
| - std::unique_ptr<LayerImpl> mask_layer( |
| - ReuseOrCreateLayerImpl(old_layers, layer->mask_layer(), tree_impl)); |
| - SynchronizeMaskLayer(layer_impl.get(), std::move(mask_layer), tree_impl); |
| - |
| - std::unique_ptr<LayerImpl> replica_layer( |
| - ReuseOrCreateLayerImpl(old_layers, layer->replica_layer(), tree_impl)); |
| - SynchronizeReplicaLayer(layer_impl.get(), std::move(replica_layer), |
| - tree_impl); |
| - if (layer->replica_layer()) { |
| - std::unique_ptr<LayerImpl> replica_mask_layer(ReuseOrCreateLayerImpl( |
| - old_layers, layer->replica_layer()->mask_layer(), tree_impl)); |
| - SynchronizeMaskLayer(layer_impl->replica_layer(), |
| - std::move(replica_mask_layer), tree_impl); |
| - } |
| tree_impl->AddToLayerList(layer_impl.get()); |
| tree_impl->AddLayer(std::move(layer_impl)); |
| } |