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/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 viewport.height() / scrollable_size.height()); | 870 viewport.height() / scrollable_size.height()); |
871 } | 871 } |
872 | 872 |
873 if (current_offset == last_scroll_offset_) | 873 if (current_offset == last_scroll_offset_) |
874 return; | 874 return; |
875 last_scroll_offset_ = current_offset; | 875 last_scroll_offset_ = current_offset; |
876 | 876 |
877 if (scrollbar_animation_controller_ && | 877 if (scrollbar_animation_controller_ && |
878 !scrollbar_animation_controller_->IsScrollGestureInProgress()) { | 878 !scrollbar_animation_controller_->IsScrollGestureInProgress()) { |
879 scrollbar_animation_controller_->DidProgrammaticallyUpdateScroll( | 879 scrollbar_animation_controller_->DidProgrammaticallyUpdateScroll( |
880 layer_tree_impl()->CurrentFrameTimeTicks()); | 880 layer_tree_impl_->CurrentPhysicalTimeTicks()); |
881 } | 881 } |
882 | 882 |
883 // Get the current_offset_.y() value for a sanity-check on scrolling | 883 // Get the current_offset_.y() value for a sanity-check on scrolling |
884 // benchmark metrics. Specifically, we want to make sure | 884 // benchmark metrics. Specifically, we want to make sure |
885 // BasicMouseWheelSmoothScrollGesture has proper scroll curves. | 885 // BasicMouseWheelSmoothScrollGesture has proper scroll curves. |
886 if (layer_tree_impl()->IsActiveTree()) { | 886 if (layer_tree_impl()->IsActiveTree()) { |
887 TRACE_COUNTER_ID1("gpu", "scroll_offset_y", this->id(), current_offset.y()); | 887 TRACE_COUNTER_ID1("gpu", "scroll_offset_y", this->id(), current_offset.y()); |
888 } | 888 } |
889 } | 889 } |
890 | 890 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 UpdateScrollbarPositions(); | 978 UpdateScrollbarPositions(); |
979 } | 979 } |
980 | 980 |
981 void LayerImpl::SetScrollbarOpacity(float opacity) { | 981 void LayerImpl::SetScrollbarOpacity(float opacity) { |
982 if (horizontal_scrollbar_layer_) | 982 if (horizontal_scrollbar_layer_) |
983 horizontal_scrollbar_layer_->SetOpacity(opacity); | 983 horizontal_scrollbar_layer_->SetOpacity(opacity); |
984 if (vertical_scrollbar_layer_) | 984 if (vertical_scrollbar_layer_) |
985 vertical_scrollbar_layer_->SetOpacity(opacity); | 985 vertical_scrollbar_layer_->SetOpacity(opacity); |
986 } | 986 } |
987 | 987 |
988 inline scoped_ptr<ScrollbarAnimationController> | |
989 CreateScrollbarAnimationControllerWithFade(LayerImpl* layer) { | |
990 base::TimeDelta fadeout_delay = base::TimeDelta::FromMilliseconds(300); | |
991 base::TimeDelta fadeout_length = base::TimeDelta::FromMilliseconds(300); | |
992 return ScrollbarAnimationControllerLinearFade::Create( | |
993 layer, fadeout_delay, fadeout_length) | |
994 .PassAs<ScrollbarAnimationController>(); | |
995 } | |
996 | |
997 void LayerImpl::DidBecomeActive() { | 988 void LayerImpl::DidBecomeActive() { |
998 if (!layer_tree_impl_->settings().use_linear_fade_scrollbar_animator) | 989 if (!layer_tree_impl_->settings().use_linear_fade_scrollbar_animator) |
999 return; | 990 return; |
1000 | 991 |
1001 bool need_scrollbar_animation_controller = horizontal_scrollbar_layer_ || | 992 bool need_scrollbar_animation_controller = horizontal_scrollbar_layer_ || |
1002 vertical_scrollbar_layer_; | 993 vertical_scrollbar_layer_; |
1003 if (need_scrollbar_animation_controller) { | 994 if (need_scrollbar_animation_controller) { |
1004 if (!scrollbar_animation_controller_) { | 995 if (!scrollbar_animation_controller_) { |
| 996 base::TimeDelta fadeout_delay = base::TimeDelta::FromMilliseconds( |
| 997 layer_tree_impl_->settings().scrollbar_linear_fade_delay_ms); |
| 998 base::TimeDelta fadeout_length = base::TimeDelta::FromMilliseconds( |
| 999 layer_tree_impl_->settings().scrollbar_linear_fade_length_ms); |
1005 scrollbar_animation_controller_ = | 1000 scrollbar_animation_controller_ = |
1006 CreateScrollbarAnimationControllerWithFade(this); | 1001 ScrollbarAnimationControllerLinearFade::Create( |
| 1002 this, fadeout_delay, fadeout_length) |
| 1003 .PassAs<ScrollbarAnimationController>(); |
1007 } | 1004 } |
1008 } else { | 1005 } else { |
1009 scrollbar_animation_controller_.reset(); | 1006 scrollbar_animation_controller_.reset(); |
1010 } | 1007 } |
1011 } | 1008 } |
1012 void LayerImpl::SetHorizontalScrollbarLayer( | 1009 void LayerImpl::SetHorizontalScrollbarLayer( |
1013 ScrollbarLayerImpl* scrollbar_layer) { | 1010 ScrollbarLayerImpl* scrollbar_layer) { |
1014 horizontal_scrollbar_layer_ = scrollbar_layer; | 1011 horizontal_scrollbar_layer_ = scrollbar_layer; |
1015 if (horizontal_scrollbar_layer_) | 1012 if (horizontal_scrollbar_layer_) |
1016 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); | 1013 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 | 1168 |
1172 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1169 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
1173 | 1170 |
1174 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1171 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1175 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1172 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1176 AsValueInto(state.get()); | 1173 AsValueInto(state.get()); |
1177 return state.PassAs<base::Value>(); | 1174 return state.PassAs<base::Value>(); |
1178 } | 1175 } |
1179 | 1176 |
1180 } // namespace cc | 1177 } // namespace cc |
OLD | NEW |