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

Side by Side Diff: cc/trees/tree_synchronizer.cc

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « cc/trees/occlusion_tracker_unittest.cc ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker_unittest.cc ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698