diff options
author | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-18 06:45:20 +0000 |
---|---|---|
committer | aelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-18 06:45:20 +0000 |
commit | 0fc818ec6e012243303de3e013037c8c0221c83f (patch) | |
tree | 968a152d95cd78ac42fa616fd34e2509144b267e /cc/layer_tree_host_impl.cc | |
parent | 32eee898d3d502b8b62e8f48f5eb9ac021e3489d (diff) | |
download | chromium_src-0fc818ec6e012243303de3e013037c8c0221c83f.zip chromium_src-0fc818ec6e012243303de3e013037c8c0221c83f.tar.gz chromium_src-0fc818ec6e012243303de3e013037c8c0221c83f.tar.bz2 |
cc: Delay start of scrollbar animation setNeedsRedraw.
This adds a 300ms delay triggered at ScrollEnd in order to avoid
beginning the setNeedsRedraw cycle until we really start fading the
scrollbar, in order to improve performance during non-fling scrolls.
Notes:
- I switched to notifying the animator about ScrollBegin/ScrollEnd when
the currently scrolling layer is attached/detached, and suppress fading
until ScrollEnd.
- The scrollUpdate path is still needed for when the scroll position changes
due to e.g. Javascript, but it's a no-op during a scroll gesture.
- I deleted the pinchGesture logic for simplicity, as there's no
reason to treat pinches differently from scrolls.
- I switches cc::Thread to use TimeDelta for its postDelayedTask since
I ran into some bugs with the flooring to milliseconds. I updated the
few other callers.
NOTRY=true
BUG=181417
Review URL: https://chromiumcodereview.appspot.com/12408028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host_impl.cc')
-rw-r--r-- | cc/layer_tree_host_impl.cc | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index 32290c4..3270702 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -1392,7 +1392,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::ScrollBegin( } if (potentially_scrolling_layer_impl) { - active_tree_->set_currently_scrolling_layer( + active_tree_->SetCurrentlyScrollingLayer( potentially_scrolling_layer_impl); should_bubble_scrolls_ = (type != NonBubblingGesture); wheel_scrolling_ = (type == Wheel); @@ -1534,7 +1534,7 @@ bool LayerTreeHostImpl::ScrollBy(gfx::Point viewport_point, did_scroll = true; did_lock_scrolling_layer_ = true; if (!should_bubble_scrolls_) { - active_tree_->set_currently_scrolling_layer(layer_impl); + active_tree_->SetCurrentlyScrollingLayer(layer_impl); break; } @@ -1576,6 +1576,7 @@ void LayerTreeHostImpl::ScrollEnd() { top_controls_manager_->ScrollEnd(); ClearCurrentlyScrollingLayer(); active_tree()->DidEndScroll(); + StartScrollbarAnimation(base::TimeTicks::Now()); } void LayerTreeHostImpl::PinchGestureBegin() { @@ -1608,11 +1609,6 @@ void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, RootScrollLayer()->ScrollBy(move); - if (RootScrollLayer()->scrollbar_animation_controller()) { - RootScrollLayer()->scrollbar_animation_controller()-> - didPinchGestureUpdate(base::TimeTicks::Now()); - } - client_->SetNeedsCommitOnImplThread(); client_->SetNeedsRedrawOnImplThread(); client_->RenewTreePriority(); @@ -1620,13 +1616,6 @@ void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, void LayerTreeHostImpl::PinchGestureEnd() { pinch_gesture_active_ = false; - - if (RootScrollLayer() && - RootScrollLayer()->scrollbar_animation_controller()) { - RootScrollLayer()->scrollbar_animation_controller()-> - didPinchGestureEnd(base::TimeTicks::Now()); - } - client_->SetNeedsCommitOnImplThread(); } @@ -1855,13 +1844,40 @@ void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, ScrollbarAnimationController* scrollbar_controller = layer->scrollbar_animation_controller(); - if (scrollbar_controller && scrollbar_controller->animate(time)) + if (scrollbar_controller && scrollbar_controller->animate(time)) { + TRACE_EVENT_INSTANT0( + "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars"); client_->SetNeedsRedrawOnImplThread(); + } for (size_t i = 0; i < layer->children().size(); ++i) AnimateScrollbarsRecursive(layer->children()[i], time); } +void LayerTreeHostImpl::StartScrollbarAnimation(base::TimeTicks time) { + TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation"); + StartScrollbarAnimationRecursive(RootLayer(), time); +} + +void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer, + base::TimeTicks time) { + if (!layer) + return; + + ScrollbarAnimationController* scrollbar_controller = + layer->scrollbar_animation_controller(); + if (scrollbar_controller && scrollbar_controller->isAnimating()) { + base::TimeDelta delay = scrollbar_controller->delayBeforeStart(time); + if (delay > base::TimeDelta()) + client_->RequestScrollbarAnimationOnImplThread(delay); + else if (scrollbar_controller->animate(time)) + client_->SetNeedsRedrawOnImplThread(); + } + + for (size_t i = 0; i < layer->children().size(); ++i) + StartScrollbarAnimationRecursive(layer->children()[i], time); +} + void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { if (!tile_manager_) return; |