OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/tree_synchronizer.h" | 5 #include "cc/trees/tree_synchronizer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 return; | 25 return; |
26 | 26 |
27 OwnedLayerImplList& children = layer_impl->children(); | 27 OwnedLayerImplList& children = layer_impl->children(); |
28 for (auto& child : children) | 28 for (auto& child : children) |
29 CollectExistingLayerImplRecursive(old_layers, std::move(child)); | 29 CollectExistingLayerImplRecursive(old_layers, std::move(child)); |
30 | 30 |
31 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeMaskLayer()); | 31 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeMaskLayer()); |
32 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer()); | 32 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer()); |
33 | 33 |
34 int id = layer_impl->id(); | 34 int id = layer_impl->id(); |
35 old_layers->set(id, layer_impl.Pass()); | 35 old_layers->set(id, std::move(layer_impl)); |
36 } | 36 } |
37 | 37 |
38 template <typename LayerType> | 38 template <typename LayerType> |
39 scoped_ptr<LayerImpl> SynchronizeTreesInternal( | 39 scoped_ptr<LayerImpl> SynchronizeTreesInternal( |
40 LayerType* layer_root, | 40 LayerType* layer_root, |
41 scoped_ptr<LayerImpl> old_layer_impl_root, | 41 scoped_ptr<LayerImpl> old_layer_impl_root, |
42 LayerTreeImpl* tree_impl) { | 42 LayerTreeImpl* tree_impl) { |
43 DCHECK(tree_impl); | 43 DCHECK(tree_impl); |
44 | 44 |
45 TRACE_EVENT0("cc", "TreeSynchronizer::SynchronizeTrees"); | 45 TRACE_EVENT0("cc", "TreeSynchronizer::SynchronizeTrees"); |
46 ScopedPtrLayerImplMap old_layers; | 46 ScopedPtrLayerImplMap old_layers; |
47 RawPtrLayerImplMap new_layers; | 47 RawPtrLayerImplMap new_layers; |
48 | 48 |
49 CollectExistingLayerImplRecursive(&old_layers, old_layer_impl_root.Pass()); | 49 CollectExistingLayerImplRecursive(&old_layers, |
| 50 std::move(old_layer_impl_root)); |
50 | 51 |
51 scoped_ptr<LayerImpl> new_tree = SynchronizeTreesRecursive( | 52 scoped_ptr<LayerImpl> new_tree = SynchronizeTreesRecursive( |
52 &new_layers, &old_layers, layer_root, tree_impl); | 53 &new_layers, &old_layers, layer_root, tree_impl); |
53 | 54 |
54 return new_tree.Pass(); | 55 return new_tree; |
55 } | 56 } |
56 | 57 |
57 scoped_ptr<LayerImpl> TreeSynchronizer::SynchronizeTrees( | 58 scoped_ptr<LayerImpl> TreeSynchronizer::SynchronizeTrees( |
58 Layer* layer_root, | 59 Layer* layer_root, |
59 scoped_ptr<LayerImpl> old_layer_impl_root, | 60 scoped_ptr<LayerImpl> old_layer_impl_root, |
60 LayerTreeImpl* tree_impl) { | 61 LayerTreeImpl* tree_impl) { |
61 return SynchronizeTreesInternal( | 62 return SynchronizeTreesInternal(layer_root, std::move(old_layer_impl_root), |
62 layer_root, old_layer_impl_root.Pass(), tree_impl); | 63 tree_impl); |
63 } | 64 } |
64 | 65 |
65 scoped_ptr<LayerImpl> TreeSynchronizer::SynchronizeTrees( | 66 scoped_ptr<LayerImpl> TreeSynchronizer::SynchronizeTrees( |
66 LayerImpl* layer_root, | 67 LayerImpl* layer_root, |
67 scoped_ptr<LayerImpl> old_layer_impl_root, | 68 scoped_ptr<LayerImpl> old_layer_impl_root, |
68 LayerTreeImpl* tree_impl) { | 69 LayerTreeImpl* tree_impl) { |
69 return SynchronizeTreesInternal( | 70 return SynchronizeTreesInternal(layer_root, std::move(old_layer_impl_root), |
70 layer_root, old_layer_impl_root.Pass(), tree_impl); | 71 tree_impl); |
71 } | 72 } |
72 | 73 |
73 template <typename LayerType> | 74 template <typename LayerType> |
74 scoped_ptr<LayerImpl> ReuseOrCreateLayerImpl(RawPtrLayerImplMap* new_layers, | 75 scoped_ptr<LayerImpl> ReuseOrCreateLayerImpl(RawPtrLayerImplMap* new_layers, |
75 ScopedPtrLayerImplMap* old_layers, | 76 ScopedPtrLayerImplMap* old_layers, |
76 LayerType* layer, | 77 LayerType* layer, |
77 LayerTreeImpl* tree_impl) { | 78 LayerTreeImpl* tree_impl) { |
78 scoped_ptr<LayerImpl> layer_impl = old_layers->take(layer->id()); | 79 scoped_ptr<LayerImpl> layer_impl = old_layers->take(layer->id()); |
79 | 80 |
80 if (!layer_impl) | 81 if (!layer_impl) |
81 layer_impl = layer->CreateLayerImpl(tree_impl); | 82 layer_impl = layer->CreateLayerImpl(tree_impl); |
82 | 83 |
83 (*new_layers)[layer->id()] = layer_impl.get(); | 84 (*new_layers)[layer->id()] = layer_impl.get(); |
84 return layer_impl.Pass(); | 85 return layer_impl; |
85 } | 86 } |
86 | 87 |
87 template <typename LayerType> | 88 template <typename LayerType> |
88 scoped_ptr<LayerImpl> SynchronizeTreesRecursiveInternal( | 89 scoped_ptr<LayerImpl> SynchronizeTreesRecursiveInternal( |
89 RawPtrLayerImplMap* new_layers, | 90 RawPtrLayerImplMap* new_layers, |
90 ScopedPtrLayerImplMap* old_layers, | 91 ScopedPtrLayerImplMap* old_layers, |
91 LayerType* layer, | 92 LayerType* layer, |
92 LayerTreeImpl* tree_impl) { | 93 LayerTreeImpl* tree_impl) { |
93 if (!layer) | 94 if (!layer) |
94 return nullptr; | 95 return nullptr; |
95 | 96 |
96 scoped_ptr<LayerImpl> layer_impl = | 97 scoped_ptr<LayerImpl> layer_impl = |
97 ReuseOrCreateLayerImpl(new_layers, old_layers, layer, tree_impl); | 98 ReuseOrCreateLayerImpl(new_layers, old_layers, layer, tree_impl); |
98 | 99 |
99 layer_impl->ClearChildList(); | 100 layer_impl->ClearChildList(); |
100 for (size_t i = 0; i < layer->children().size(); ++i) { | 101 for (size_t i = 0; i < layer->children().size(); ++i) { |
101 layer_impl->AddChild(SynchronizeTreesRecursiveInternal( | 102 layer_impl->AddChild(SynchronizeTreesRecursiveInternal( |
102 new_layers, old_layers, layer->child_at(i), tree_impl)); | 103 new_layers, old_layers, layer->child_at(i), tree_impl)); |
103 } | 104 } |
104 | 105 |
105 layer_impl->SetMaskLayer(SynchronizeTreesRecursiveInternal( | 106 layer_impl->SetMaskLayer(SynchronizeTreesRecursiveInternal( |
106 new_layers, old_layers, layer->mask_layer(), tree_impl)); | 107 new_layers, old_layers, layer->mask_layer(), tree_impl)); |
107 layer_impl->SetReplicaLayer(SynchronizeTreesRecursiveInternal( | 108 layer_impl->SetReplicaLayer(SynchronizeTreesRecursiveInternal( |
108 new_layers, old_layers, layer->replica_layer(), tree_impl)); | 109 new_layers, old_layers, layer->replica_layer(), tree_impl)); |
109 | 110 |
110 return layer_impl.Pass(); | 111 return layer_impl; |
111 } | 112 } |
112 | 113 |
113 scoped_ptr<LayerImpl> SynchronizeTreesRecursive( | 114 scoped_ptr<LayerImpl> SynchronizeTreesRecursive( |
114 RawPtrLayerImplMap* new_layers, | 115 RawPtrLayerImplMap* new_layers, |
115 ScopedPtrLayerImplMap* old_layers, | 116 ScopedPtrLayerImplMap* old_layers, |
116 Layer* layer, | 117 Layer* layer, |
117 LayerTreeImpl* tree_impl) { | 118 LayerTreeImpl* tree_impl) { |
118 return SynchronizeTreesRecursiveInternal( | 119 return SynchronizeTreesRecursiveInternal( |
119 new_layers, old_layers, layer, tree_impl); | 120 new_layers, old_layers, layer, tree_impl); |
120 } | 121 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 #endif | 246 #endif |
246 } | 247 } |
247 | 248 |
248 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { | 249 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { |
249 int num_dependents_need_push_properties = 0; | 250 int num_dependents_need_push_properties = 0; |
250 PushPropertiesInternal( | 251 PushPropertiesInternal( |
251 layer, layer_impl, &num_dependents_need_push_properties); | 252 layer, layer_impl, &num_dependents_need_push_properties); |
252 } | 253 } |
253 | 254 |
254 } // namespace cc | 255 } // namespace cc |
OLD | NEW |