Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1282)

Unified Diff: cc/trees/tree_synchronizer.cc

Issue 2035863003: cc: Add mask and replica layer ids to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/property_tree_unittest.cc ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/tree_synchronizer.cc
diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc
index cdb46f772c23ae55e4442af7150c779df5b071a0..4069a3437075c6214a7831b398dc3b2b45962ef9 100644
--- a/cc/trees/tree_synchronizer.cc
+++ b/cc/trees/tree_synchronizer.cc
@@ -18,8 +18,10 @@
namespace cc {
-template <typename LayerType>
-void SynchronizeTreesInternal(LayerType* layer_root, LayerTreeImpl* tree_impl) {
+template <typename LayerTreeType>
+void SynchronizeTreesInternal(LayerTreeType* source_tree,
+ LayerTreeImpl* tree_impl,
+ PropertyTrees* property_trees) {
DCHECK(tree_impl);
TRACE_EVENT0("cc", "TreeSynchronizer::SynchronizeTrees");
@@ -29,31 +31,33 @@ void SynchronizeTreesInternal(LayerType* layer_root, LayerTreeImpl* tree_impl) {
for (auto& it : *old_layers)
old_layer_map[it->id()] = std::move(it);
- PushLayerList(&old_layer_map, layer_root, tree_impl);
+ PushLayerList(&old_layer_map, source_tree, 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_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_tree_impl(), tree_impl,
+ layer_root->layer_tree_impl()->property_trees());
+ }
}
template <typename LayerType>
@@ -68,70 +72,18 @@ 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,
- LayerTreeImpl* tree_impl) {
+void PushLayerList(OwnedLayerImplMap* old_layers,
+ LayerTreeType* host,
+ LayerTreeImpl* tree_impl) {
tree_impl->ClearLayerList();
for (auto* layer : *host) {
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));
}
-}
-
-void PushLayerList(OwnedLayerImplMap* old_layers,
- Layer* old_root,
- LayerTreeImpl* tree_impl) {
- PushLayerListInternal(old_layers, old_root->layer_tree_host(), tree_impl);
- tree_impl->SetRootLayerFromLayerList();
-}
-
-void PushLayerList(OwnedLayerImplMap* old_layers,
- LayerImpl* old_root,
- LayerTreeImpl* tree_impl) {
- PushLayerListInternal(old_layers, old_root->layer_tree_impl(), tree_impl);
tree_impl->SetRootLayerFromLayerList();
}
« no previous file with comments | « cc/trees/property_tree_unittest.cc ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698