| 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 3625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3636 active_tree_->ScrollableSize(), active_tree_->current_page_scale_factor(), | 3636 active_tree_->ScrollableSize(), active_tree_->current_page_scale_factor(), |
| 3637 active_tree_->min_page_scale_factor(), | 3637 active_tree_->min_page_scale_factor(), |
| 3638 active_tree_->max_page_scale_factor()); | 3638 active_tree_->max_page_scale_factor()); |
| 3639 } | 3639 } |
| 3640 | 3640 |
| 3641 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { | 3641 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { |
| 3642 if (animation_host_) | 3642 if (animation_host_) |
| 3643 return animation_host_->ScrollAnimationAbort(); | 3643 return animation_host_->ScrollAnimationAbort(); |
| 3644 | 3644 |
| 3645 layer_impl->layer_animation_controller()->AbortAnimations( | 3645 layer_impl->layer_animation_controller()->AbortAnimations( |
| 3646 Animation::SCROLL_OFFSET); | 3646 AnimationTargetProperty::SCROLL_OFFSET); |
| 3647 } | 3647 } |
| 3648 | 3648 |
| 3649 void LayerTreeHostImpl::ScrollAnimationCreate( | 3649 void LayerTreeHostImpl::ScrollAnimationCreate( |
| 3650 LayerImpl* layer_impl, | 3650 LayerImpl* layer_impl, |
| 3651 const gfx::ScrollOffset& target_offset, | 3651 const gfx::ScrollOffset& target_offset, |
| 3652 const gfx::ScrollOffset& current_offset) { | 3652 const gfx::ScrollOffset& current_offset) { |
| 3653 if (animation_host_) | 3653 if (animation_host_) |
| 3654 return animation_host_->ImplOnlyScrollAnimationCreate( | 3654 return animation_host_->ImplOnlyScrollAnimationCreate( |
| 3655 layer_impl->id(), target_offset, current_offset); | 3655 layer_impl->id(), target_offset, current_offset); |
| 3656 | 3656 |
| 3657 scoped_ptr<ScrollOffsetAnimationCurve> curve = | 3657 scoped_ptr<ScrollOffsetAnimationCurve> curve = |
| 3658 ScrollOffsetAnimationCurve::Create( | 3658 ScrollOffsetAnimationCurve::Create( |
| 3659 target_offset, EaseInOutTimingFunction::Create(), | 3659 target_offset, EaseInOutTimingFunction::Create(), |
| 3660 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); | 3660 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); |
| 3661 curve->SetInitialValue(current_offset); | 3661 curve->SetInitialValue(current_offset); |
| 3662 | 3662 |
| 3663 scoped_ptr<Animation> animation = Animation::Create( | 3663 scoped_ptr<Animation> animation = Animation::Create( |
| 3664 std::move(curve), AnimationIdProvider::NextAnimationId(), | 3664 std::move(curve), AnimationIdProvider::NextAnimationId(), |
| 3665 AnimationIdProvider::NextGroupId(), Animation::SCROLL_OFFSET); | 3665 AnimationIdProvider::NextGroupId(), |
| 3666 AnimationTargetProperty::SCROLL_OFFSET); |
| 3666 animation->set_is_impl_only(true); | 3667 animation->set_is_impl_only(true); |
| 3667 | 3668 |
| 3668 layer_impl->layer_animation_controller()->AddAnimation(std::move(animation)); | 3669 layer_impl->layer_animation_controller()->AddAnimation(std::move(animation)); |
| 3669 } | 3670 } |
| 3670 | 3671 |
| 3671 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( | 3672 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( |
| 3672 LayerImpl* layer_impl, | 3673 LayerImpl* layer_impl, |
| 3673 const gfx::Vector2dF& scroll_delta) { | 3674 const gfx::Vector2dF& scroll_delta) { |
| 3674 if (animation_host_) | 3675 if (animation_host_) |
| 3675 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( | 3676 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( |
| 3676 layer_impl->id(), scroll_delta, layer_impl->MaxScrollOffset(), | 3677 layer_impl->id(), scroll_delta, layer_impl->MaxScrollOffset(), |
| 3677 CurrentBeginFrameArgs().frame_time); | 3678 CurrentBeginFrameArgs().frame_time); |
| 3678 | 3679 |
| 3679 Animation* animation = | 3680 Animation* animation = |
| 3680 layer_impl->layer_animation_controller() | 3681 layer_impl->layer_animation_controller() |
| 3681 ? layer_impl->layer_animation_controller()->GetAnimation( | 3682 ? layer_impl->layer_animation_controller()->GetAnimation( |
| 3682 Animation::SCROLL_OFFSET) | 3683 AnimationTargetProperty::SCROLL_OFFSET) |
| 3683 : nullptr; | 3684 : nullptr; |
| 3684 if (!animation) | 3685 if (!animation) |
| 3685 return false; | 3686 return false; |
| 3686 | 3687 |
| 3687 ScrollOffsetAnimationCurve* curve = | 3688 ScrollOffsetAnimationCurve* curve = |
| 3688 animation->curve()->ToScrollOffsetAnimationCurve(); | 3689 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 3689 | 3690 |
| 3690 gfx::ScrollOffset new_target = | 3691 gfx::ScrollOffset new_target = |
| 3691 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); | 3692 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); |
| 3692 new_target.SetToMax(gfx::ScrollOffset()); | 3693 new_target.SetToMax(gfx::ScrollOffset()); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3867 return task_runner_provider_->HasImplThread(); | 3868 return task_runner_provider_->HasImplThread(); |
| 3868 } | 3869 } |
| 3869 | 3870 |
| 3870 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3871 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3871 // In single threaded mode we skip the pending tree and commit directly to the | 3872 // In single threaded mode we skip the pending tree and commit directly to the |
| 3872 // active tree. | 3873 // active tree. |
| 3873 return !task_runner_provider_->HasImplThread(); | 3874 return !task_runner_provider_->HasImplThread(); |
| 3874 } | 3875 } |
| 3875 | 3876 |
| 3876 } // namespace cc | 3877 } // namespace cc |
| OLD | NEW |