| 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_impl_base.h" |
| 15 #include "cc/layers/scrollbar_layer_impl.h" | 15 #include "cc/layers/scrollbar_layer_interface.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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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->ToScrollbarLayer(); |
| 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, ScrollbarLayerInterface>( |
| 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 // static | 188 // static |
| 187 void TreeSynchronizer::SetNumDependentsNeedPushProperties( | 189 void TreeSynchronizer::SetNumDependentsNeedPushProperties( |
| 188 Layer* layer, size_t num) { | 190 Layer* layer, size_t num) { |
| 189 layer->num_dependents_need_push_properties_ = num; | 191 layer->num_dependents_need_push_properties_ = num; |
| 190 } | 192 } |
| 191 | 193 |
| 192 // static | 194 // static |
| 193 void TreeSynchronizer::SetNumDependentsNeedPushProperties( | 195 void TreeSynchronizer::SetNumDependentsNeedPushProperties( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 layer, layer_impl, &num_dependents_need_push_properties); | 255 layer, layer_impl, &num_dependents_need_push_properties); |
| 254 } | 256 } |
| 255 | 257 |
| 256 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { | 258 void TreeSynchronizer::PushProperties(LayerImpl* layer, LayerImpl* layer_impl) { |
| 257 size_t num_dependents_need_push_properties = 0; | 259 size_t num_dependents_need_push_properties = 0; |
| 258 PushPropertiesInternal( | 260 PushPropertiesInternal( |
| 259 layer, layer_impl, &num_dependents_need_push_properties); | 261 layer, layer_impl, &num_dependents_need_push_properties); |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace cc | 264 } // namespace cc |
| OLD | NEW |