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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 void ScrollbarAnimationController::Show() { | 358 void ScrollbarAnimationController::Show() { |
359 delayed_scrollbar_show_.Cancel(); | 359 delayed_scrollbar_show_.Cancel(); |
360 ApplyOpacityToScrollbars(1.0f); | 360 ApplyOpacityToScrollbars(1.0f); |
361 } | 361 } |
362 | 362 |
363 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { | 363 void ScrollbarAnimationController::ApplyOpacityToScrollbars(float opacity) { |
364 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 364 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
365 if (!scrollbar->is_overlay_scrollbar()) | 365 if (!scrollbar->is_overlay_scrollbar()) |
366 continue; | 366 continue; |
367 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; | 367 float effective_opacity = scrollbar->CanScrollOrientation() ? opacity : 0; |
368 PropertyTrees* property_trees = | 368 scrollbar->SetOverlayScrollbarLayerOpacityAnimated(effective_opacity); |
369 scrollbar->layer_tree_impl()->property_trees(); | |
370 // If this method is called during LayerImpl::PushPropertiesTo, we may not | |
371 // yet have valid owning_layer_id_to_node_index entries in effect tree as | |
372 // property trees are pushed after layers during activation. We can skip | |
373 // updating opacity in that case as we are only registering a scrollbar and | |
374 // because opacity will be overwritten anyway when property trees are | |
375 // pushed. | |
376 if (property_trees->effect_tree.FindNodeIndexFromOwningLayerId( | |
377 scrollbar->id()) != EffectTree::kInvalidNodeId) { | |
378 property_trees->effect_tree.OnOpacityAnimated( | |
379 effective_opacity, | |
380 property_trees->effect_tree.FindNodeIndexFromOwningLayerId( | |
381 scrollbar->id()), | |
382 scrollbar->layer_tree_impl()); | |
383 } | |
384 } | 369 } |
385 | 370 |
386 bool previouslyVisible = opacity_ > 0.0f; | 371 bool previouslyVisible = opacity_ > 0.0f; |
387 bool currentlyVisible = opacity > 0.0f; | 372 bool currentlyVisible = opacity > 0.0f; |
388 | 373 |
389 if (opacity_ != opacity) | 374 if (opacity_ != opacity) |
390 client_->SetNeedsRedrawForScrollbarAnimation(); | 375 client_->SetNeedsRedrawForScrollbarAnimation(); |
391 | 376 |
392 opacity_ = opacity; | 377 opacity_ = opacity; |
393 | 378 |
394 if (previouslyVisible != currentlyVisible) | 379 if (previouslyVisible != currentlyVisible) |
395 client_->DidChangeScrollbarVisibility(); | 380 client_->DidChangeScrollbarVisibility(); |
396 } | 381 } |
397 | 382 |
398 } // namespace cc | 383 } // namespace cc |
OLD | NEW |