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

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

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r248052. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | content/public/common/common_param_traits_macros.h » ('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 "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/containers/scoped_ptr_hash_map.h" 8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "cc/animation/scrollbar_animation_controller.h" 11 #include "cc/animation/scrollbar_animation_controller.h"
12 #include "cc/input/scrollbar.h" 12 #include "cc/input/scrollbar.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 #include "cc/layers/scrollbar_layer_impl_base.h" 15 #include "cc/layers/scrollbar_layer_impl_base.h"
16 #include "cc/layers/scrollbar_layer_interface.h" 16 #include "cc/layers/scrollbar_layer_interface.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 typedef base::ScopedPtrHashMap<int, LayerImpl> ScopedPtrLayerImplMap; 20 typedef base::ScopedPtrHashMap<int, LayerImpl> ScopedPtrLayerImplMap;
21 typedef base::hash_map<int, LayerImpl*> RawPtrLayerImplMap; 21 typedef base::hash_map<int, LayerImpl*> RawPtrLayerImplMap;
22 22
23 void CollectExistingLayerImplRecursive(ScopedPtrLayerImplMap* old_layers, 23 void CollectExistingLayerImplRecursive(ScopedPtrLayerImplMap* old_layers,
24 scoped_ptr<LayerImpl> layer_impl) { 24 scoped_ptr<LayerImpl> layer_impl) {
25 if (!layer_impl) 25 if (!layer_impl)
26 return; 26 return;
27 27
28 layer_impl->ClearScrollbars();
29 if (ScrollbarLayerImplBase* scrollbar_layer =
30 layer_impl->ToScrollbarLayer()) {
31 scrollbar_layer->ClearClipLayer();
32 scrollbar_layer->ClearScrollLayer();
33 }
34
28 OwnedLayerImplList& children = layer_impl->children(); 35 OwnedLayerImplList& children = layer_impl->children();
29 for (OwnedLayerImplList::iterator it = children.begin(); 36 for (OwnedLayerImplList::iterator it = children.begin();
30 it != children.end(); 37 it != children.end();
31 ++it) 38 ++it)
32 CollectExistingLayerImplRecursive(old_layers, children.take(it)); 39 CollectExistingLayerImplRecursive(old_layers, children.take(it));
33 40
34 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeMaskLayer()); 41 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeMaskLayer());
35 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer()); 42 CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer());
36 43
37 int id = layer_impl->id(); 44 int id = layer_impl->id();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 for (size_t i = 0; i < layer->children().size(); ++i) { 112 for (size_t i = 0; i < layer->children().size(); ++i) {
106 layer_impl->AddChild(SynchronizeTreesRecursiveInternal( 113 layer_impl->AddChild(SynchronizeTreesRecursiveInternal(
107 new_layers, old_layers, layer->child_at(i), tree_impl)); 114 new_layers, old_layers, layer->child_at(i), tree_impl));
108 } 115 }
109 116
110 layer_impl->SetMaskLayer(SynchronizeTreesRecursiveInternal( 117 layer_impl->SetMaskLayer(SynchronizeTreesRecursiveInternal(
111 new_layers, old_layers, layer->mask_layer(), tree_impl)); 118 new_layers, old_layers, layer->mask_layer(), tree_impl));
112 layer_impl->SetReplicaLayer(SynchronizeTreesRecursiveInternal( 119 layer_impl->SetReplicaLayer(SynchronizeTreesRecursiveInternal(
113 new_layers, old_layers, layer->replica_layer(), tree_impl)); 120 new_layers, old_layers, layer->replica_layer(), tree_impl));
114 121
115 // Remove all dangling pointers. The pointers will be setup later in
116 // UpdateScrollbarLayerPointersRecursive phase
117 layer_impl->SetHorizontalScrollbarLayer(NULL);
118 layer_impl->SetVerticalScrollbarLayer(NULL);
119
120 return layer_impl.Pass(); 122 return layer_impl.Pass();
121 } 123 }
122 124
123 scoped_ptr<LayerImpl> SynchronizeTreesRecursive( 125 scoped_ptr<LayerImpl> SynchronizeTreesRecursive(
124 RawPtrLayerImplMap* new_layers, 126 RawPtrLayerImplMap* new_layers,
125 ScopedPtrLayerImplMap* old_layers, 127 ScopedPtrLayerImplMap* old_layers,
126 Layer* layer, 128 Layer* layer,
127 LayerTreeImpl* tree_impl) { 129 LayerTreeImpl* tree_impl) {
128 return SynchronizeTreesRecursiveInternal( 130 return SynchronizeTreesRecursiveInternal(
129 new_layers, old_layers, layer, tree_impl); 131 new_layers, old_layers, layer, tree_impl);
(...skipping 23 matching lines...) Expand all
153 ScrollbarLayerType* scrollbar_layer = layer->ToScrollbarLayer(); 155 ScrollbarLayerType* scrollbar_layer = layer->ToScrollbarLayer();
154 if (!scrollbar_layer) 156 if (!scrollbar_layer)
155 return; 157 return;
156 158
157 RawPtrLayerImplMap::const_iterator iter = 159 RawPtrLayerImplMap::const_iterator iter =
158 new_layers->find(layer->id()); 160 new_layers->find(layer->id());
159 ScrollbarLayerImplBase* scrollbar_layer_impl = 161 ScrollbarLayerImplBase* scrollbar_layer_impl =
160 iter != new_layers->end() 162 iter != new_layers->end()
161 ? static_cast<ScrollbarLayerImplBase*>(iter->second) 163 ? static_cast<ScrollbarLayerImplBase*>(iter->second)
162 : NULL; 164 : NULL;
163 iter = new_layers->find(scrollbar_layer->ScrollLayerId()); 165 DCHECK(scrollbar_layer_impl);
164 LayerImpl* scroll_layer_impl =
165 iter != new_layers->end() ? iter->second : NULL;
166 166
167 DCHECK(scrollbar_layer_impl); 167 scrollbar_layer->PushScrollClipPropertiesTo(scrollbar_layer_impl);
168 DCHECK(scroll_layer_impl);
169
170 if (scrollbar_layer->orientation() == HORIZONTAL)
171 scroll_layer_impl->SetHorizontalScrollbarLayer(scrollbar_layer_impl);
172 else
173 scroll_layer_impl->SetVerticalScrollbarLayer(scrollbar_layer_impl);
174 } 168 }
175 169
176 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, 170 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers,
177 Layer* layer) { 171 Layer* layer) {
178 UpdateScrollbarLayerPointersRecursiveInternal<Layer, ScrollbarLayerInterface>( 172 UpdateScrollbarLayerPointersRecursiveInternal<Layer, ScrollbarLayerInterface>(
179 new_layers, layer); 173 new_layers, layer);
180 } 174 }
181 175
182 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, 176 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers,
183 LayerImpl* layer) { 177 LayerImpl* layer) {
(...skipping 14 matching lines...) Expand all
198 } 192 }
199 193
200 DCHECK_EQ(layer->id(), layer_impl->id()); 194 DCHECK_EQ(layer->id(), layer_impl->id());
201 195
202 bool push_layer = layer->needs_push_properties(); 196 bool push_layer = layer->needs_push_properties();
203 bool recurse_on_children_and_dependents = 197 bool recurse_on_children_and_dependents =
204 layer->descendant_needs_push_properties(); 198 layer->descendant_needs_push_properties();
205 199
206 if (push_layer) 200 if (push_layer)
207 layer->PushPropertiesTo(layer_impl); 201 layer->PushPropertiesTo(layer_impl);
202 else if (layer->ToScrollbarLayer())
203 layer->ToScrollbarLayer()->PushScrollClipPropertiesTo(layer_impl);
208 204
209 size_t num_dependents_need_push_properties = 0; 205 size_t num_dependents_need_push_properties = 0;
210 if (recurse_on_children_and_dependents) { 206 if (recurse_on_children_and_dependents) {
211 PushPropertiesInternal(layer->mask_layer(), 207 PushPropertiesInternal(layer->mask_layer(),
212 layer_impl->mask_layer(), 208 layer_impl->mask_layer(),
213 &num_dependents_need_push_properties); 209 &num_dependents_need_push_properties);
214 PushPropertiesInternal(layer->replica_layer(), 210 PushPropertiesInternal(layer->replica_layer(),
215 layer_impl->replica_layer(), 211 layer_impl->replica_layer(),
216 &num_dependents_need_push_properties); 212 &num_dependents_need_push_properties);
217 213
(...skipping 27 matching lines...) Expand all
245 layer, layer_impl, &num_dependents_need_push_properties); 241 layer, layer_impl, &num_dependents_need_push_properties);
246 } 242 }
247 243
248 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { 244 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) {
249 size_t num_dependents_need_push_properties = 0; 245 size_t num_dependents_need_push_properties = 0;
250 PushPropertiesInternal( 246 PushPropertiesInternal(
251 layer, layer_impl, &num_dependents_need_push_properties); 247 layer, layer_impl, &num_dependents_need_push_properties);
252 } 248 }
253 249
254 } // namespace cc 250 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | content/public/common/common_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698