| 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 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 if (ScrollAnimationUpdateTarget(layer_impl, delta)) { | 2627 if (ScrollAnimationUpdateTarget(layer_impl, delta)) { |
| 2628 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 2628 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
| 2629 } else { | 2629 } else { |
| 2630 scroll_status.thread = SCROLL_IGNORED; | 2630 scroll_status.thread = SCROLL_IGNORED; |
| 2631 scroll_status.main_thread_scrolling_reasons = | 2631 scroll_status.main_thread_scrolling_reasons = |
| 2632 MainThreadScrollingReason::kNotScrollable; | 2632 MainThreadScrollingReason::kNotScrollable; |
| 2633 } | 2633 } |
| 2634 return scroll_status; | 2634 return scroll_status; |
| 2635 } | 2635 } |
| 2636 | 2636 |
| 2637 ScrollState scroll_state(0, 0, viewport_point.x(), viewport_point.y(), 0, 0, | 2637 ScrollStateData scroll_state_data; |
| 2638 false, true, false); | 2638 scroll_state_data.start_position_x = viewport_point.x(); |
| 2639 scroll_state_data.start_position_y = viewport_point.y(); |
| 2640 scroll_state_data.is_in_inertial_phase = true; |
| 2641 ScrollState scroll_state(scroll_state_data); |
| 2642 |
| 2639 // ScrollAnimated is used for animated wheel scrolls. We find the first layer | 2643 // ScrollAnimated is used for animated wheel scrolls. We find the first layer |
| 2640 // that can scroll and set up an animation of its scroll offset. Note that | 2644 // that can scroll and set up an animation of its scroll offset. Note that |
| 2641 // this does not currently go through the scroll customization and viewport | 2645 // this does not currently go through the scroll customization and viewport |
| 2642 // machinery that ScrollBy uses for non-animated wheel scrolls. | 2646 // machinery that ScrollBy uses for non-animated wheel scrolls. |
| 2643 scroll_status = ScrollBegin(&scroll_state, ANIMATED_WHEEL); | 2647 scroll_status = ScrollBegin(&scroll_state, ANIMATED_WHEEL); |
| 2644 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2648 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2645 gfx::Vector2dF pending_delta = scroll_delta; | 2649 gfx::Vector2dF pending_delta = scroll_delta; |
| 2646 LayerImpl* layer_impl = CurrentlyScrollingLayer(); | 2650 LayerImpl* layer_impl = CurrentlyScrollingLayer(); |
| 2647 if (layer_impl) { | 2651 if (layer_impl) { |
| 2648 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2652 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3847 TreeLayerTransformIsPotentiallyAnimatingChanged(layer_id, active_tree(), | 3851 TreeLayerTransformIsPotentiallyAnimatingChanged(layer_id, active_tree(), |
| 3848 is_animating); | 3852 is_animating); |
| 3849 } else { | 3853 } else { |
| 3850 TreeLayerTransformIsPotentiallyAnimatingChanged(layer_id, pending_tree(), | 3854 TreeLayerTransformIsPotentiallyAnimatingChanged(layer_id, pending_tree(), |
| 3851 is_animating); | 3855 is_animating); |
| 3852 } | 3856 } |
| 3853 } | 3857 } |
| 3854 | 3858 |
| 3855 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { | 3859 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { |
| 3856 // TODO(majidvp): We should pass in the original starting scroll position here | 3860 // TODO(majidvp): We should pass in the original starting scroll position here |
| 3857 ScrollState scroll_state(0, 0, 0, 0, 0, 0, false, false, false); | 3861 ScrollStateData scroll_state_data; |
| 3862 ScrollState scroll_state(scroll_state_data); |
| 3858 ScrollEnd(&scroll_state); | 3863 ScrollEnd(&scroll_state); |
| 3859 } | 3864 } |
| 3860 | 3865 |
| 3861 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( | 3866 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( |
| 3862 int layer_id) const { | 3867 int layer_id) const { |
| 3863 if (active_tree()) { | 3868 if (active_tree()) { |
| 3864 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); | 3869 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); |
| 3865 if (layer) | 3870 if (layer) |
| 3866 return layer->ScrollOffsetForAnimation(); | 3871 return layer->ScrollOffsetForAnimation(); |
| 3867 } | 3872 } |
| 3868 | 3873 |
| 3869 return gfx::ScrollOffset(); | 3874 return gfx::ScrollOffset(); |
| 3870 } | 3875 } |
| 3871 | 3876 |
| 3872 bool LayerTreeHostImpl::SupportsImplScrolling() const { | 3877 bool LayerTreeHostImpl::SupportsImplScrolling() const { |
| 3873 // Supported in threaded mode. | 3878 // Supported in threaded mode. |
| 3874 return task_runner_provider_->HasImplThread(); | 3879 return task_runner_provider_->HasImplThread(); |
| 3875 } | 3880 } |
| 3876 | 3881 |
| 3877 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3882 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3878 // In single threaded mode we skip the pending tree and commit directly to the | 3883 // In single threaded mode we skip the pending tree and commit directly to the |
| 3879 // active tree. | 3884 // active tree. |
| 3880 return !task_runner_provider_->HasImplThread(); | 3885 return !task_runner_provider_->HasImplThread(); |
| 3881 } | 3886 } |
| 3882 | 3887 |
| 3883 } // namespace cc | 3888 } // namespace cc |
| OLD | NEW |