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