| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "cc/input/scrollbar_animation_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "cc/trees/layer_tree_impl.h" | 10 #include "cc/trees/layer_tree_impl.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 void ScrollbarAnimationController::Show() { | 335 void ScrollbarAnimationController::Show() { |
| 336 delayed_scrollbar_show_.Cancel(); | 336 delayed_scrollbar_show_.Cancel(); |
| 337 ApplyOpacityToScrollbars(1.0f); | 337 ApplyOpacityToScrollbars(1.0f); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { | 340 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { |
| 341 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 341 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 342 if (!scrollbar->is_overlay_scrollbar()) | 342 if (!scrollbar->is_overlay_scrollbar()) |
| 343 continue; | 343 continue; |
| 344 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; | 344 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; |
| 345 PropertyTrees* property_trees = | 345 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); |
| 346 scrollbar->layer_tree_impl()->property_trees(); | |
| 347 // If this method is called during LayerImpl::PushPropertiesTo, we may not | |
| 348 // yet have valid owning_layer_id_to_node_index entries in effect tree as | |
| 349 // property trees are pushed after layers during activation. We can skip | |
| 350 // updating opacity in that case as we are only registering a scrollbar and | |
| 351 // because opacity will be overwritten anyway when property trees are | |
| 352 // pushed. | |
| 353 if (property_trees->effect_tree.FindNodeIndexFromOwningLayerId( | |
| 354 scrollbar->id()) != EffectTree::kInvalidNodeId) { | |
| 355 property_trees->effect_tree.OnOpacityAnimated( | |
| 356 effective_opacity, | |
| 357 property_trees->effect_tree.FindNodeIndexFromOwningLayerId( | |
| 358 scrollbar->id()), | |
| 359 scrollbar->layer_tree_impl()); | |
| 360 } | |
| 361 } | 346 } |
| 362 | 347 |
| 363 bool previouslyVisible = opacity_ > 0.0f; | 348 bool previouslyVisible = opacity_ > 0.0f; |
| 364 bool currentlyVisible = opacity > 0.0f; | 349 bool currentlyVisible = opacity > 0.0f; |
| 365 | 350 |
| 366 if (opacity_ != opacity) | 351 if (opacity_ != opacity) |
| 367 client_->SetNeedsRedrawForScrollbarAnimation(); | 352 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 368 | 353 |
| 369 opacity_ = opacity; | 354 opacity_ = opacity; |
| 370 | 355 |
| 371 if (previouslyVisible != currentlyVisible) | 356 if (previouslyVisible != currentlyVisible) |
| 372 client_->DidChangeScrollbarVisibility(); | 357 client_->DidChangeScrollbarVisibility(); |
| 373 } | 358 } |
| 374 | 359 |
| 375 } // namespace cc | 360 } // namespace cc |
| OLD | NEW |