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 "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
11 #include "cc/input/scrollbar.h" | 11 #include "cc/input/scrollbar.h" |
12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 #include "cc/layers/layer_impl.h" | 13 #include "cc/layers/layer_impl.h" |
14 #include "cc/layers/scrollbar_layer.h" | 14 #include "cc/layers/scrollbar_layer_base.h" |
15 #include "cc/layers/scrollbar_layer_impl.h" | 15 #include "cc/layers/scrollbar_layer_impl_base.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 typedef ScopedPtrHashMap<int, LayerImpl> ScopedPtrLayerImplMap; | 19 typedef ScopedPtrHashMap<int, LayerImpl> 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; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const RawPtrLayerImplMap* new_layers, | 142 const RawPtrLayerImplMap* new_layers, |
143 LayerType* layer) { | 143 LayerType* layer) { |
144 if (!layer) | 144 if (!layer) |
145 return; | 145 return; |
146 | 146 |
147 for (size_t i = 0; i < layer->children().size(); ++i) { | 147 for (size_t i = 0; i < layer->children().size(); ++i) { |
148 UpdateScrollbarLayerPointersRecursiveInternal< | 148 UpdateScrollbarLayerPointersRecursiveInternal< |
149 LayerType, ScrollbarLayerType>(new_layers, layer->child_at(i)); | 149 LayerType, ScrollbarLayerType>(new_layers, layer->child_at(i)); |
150 } | 150 } |
151 | 151 |
152 ScrollbarLayerType* scrollbar_layer = layer->ToScrollbarLayer(); | 152 ScrollbarLayerType* scrollbar_layer = layer->ToScrollbarLayerBase(); |
153 if (!scrollbar_layer) | 153 if (!scrollbar_layer) |
154 return; | 154 return; |
155 | 155 |
156 RawPtrLayerImplMap::const_iterator iter = | 156 RawPtrLayerImplMap::const_iterator iter = |
157 new_layers->find(scrollbar_layer->id()); | 157 new_layers->find(layer->id()); |
158 ScrollbarLayerImpl* scrollbar_layer_impl = | 158 ScrollbarLayerImplBase* scrollbar_layer_impl = |
159 iter != new_layers->end() ? static_cast<ScrollbarLayerImpl*>(iter->second) | 159 iter != new_layers->end() |
160 : NULL; | 160 ? static_cast<ScrollbarLayerImplBase*>(iter->second) |
| 161 : NULL; |
161 iter = new_layers->find(scrollbar_layer->scroll_layer_id()); | 162 iter = new_layers->find(scrollbar_layer->scroll_layer_id()); |
162 LayerImpl* scroll_layer_impl = | 163 LayerImpl* scroll_layer_impl = |
163 iter != new_layers->end() ? iter->second : NULL; | 164 iter != new_layers->end() ? iter->second : NULL; |
164 | 165 |
165 DCHECK(scrollbar_layer_impl); | 166 DCHECK(scrollbar_layer_impl); |
166 DCHECK(scroll_layer_impl); | 167 DCHECK(scroll_layer_impl); |
167 | 168 |
168 if (scrollbar_layer->Orientation() == HORIZONTAL) | 169 if (scrollbar_layer->Orientation() == HORIZONTAL) |
169 scroll_layer_impl->SetHorizontalScrollbarLayer(scrollbar_layer_impl); | 170 scroll_layer_impl->SetHorizontalScrollbarLayer(scrollbar_layer_impl); |
170 else | 171 else |
171 scroll_layer_impl->SetVerticalScrollbarLayer(scrollbar_layer_impl); | 172 scroll_layer_impl->SetVerticalScrollbarLayer(scrollbar_layer_impl); |
172 } | 173 } |
173 | 174 |
174 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, | 175 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, |
175 Layer* layer) { | 176 Layer* layer) { |
176 UpdateScrollbarLayerPointersRecursiveInternal<Layer, ScrollbarLayer>( | 177 UpdateScrollbarLayerPointersRecursiveInternal<Layer, ScrollbarLayerBase>( |
177 new_layers, layer); | 178 new_layers, layer); |
178 } | 179 } |
179 | 180 |
180 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, | 181 void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, |
181 LayerImpl* layer) { | 182 LayerImpl* layer) { |
182 UpdateScrollbarLayerPointersRecursiveInternal<LayerImpl, ScrollbarLayerImpl>( | 183 UpdateScrollbarLayerPointersRecursiveInternal< |
183 new_layers, layer); | 184 LayerImpl, |
| 185 ScrollbarLayerImplBase>(new_layers, layer); |
184 } | 186 } |
185 | 187 |
186 template <typename LayerType> | 188 template <typename LayerType> |
187 void PushPropertiesInternal(LayerType* layer, LayerImpl* layer_impl) { | 189 void PushPropertiesInternal(LayerType* layer, LayerImpl* layer_impl) { |
188 if (!layer) { | 190 if (!layer) { |
189 DCHECK(!layer_impl); | 191 DCHECK(!layer_impl); |
190 return; | 192 return; |
191 } | 193 } |
192 | 194 |
193 DCHECK_EQ(layer->id(), layer_impl->id()); | 195 DCHECK_EQ(layer->id(), layer_impl->id()); |
(...skipping 12 matching lines...) Expand all Loading... |
206 | 208 |
207 void TreeSynchronizer::PushProperties(Layer* layer, LayerImpl* layer_impl) { | 209 void TreeSynchronizer::PushProperties(Layer* layer, LayerImpl* layer_impl) { |
208 PushPropertiesInternal(layer, layer_impl); | 210 PushPropertiesInternal(layer, layer_impl); |
209 } | 211 } |
210 | 212 |
211 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { | 213 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { |
212 PushPropertiesInternal(layer, layer_impl); | 214 PushPropertiesInternal(layer, layer_impl); |
213 } | 215 } |
214 | 216 |
215 } // namespace cc | 217 } // namespace cc |
OLD | NEW |