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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 typedef base::ScopedPtrHashMap<int, scoped_ptr<LayerImpl>> | 18 typedef base::ScopedPtrHashMap<int, scoped_ptr<LayerImpl>> |
19 ScopedPtrLayerImplMap; | 19 ScopedPtrLayerImplMap; |
20 typedef base::hash_map<int, LayerImpl*> RawPtrLayerImplMap; | 20 typedef base::hash_map<int, LayerImpl*> RawPtrLayerImplMap; |
21 | 21 |
22 void CollectExistingLayerImplRecursive(ScopedPtrLayerImplMap* old_layers, | 22 void CollectExistingLayerImplRecursive(ScopedPtrLayerImplMap* old_layers, |
23 scoped_ptr<LayerImpl> layer_impl) { | 23 scoped_ptr<LayerImpl> layer_impl) { |
24 if (!layer_impl) | 24 if (!layer_impl) |
25 return; | 25 return; |
26 | 26 |
27 OwnedLayerImplList& children = layer_impl->children(); | 27 OwnedLayerImplList& children = layer_impl->children(); |
28 for (OwnedLayerImplList::iterator it = children.begin(); | 28 for (auto& child : children) |
29 it != children.end(); | 29 CollectExistingLayerImplRecursive(old_layers, std::move(child)); |
30 ++it) | |
31 CollectExistingLayerImplRecursive(old_layers, children.take(it)); | |
32 | 30 |
33 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeMaskLayer()); | 31 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeMaskLayer()); |
34 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer()); | 32 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer()); |
35 | 33 |
36 int id = layer_impl->id(); | 34 int id = layer_impl->id(); |
37 old_layers->set(id, layer_impl.Pass()); | 35 old_layers->set(id, layer_impl.Pass()); |
38 } | 36 } |
39 | 37 |
40 template <typename LayerType> | 38 template <typename LayerType> |
41 scoped_ptr<LayerImpl> SynchronizeTreesInternal( | 39 scoped_ptr<LayerImpl> SynchronizeTreesInternal( |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 layer_impl->mask_layer(), | 154 layer_impl->mask_layer(), |
157 &num_dependents_need_push_properties); | 155 &num_dependents_need_push_properties); |
158 PushPropertiesInternal(layer->replica_layer(), | 156 PushPropertiesInternal(layer->replica_layer(), |
159 layer_impl->replica_layer(), | 157 layer_impl->replica_layer(), |
160 &num_dependents_need_push_properties); | 158 &num_dependents_need_push_properties); |
161 | 159 |
162 const OwnedLayerImplList& impl_children = layer_impl->children(); | 160 const OwnedLayerImplList& impl_children = layer_impl->children(); |
163 DCHECK_EQ(layer->children().size(), impl_children.size()); | 161 DCHECK_EQ(layer->children().size(), impl_children.size()); |
164 | 162 |
165 for (size_t i = 0; i < layer->children().size(); ++i) { | 163 for (size_t i = 0; i < layer->children().size(); ++i) { |
166 PushPropertiesInternal(layer->child_at(i), | 164 PushPropertiesInternal(layer->child_at(i), impl_children[i].get(), |
167 impl_children[i], | |
168 &num_dependents_need_push_properties); | 165 &num_dependents_need_push_properties); |
169 } | 166 } |
170 | 167 |
171 // When PushPropertiesTo completes for a layer, it may still keep | 168 // When PushPropertiesTo completes for a layer, it may still keep |
172 // its needs_push_properties() state if the layer must push itself | 169 // its needs_push_properties() state if the layer must push itself |
173 // every PushProperties tree walk. Here we keep track of those layers, and | 170 // every PushProperties tree walk. Here we keep track of those layers, and |
174 // ensure that their ancestors know about them for the next PushProperties | 171 // ensure that their ancestors know about them for the next PushProperties |
175 // tree walk. | 172 // tree walk. |
176 layer->num_dependents_need_push_properties_ = | 173 layer->num_dependents_need_push_properties_ = |
177 num_dependents_need_push_properties; | 174 num_dependents_need_push_properties; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 #endif | 245 #endif |
249 } | 246 } |
250 | 247 |
251 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { | 248 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { |
252 int num_dependents_need_push_properties = 0; | 249 int num_dependents_need_push_properties = 0; |
253 PushPropertiesInternal( | 250 PushPropertiesInternal( |
254 layer, layer_impl, &num_dependents_need_push_properties); | 251 layer, layer_impl, &num_dependents_need_push_properties); |
255 } | 252 } |
256 | 253 |
257 } // namespace cc | 254 } // namespace cc |
OLD | NEW |