From 7a7d5bec832fd997b6b2eef3ec9c0906b74ef16d Mon Sep 17 00:00:00 2001 From: "skobes@chromium.org" Date: Fri, 18 Jul 2014 22:37:26 +0000 Subject: Scroll offset animation curve retargeting. Adds support for updating the target of an in-progress input-triggered impl-side scroll offset animation, keeping the velocity function continuous. BUG=575 Review URL: https://codereview.chromium.org/393713002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284228 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/trees/layer_tree_host_impl.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'cc/trees/layer_tree_host_impl.cc') diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index a2c8111..f137cb4 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2302,9 +2302,25 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( const gfx::Point& viewport_point, const gfx::Vector2dF& scroll_delta) { - if (CurrentlyScrollingLayer()) { - // TODO(skobes): Update the target of the existing animation. - return ScrollIgnored; + if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { + Animation* animation = + layer_impl->layer_animation_controller()->GetAnimation( + Animation::ScrollOffset); + if (!animation) + return ScrollIgnored; + + ScrollOffsetAnimationCurve* curve = + animation->curve()->ToScrollOffsetAnimationCurve(); + + gfx::Vector2dF new_target = curve->target_value() + scroll_delta; + new_target.SetToMax(gfx::Vector2dF()); + new_target.SetToMin(layer_impl->MaxScrollOffset()); + + curve->UpdateTarget( + animation->TrimTimeToCurrentIteration(CurrentFrameTimeTicks()), + new_target); + + return ScrollStarted; } // ScrollAnimated is only used for wheel scrolls. We use the same bubbling // behavior as ScrollBy to determine which layer to animate, but we do not @@ -2341,7 +2357,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( curve->SetInitialValue(current_offset); scoped_ptr animation = - Animation::Create(curve->Clone().Pass(), + Animation::Create(curve.PassAs(), AnimationIdProvider::NextAnimationId(), AnimationIdProvider::NextGroupId(), Animation::ScrollOffset); -- cgit v1.1