Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 1306193006: Remove touch scroll chaining from compositor scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@disable_chaining_no_bubbling
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 proxy_(proxy), 173 proxy_(proxy),
174 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), 174 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
175 content_is_suitable_for_gpu_rasterization_(true), 175 content_is_suitable_for_gpu_rasterization_(true),
176 has_gpu_rasterization_trigger_(false), 176 has_gpu_rasterization_trigger_(false),
177 use_gpu_rasterization_(false), 177 use_gpu_rasterization_(false),
178 use_msaa_(false), 178 use_msaa_(false),
179 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), 179 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE),
180 tree_resources_for_gpu_rasterization_dirty_(false), 180 tree_resources_for_gpu_rasterization_dirty_(false),
181 input_handler_client_(NULL), 181 input_handler_client_(NULL),
182 did_lock_scrolling_layer_(false), 182 did_lock_scrolling_layer_(false),
183 should_bubble_scrolls_(false),
184 wheel_scrolling_(false), 183 wheel_scrolling_(false),
185 scroll_affects_scroll_handler_(false), 184 scroll_affects_scroll_handler_(false),
186 scroll_layer_id_when_mouse_over_scrollbar_(0), 185 scroll_layer_id_when_mouse_over_scrollbar_(0),
187 tile_priorities_dirty_(false), 186 tile_priorities_dirty_(false),
188 root_layer_scroll_offset_delegate_(NULL), 187 root_layer_scroll_offset_delegate_(NULL),
189 settings_(settings), 188 settings_(settings),
190 visible_(true), 189 visible_(true),
191 cached_managed_memory_policy_( 190 cached_managed_memory_policy_(
192 GetDefaultMemoryAllocationLimit(), 191 GetDefaultMemoryAllocationLimit(),
193 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 192 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 2388
2390 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( 2389 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
2391 LayerImpl* scrolling_layer_impl, 2390 LayerImpl* scrolling_layer_impl,
2392 InputHandler::ScrollInputType type) { 2391 InputHandler::ScrollInputType type) {
2393 if (!scrolling_layer_impl) 2392 if (!scrolling_layer_impl)
2394 return SCROLL_IGNORED; 2393 return SCROLL_IGNORED;
2395 2394
2396 top_controls_manager_->ScrollBegin(); 2395 top_controls_manager_->ScrollBegin();
2397 2396
2398 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); 2397 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl);
2399 should_bubble_scrolls_ = (type != NON_BUBBLING_GESTURE);
2400 wheel_scrolling_ = (type == WHEEL); 2398 wheel_scrolling_ = (type == WHEEL);
2401 client_->RenewTreePriority(); 2399 client_->RenewTreePriority();
2402 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); 2400 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
2403 return SCROLL_STARTED; 2401 return SCROLL_STARTED;
2404 } 2402 }
2405 2403
2406 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( 2404 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin(
2407 InputHandler::ScrollInputType type) { 2405 InputHandler::ScrollInputType type) {
2408 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin"); 2406 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin");
2409 2407
(...skipping 22 matching lines...) Expand all
2432 device_viewport_point); 2430 device_viewport_point);
2433 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) 2431 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl))
2434 return SCROLL_UNKNOWN; 2432 return SCROLL_UNKNOWN;
2435 } 2433 }
2436 2434
2437 bool scroll_on_main_thread = false; 2435 bool scroll_on_main_thread = false;
2438 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 2436 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
2439 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 2437 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
2440 &scroll_affects_scroll_handler_); 2438 &scroll_affects_scroll_handler_);
2441 2439
2440 // The inner viewport layer represents the viewport during scrolling.
jdduke (slow) 2015/09/09 14:41:10 Should we instead move this adjustment into FindSc
tdresser 2015/09/10 13:56:51 Absolutely, thanks. Done.
2441 if (scrolling_layer_impl == OuterViewportScrollLayer())
2442 scrolling_layer_impl = InnerViewportScrollLayer();
2443
2442 if (scroll_on_main_thread) { 2444 if (scroll_on_main_thread) {
2443 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); 2445 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true);
2444 return SCROLL_ON_MAIN_THREAD; 2446 return SCROLL_ON_MAIN_THREAD;
2445 } 2447 }
2446 2448
2447 return ScrollBeginImpl(scrolling_layer_impl, type); 2449 return ScrollBeginImpl(scrolling_layer_impl, type);
2448 } 2450 }
2449 2451
2450 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( 2452 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
2451 const gfx::Point& viewport_point, 2453 const gfx::Point& viewport_point,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 // in which the layer moved. 2638 // in which the layer moved.
2637 applied_delta = MathUtil::ProjectVector(delta, applied_delta); 2639 applied_delta = MathUtil::ProjectVector(delta, applied_delta);
2638 } 2640 }
2639 scroll_state->set_caused_scroll(std::abs(applied_delta.x()) > kEpsilon, 2641 scroll_state->set_caused_scroll(std::abs(applied_delta.x()) > kEpsilon,
2640 std::abs(applied_delta.y()) > kEpsilon); 2642 std::abs(applied_delta.y()) > kEpsilon);
2641 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 2643 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
2642 } 2644 }
2643 2645
2644 if (!scrolled) 2646 if (!scrolled)
2645 return; 2647 return;
2646 // When scrolls are allowed to bubble, it's important that the original 2648
2647 // scrolling layer be preserved. This ensures that, after a scroll 2649 scroll_state->set_current_native_scrolling_layer(layer);
2648 // bubbles, the user can reverse scroll directions and immediately resume
2649 // scrolling the original layer that scrolled.
2650 if (!scroll_state->should_propagate())
2651 scroll_state->set_current_native_scrolling_layer(layer);
2652 } 2650 }
2653 2651
2654 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( 2652 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
2655 const gfx::Point& viewport_point, 2653 const gfx::Point& viewport_point,
2656 const gfx::Vector2dF& scroll_delta) { 2654 const gfx::Vector2dF& scroll_delta) {
2657 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); 2655 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
2658 if (!CurrentlyScrollingLayer()) 2656 if (!CurrentlyScrollingLayer())
2659 return InputHandlerScrollResult(); 2657 return InputHandlerScrollResult();
2660 2658
2661 float initial_top_controls_offset = 2659 float initial_top_controls_offset =
2662 top_controls_manager_->ControlsTopOffset(); 2660 top_controls_manager_->ControlsTopOffset();
2663 ScrollState scroll_state( 2661 ScrollState scroll_state(
2664 scroll_delta.x(), scroll_delta.y(), viewport_point.x(), 2662 scroll_delta.x(), scroll_delta.y(), viewport_point.x(),
2665 viewport_point.y(), should_bubble_scrolls_ /* should_propagate */, 2663 viewport_point.y(), false /* should_propagate */,
2666 did_lock_scrolling_layer_ /* delta_consumed_for_scroll_sequence */, 2664 did_lock_scrolling_layer_ /* delta_consumed_for_scroll_sequence */,
2667 !wheel_scrolling_ /* is_direct_manipulation */); 2665 !wheel_scrolling_ /* is_direct_manipulation */);
2668 scroll_state.set_current_native_scrolling_layer(CurrentlyScrollingLayer()); 2666 scroll_state.set_current_native_scrolling_layer(CurrentlyScrollingLayer());
2669 2667
2670 std::list<LayerImpl*> current_scroll_chain; 2668 std::list<LayerImpl*> current_scroll_chain;
2671 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; 2669 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl;
2672 layer_impl = nextLayerInScrollOrder(layer_impl)) { 2670 layer_impl = nextLayerInScrollOrder(layer_impl)) {
2673 // Skip the outer viewport scroll layer so that we try to scroll the 2671 // Skip the outer viewport scroll layer so that we try to scroll the
2674 // viewport only once. i.e. The inner viewport layer represents the 2672 // viewport only once. i.e. The inner viewport layer represents the
2675 // viewport. 2673 // viewport.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 2791
2794 void LayerTreeHostImpl::ScrollEnd() { 2792 void LayerTreeHostImpl::ScrollEnd() {
2795 top_controls_manager_->ScrollEnd(); 2793 top_controls_manager_->ScrollEnd();
2796 ClearCurrentlyScrollingLayer(); 2794 ClearCurrentlyScrollingLayer();
2797 } 2795 }
2798 2796
2799 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { 2797 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
2800 if (!CurrentlyScrollingLayer()) 2798 if (!CurrentlyScrollingLayer())
2801 return SCROLL_IGNORED; 2799 return SCROLL_IGNORED;
2802 2800
2803 bool currently_scrolling_viewport =
2804 CurrentlyScrollingLayer() == OuterViewportScrollLayer() ||
2805 CurrentlyScrollingLayer() == InnerViewportScrollLayer();
2806 if (!wheel_scrolling_ && !currently_scrolling_viewport) {
2807 // Allow the fling to lock to the first layer that moves after the initial
2808 // fling |ScrollBy()| event, unless we're already scrolling the viewport.
2809 did_lock_scrolling_layer_ = false;
2810 should_bubble_scrolls_ = false;
2811 }
2812
2813 return SCROLL_STARTED; 2801 return SCROLL_STARTED;
2814 } 2802 }
2815 2803
2816 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( 2804 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
2817 const gfx::PointF& device_viewport_point, 2805 const gfx::PointF& device_viewport_point,
2818 LayerImpl* layer_impl) { 2806 LayerImpl* layer_impl) {
2819 if (!layer_impl) 2807 if (!layer_impl)
2820 return std::numeric_limits<float>::max(); 2808 return std::numeric_limits<float>::max();
2821 2809
2822 gfx::Rect layer_impl_bounds(layer_impl->bounds()); 2810 gfx::Rect layer_impl_bounds(layer_impl->bounds());
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 if (active_tree()) { 3600 if (active_tree()) {
3613 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); 3601 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
3614 if (layer) 3602 if (layer)
3615 return layer->ScrollOffsetForAnimation(); 3603 return layer->ScrollOffsetForAnimation();
3616 } 3604 }
3617 3605
3618 return gfx::ScrollOffset(); 3606 return gfx::ScrollOffset();
3619 } 3607 }
3620 3608
3621 } // namespace cc 3609 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698