| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/scrollbar_animation_controller_thinning.h" | 5 #include "cc/input/scrollbar_animation_controller_thinning.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/layers/scrollbar_layer_impl_base.h" | 10 #include "cc/layers/scrollbar_layer_impl_base.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 209 } |
| 210 | 210 |
| 211 void ScrollbarAnimationControllerThinning::ApplyOpacity(float opacity) { | 211 void ScrollbarAnimationControllerThinning::ApplyOpacity(float opacity) { |
| 212 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 212 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 213 if (!scrollbar->is_overlay_scrollbar()) | 213 if (!scrollbar->is_overlay_scrollbar()) |
| 214 continue; | 214 continue; |
| 215 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; | 215 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; |
| 216 PropertyTrees* property_trees = | 216 PropertyTrees* property_trees = |
| 217 scrollbar->layer_tree_impl()->property_trees(); | 217 scrollbar->layer_tree_impl()->property_trees(); |
| 218 // If this method is called during LayerImpl::PushPropertiesTo, we may not | 218 // If this method is called during LayerImpl::PushPropertiesTo, we may not |
| 219 // yet have valid effect_id_to_index_map entries as property trees are | 219 // yet have valid layer_id_to_effect_node_index entries as property trees |
| 220 // pushed after layers during activation. We can skip updating opacity in | 220 // are pushed after layers during activation. We can skip updating opacity |
| 221 // that case as we are only registering a scrollbar and because opacity will | 221 // in that case as we are only registering a scrollbar and because opacity |
| 222 // be overwritten anyway when property trees are pushed. | 222 // will be overwritten anyway when property trees are pushed. |
| 223 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, | 223 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, |
| 224 scrollbar->id())) { | 224 scrollbar->id())) { |
| 225 property_trees->effect_tree.OnOpacityAnimated( | 225 property_trees->effect_tree.OnOpacityAnimated( |
| 226 effective_opacity, | 226 effective_opacity, |
| 227 property_trees->effect_id_to_index_map[scrollbar->id()], | 227 property_trees->layer_id_to_effect_node_index[scrollbar->id()], |
| 228 scrollbar->layer_tree_impl()); | 228 scrollbar->layer_tree_impl()); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool previouslyVisible = opacity_ > 0.0f; | 232 bool previouslyVisible = opacity_ > 0.0f; |
| 233 bool currentlyVisible = opacity > 0.0f; | 233 bool currentlyVisible = opacity > 0.0f; |
| 234 | 234 |
| 235 opacity_ = opacity; | 235 opacity_ = opacity; |
| 236 | 236 |
| 237 if (previouslyVisible != currentlyVisible) | 237 if (previouslyVisible != currentlyVisible) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 255 if (current_animating_property_ == property) | 255 if (current_animating_property_ == property) |
| 256 return; | 256 return; |
| 257 | 257 |
| 258 StopAnimation(); | 258 StopAnimation(); |
| 259 current_animating_property_ = property; | 259 current_animating_property_ = property; |
| 260 if (current_animating_property_ == THICKNESS) | 260 if (current_animating_property_ == THICKNESS) |
| 261 ApplyOpacity(1.f); | 261 ApplyOpacity(1.f); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace cc | 264 } // namespace cc |
| OLD | NEW |