| 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 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 | 2771 |
| 2772 gfx::ScrollOffset old_offset = | 2772 gfx::ScrollOffset old_offset = |
| 2773 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2773 scroll_tree.current_scroll_offset(scroll_node->owner_id); |
| 2774 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( | 2774 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( |
| 2775 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); | 2775 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); |
| 2776 | 2776 |
| 2777 gfx::ScrollOffset scrolled = new_offset - old_offset; | 2777 gfx::ScrollOffset scrolled = new_offset - old_offset; |
| 2778 return gfx::Vector2dF(scrolled.x(), scrolled.y()); | 2778 return gfx::Vector2dF(scrolled.x(), scrolled.y()); |
| 2779 } | 2779 } |
| 2780 | 2780 |
| 2781 bool LayerTreeHostImpl::ScrollAnimationCreate(ScrollNode* scroll_node, | 2781 bool LayerTreeHostImpl::ScrollAnimationCreate( |
| 2782 const gfx::Vector2dF& delta) { | 2782 ScrollNode* scroll_node, |
| 2783 const gfx::Vector2dF& delta, |
| 2784 base::TimeTicks original_event_time) { |
| 2783 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2785 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 2784 | 2786 |
| 2785 const float kEpsilon = 0.1f; | 2787 const float kEpsilon = 0.1f; |
| 2786 bool scroll_animated = | 2788 bool scroll_animated = |
| 2787 (std::abs(delta.x()) > kEpsilon || std::abs(delta.y()) > kEpsilon); | 2789 (std::abs(delta.x()) > kEpsilon || std::abs(delta.y()) > kEpsilon); |
| 2788 if (!scroll_animated) { | 2790 if (!scroll_animated) { |
| 2789 scroll_tree.ScrollBy(scroll_node, delta, active_tree()); | 2791 scroll_tree.ScrollBy(scroll_node, delta, active_tree()); |
| 2790 return false; | 2792 return false; |
| 2791 } | 2793 } |
| 2792 | 2794 |
| 2793 scroll_tree.set_currently_scrolling_node(scroll_node->id); | 2795 scroll_tree.set_currently_scrolling_node(scroll_node->id); |
| 2794 | 2796 |
| 2795 gfx::ScrollOffset current_offset = | 2797 gfx::ScrollOffset current_offset = |
| 2796 scroll_tree.current_scroll_offset(scroll_node->owner_id); | 2798 scroll_tree.current_scroll_offset(scroll_node->owner_id); |
| 2797 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( | 2799 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( |
| 2798 current_offset + gfx::ScrollOffset(delta), scroll_node); | 2800 current_offset + gfx::ScrollOffset(delta), scroll_node); |
| 2799 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->owner_id, | 2801 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->owner_id, |
| 2800 target_offset, current_offset); | 2802 target_offset, current_offset, |
| 2803 original_event_time); |
| 2801 | 2804 |
| 2802 SetNeedsOneBeginImplFrame(); | 2805 SetNeedsOneBeginImplFrame(); |
| 2803 | 2806 |
| 2804 return true; | 2807 return true; |
| 2805 } | 2808 } |
| 2806 | 2809 |
| 2807 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 2810 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
| 2808 const gfx::Point& viewport_point, | 2811 const gfx::Point& viewport_point, |
| 2809 const gfx::Vector2dF& scroll_delta) { | 2812 const gfx::Vector2dF& scroll_delta, |
| 2813 const ui::LatencyInfo* latency_info) { |
| 2810 InputHandler::ScrollStatus scroll_status; | 2814 InputHandler::ScrollStatus scroll_status; |
| 2811 scroll_status.main_thread_scrolling_reasons = | 2815 scroll_status.main_thread_scrolling_reasons = |
| 2812 MainThreadScrollingReason::kNotScrollingOnMain; | 2816 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2813 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 2817 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 2814 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2818 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2815 if (scroll_node) { | 2819 if (scroll_node) { |
| 2816 gfx::Vector2dF delta = scroll_delta; | 2820 gfx::Vector2dF delta = scroll_delta; |
| 2817 if (!scroll_node->data.user_scrollable_horizontal) | 2821 if (!scroll_node->data.user_scrollable_horizontal) |
| 2818 delta.set_x(0); | 2822 delta.set_x(0); |
| 2819 if (!scroll_node->data.user_scrollable_vertical) | 2823 if (!scroll_node->data.user_scrollable_vertical) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2843 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2847 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2844 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2848 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2845 gfx::Vector2dF pending_delta = scroll_delta; | 2849 gfx::Vector2dF pending_delta = scroll_delta; |
| 2846 if (scroll_node) { | 2850 if (scroll_node) { |
| 2847 for (; scroll_tree.parent(scroll_node); | 2851 for (; scroll_tree.parent(scroll_node); |
| 2848 scroll_node = scroll_tree.parent(scroll_node)) { | 2852 scroll_node = scroll_tree.parent(scroll_node)) { |
| 2849 if (!scroll_node->data.scrollable || | 2853 if (!scroll_node->data.scrollable || |
| 2850 scroll_node->data.is_outer_viewport_scroll_layer) | 2854 scroll_node->data.is_outer_viewport_scroll_layer) |
| 2851 continue; | 2855 continue; |
| 2852 | 2856 |
| 2857 // Some time may have passed between now and when the user actually |
| 2858 // asked to scroll. The animation curve should take this into account |
| 2859 // in the duration of the animation. |
| 2860 ui::LatencyInfo::LatencyComponent o_component; |
| 2861 o_component.event_time = base::TimeTicks(); |
| 2862 if (latency_info) |
| 2863 latency_info->FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 2864 0, &o_component); |
| 2865 |
| 2853 if (scroll_node->data.is_inner_viewport_scroll_layer) { | 2866 if (scroll_node->data.is_inner_viewport_scroll_layer) { |
| 2854 gfx::Vector2dF scrolled = viewport()->ScrollAnimated(pending_delta); | 2867 gfx::Vector2dF scrolled = |
| 2868 viewport()->ScrollAnimated(pending_delta, o_component.event_time); |
| 2855 // Viewport::ScrollAnimated returns pending_delta as long as it | 2869 // Viewport::ScrollAnimated returns pending_delta as long as it |
| 2856 // starts an animation. | 2870 // starts an animation. |
| 2857 if (scrolled == pending_delta) | 2871 if (scrolled == pending_delta) |
| 2858 return scroll_status; | 2872 return scroll_status; |
| 2859 pending_delta -= scrolled; | 2873 pending_delta -= scrolled; |
| 2860 continue; | 2874 continue; |
| 2861 } | 2875 } |
| 2862 | 2876 |
| 2863 gfx::Vector2dF scroll_delta = | 2877 gfx::Vector2dF scroll_delta = |
| 2864 ComputeScrollDelta(scroll_node, pending_delta); | 2878 ComputeScrollDelta(scroll_node, pending_delta); |
| 2865 if (ScrollAnimationCreate(scroll_node, scroll_delta)) | 2879 if (ScrollAnimationCreate(scroll_node, scroll_delta, |
| 2880 o_component.event_time)) |
| 2866 return scroll_status; | 2881 return scroll_status; |
| 2867 | 2882 |
| 2868 pending_delta -= scroll_delta; | 2883 pending_delta -= scroll_delta; |
| 2869 } | 2884 } |
| 2870 } | 2885 } |
| 2871 } | 2886 } |
| 2872 scroll_state.set_is_ending(true); | 2887 scroll_state.set_is_ending(true); |
| 2873 ScrollEnd(&scroll_state); | 2888 ScrollEnd(&scroll_state); |
| 2874 return scroll_status; | 2889 return scroll_status; |
| 2875 } | 2890 } |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4029 const { | 4044 const { |
| 4030 return fixed_raster_scale_attempted_scale_change_history_.count() >= | 4045 return fixed_raster_scale_attempted_scale_change_history_.count() >= |
| 4031 kFixedRasterScaleAttemptedScaleChangeThreshold; | 4046 kFixedRasterScaleAttemptedScaleChangeThreshold; |
| 4032 } | 4047 } |
| 4033 | 4048 |
| 4034 void LayerTreeHostImpl::SetFixedRasterScaleAttemptedToChangeScale() { | 4049 void LayerTreeHostImpl::SetFixedRasterScaleAttemptedToChangeScale() { |
| 4035 fixed_raster_scale_attempted_scale_change_history_.set(0); | 4050 fixed_raster_scale_attempted_scale_change_history_.set(0); |
| 4036 } | 4051 } |
| 4037 | 4052 |
| 4038 } // namespace cc | 4053 } // namespace cc |
| OLD | NEW |