| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_linear_fade.h" | 5 #include "cc/input/scrollbar_animation_controller_linear_fade.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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade( | 27 ScrollbarAnimationControllerLinearFade::ScrollbarAnimationControllerLinearFade( |
| 28 int scroll_layer_id, | 28 int scroll_layer_id, |
| 29 ScrollbarAnimationControllerClient* client, | 29 ScrollbarAnimationControllerClient* client, |
| 30 base::TimeDelta delay_before_starting, | 30 base::TimeDelta delay_before_starting, |
| 31 base::TimeDelta resize_delay_before_starting, | 31 base::TimeDelta resize_delay_before_starting, |
| 32 base::TimeDelta duration) | 32 base::TimeDelta duration) |
| 33 : ScrollbarAnimationController(scroll_layer_id, | 33 : ScrollbarAnimationController(scroll_layer_id, |
| 34 client, | 34 client, |
| 35 delay_before_starting, | 35 delay_before_starting, |
| 36 resize_delay_before_starting, | 36 resize_delay_before_starting), |
| 37 duration) {} | 37 duration_(duration) {} |
| 38 | 38 |
| 39 ScrollbarAnimationControllerLinearFade:: | 39 ScrollbarAnimationControllerLinearFade:: |
| 40 ~ScrollbarAnimationControllerLinearFade() {} | 40 ~ScrollbarAnimationControllerLinearFade() {} |
| 41 | 41 |
| 42 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) { | 42 void ScrollbarAnimationControllerLinearFade::RunAnimationFrame(float progress) { |
| 43 ApplyOpacityToScrollbars(1.f - progress); | 43 ApplyOpacityToScrollbars(1.f - progress); |
| 44 client_->SetNeedsRedrawForScrollbarAnimation(); | 44 client_->SetNeedsRedrawForScrollbarAnimation(); |
| 45 if (progress == 1.f) | 45 if (progress == 1.f) |
| 46 StopAnimation(); | 46 StopAnimation(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 const base::TimeDelta& ScrollbarAnimationControllerLinearFade::Duration() { |
| 50 return duration_; |
| 51 } |
| 52 |
| 49 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(bool on_resize) { | 53 void ScrollbarAnimationControllerLinearFade::DidScrollUpdate(bool on_resize) { |
| 50 ScrollbarAnimationController::DidScrollUpdate(on_resize); | 54 ScrollbarAnimationController::DidScrollUpdate(on_resize); |
| 51 ApplyOpacityToScrollbars(1.f); | 55 ApplyOpacityToScrollbars(1.f); |
| 52 } | 56 } |
| 53 | 57 |
| 54 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars( | 58 void ScrollbarAnimationControllerLinearFade::ApplyOpacityToScrollbars( |
| 55 float opacity) { | 59 float opacity) { |
| 56 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { | 60 for (ScrollbarLayerImplBase* scrollbar : Scrollbars()) { |
| 57 if (!scrollbar->is_overlay_scrollbar()) | 61 if (!scrollbar->is_overlay_scrollbar()) |
| 58 continue; | 62 continue; |
| 59 PropertyTrees* property_trees = | 63 PropertyTrees* property_trees = |
| 60 scrollbar->layer_tree_impl()->property_trees(); | 64 scrollbar->layer_tree_impl()->property_trees(); |
| 61 // If this method is called during LayerImpl::PushPropertiesTo, we may not | 65 // If this method is called during LayerImpl::PushPropertiesTo, we may not |
| 62 // yet have valid effect_id_to_index_map entries as property trees are | 66 // yet have valid effect_id_to_index_map entries as property trees are |
| 63 // pushed after layers during activation. We can skip updating opacity in | 67 // pushed after layers during activation. We can skip updating opacity in |
| 64 // that case as we are only registering a scrollbar and because opacity will | 68 // that case as we are only registering a scrollbar and because opacity will |
| 65 // be overwritten anyway when property trees are pushed. | 69 // be overwritten anyway when property trees are pushed. |
| 66 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, | 70 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, |
| 67 scrollbar->id())) { | 71 scrollbar->id())) { |
| 68 property_trees->effect_tree.OnOpacityAnimated( | 72 property_trees->effect_tree.OnOpacityAnimated( |
| 69 scrollbar->CanScrollOrientation() ? opacity : 0, | 73 scrollbar->CanScrollOrientation() ? opacity : 0, |
| 70 property_trees->effect_id_to_index_map[scrollbar->id()], | 74 property_trees->effect_id_to_index_map[scrollbar->id()], |
| 71 scrollbar->layer_tree_impl()); | 75 scrollbar->layer_tree_impl()); |
| 72 } | 76 } |
| 73 } | 77 } |
| 74 } | 78 } |
| 75 | 79 |
| 76 } // namespace cc | 80 } // namespace cc |
| OLD | NEW |