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

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: Rebase. Created 5 years, 2 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), 174 current_begin_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
175 output_surface_(nullptr), 175 output_surface_(nullptr),
176 content_is_suitable_for_gpu_rasterization_(true), 176 content_is_suitable_for_gpu_rasterization_(true),
177 has_gpu_rasterization_trigger_(false), 177 has_gpu_rasterization_trigger_(false),
178 use_gpu_rasterization_(false), 178 use_gpu_rasterization_(false),
179 use_msaa_(false), 179 use_msaa_(false),
180 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), 180 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE),
181 tree_resources_for_gpu_rasterization_dirty_(false), 181 tree_resources_for_gpu_rasterization_dirty_(false),
182 input_handler_client_(NULL), 182 input_handler_client_(NULL),
183 did_lock_scrolling_layer_(false), 183 did_lock_scrolling_layer_(false),
184 should_bubble_scrolls_(false),
185 wheel_scrolling_(false), 184 wheel_scrolling_(false),
186 scroll_affects_scroll_handler_(false), 185 scroll_affects_scroll_handler_(false),
187 scroll_layer_id_when_mouse_over_scrollbar_(0), 186 scroll_layer_id_when_mouse_over_scrollbar_(0),
188 tile_priorities_dirty_(false), 187 tile_priorities_dirty_(false),
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,
194 ManagedMemoryPolicy::kDefaultNumResourcesLimit), 193 ManagedMemoryPolicy::kDefaultNumResourcesLimit),
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 if (optional_has_ancestor_scroll_handler && 2363 if (optional_has_ancestor_scroll_handler &&
2365 scroll_layer_impl->have_scroll_event_handlers()) 2364 scroll_layer_impl->have_scroll_event_handlers())
2366 *optional_has_ancestor_scroll_handler = true; 2365 *optional_has_ancestor_scroll_handler = true;
2367 2366
2368 if (status == SCROLL_STARTED && !potentially_scrolling_layer_impl) 2367 if (status == SCROLL_STARTED && !potentially_scrolling_layer_impl)
2369 potentially_scrolling_layer_impl = scroll_layer_impl; 2368 potentially_scrolling_layer_impl = scroll_layer_impl;
2370 } 2369 }
2371 2370
2372 // Falling back to the root scroll layer ensures generation of root overscroll 2371 // Falling back to the root scroll layer ensures generation of root overscroll
2373 // notifications while preventing scroll updates from being unintentionally 2372 // notifications while preventing scroll updates from being unintentionally
2374 // forwarded to the main thread. 2373 // forwarded to the main thread. The inner viewport layer represents the
2374 // viewport during scrolling.
2375 if (!potentially_scrolling_layer_impl) 2375 if (!potentially_scrolling_layer_impl)
2376 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); 2376 potentially_scrolling_layer_impl = InnerViewportScrollLayer();
2377 2377
2378 // The inner viewport layer represents the viewport. 2378 // The inner viewport layer represents the viewport.
2379 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) 2379 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer())
2380 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); 2380 potentially_scrolling_layer_impl = InnerViewportScrollLayer();
2381 2381
2382 return potentially_scrolling_layer_impl; 2382 return potentially_scrolling_layer_impl;
2383 } 2383 }
2384 2384
(...skipping 10 matching lines...) Expand all
2395 2395
2396 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( 2396 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
2397 LayerImpl* scrolling_layer_impl, 2397 LayerImpl* scrolling_layer_impl,
2398 InputHandler::ScrollInputType type) { 2398 InputHandler::ScrollInputType type) {
2399 if (!scrolling_layer_impl) 2399 if (!scrolling_layer_impl)
2400 return SCROLL_IGNORED; 2400 return SCROLL_IGNORED;
2401 2401
2402 top_controls_manager_->ScrollBegin(); 2402 top_controls_manager_->ScrollBegin();
2403 2403
2404 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); 2404 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl);
2405 should_bubble_scrolls_ = (type != NON_BUBBLING_GESTURE);
2406 wheel_scrolling_ = (type == WHEEL); 2405 wheel_scrolling_ = (type == WHEEL);
2407 client_->RenewTreePriority(); 2406 client_->RenewTreePriority();
2408 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); 2407 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
2409 return SCROLL_STARTED; 2408 return SCROLL_STARTED;
2410 } 2409 }
2411 2410
2412 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( 2411 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin(
2413 InputHandler::ScrollInputType type) { 2412 InputHandler::ScrollInputType type) {
2414 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin"); 2413 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin");
2415 2414
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 // in which the layer moved. 2643 // in which the layer moved.
2645 applied_delta = MathUtil::ProjectVector(delta, applied_delta); 2644 applied_delta = MathUtil::ProjectVector(delta, applied_delta);
2646 } 2645 }
2647 scroll_state->set_caused_scroll(std::abs(applied_delta.x()) > kEpsilon, 2646 scroll_state->set_caused_scroll(std::abs(applied_delta.x()) > kEpsilon,
2648 std::abs(applied_delta.y()) > kEpsilon); 2647 std::abs(applied_delta.y()) > kEpsilon);
2649 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 2648 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
2650 } 2649 }
2651 2650
2652 if (!scrolled) 2651 if (!scrolled)
2653 return; 2652 return;
2654 // When scrolls are allowed to bubble, it's important that the original 2653
2655 // scrolling layer be preserved. This ensures that, after a scroll 2654 scroll_state->set_current_native_scrolling_layer(layer);
2656 // bubbles, the user can reverse scroll directions and immediately resume
2657 // scrolling the original layer that scrolled.
2658 if (!scroll_state->should_propagate())
2659 scroll_state->set_current_native_scrolling_layer(layer);
2660 } 2655 }
2661 2656
2662 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( 2657 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
2663 const gfx::Point& viewport_point, 2658 const gfx::Point& viewport_point,
2664 const gfx::Vector2dF& scroll_delta) { 2659 const gfx::Vector2dF& scroll_delta) {
2665 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); 2660 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
2666 if (!CurrentlyScrollingLayer()) 2661 if (!CurrentlyScrollingLayer())
2667 return InputHandlerScrollResult(); 2662 return InputHandlerScrollResult();
2668 2663
2669 float initial_top_controls_offset = 2664 float initial_top_controls_offset =
2670 top_controls_manager_->ControlsTopOffset(); 2665 top_controls_manager_->ControlsTopOffset();
2671 ScrollState scroll_state( 2666 ScrollState scroll_state(
2672 scroll_delta.x(), scroll_delta.y(), viewport_point.x(), 2667 scroll_delta.x(), scroll_delta.y(), viewport_point.x(),
2673 viewport_point.y(), should_bubble_scrolls_ /* should_propagate */, 2668 viewport_point.y(), false /* should_propagate */,
2674 did_lock_scrolling_layer_ /* delta_consumed_for_scroll_sequence */, 2669 did_lock_scrolling_layer_ /* delta_consumed_for_scroll_sequence */,
2675 !wheel_scrolling_ /* is_direct_manipulation */); 2670 !wheel_scrolling_ /* is_direct_manipulation */);
2676 scroll_state.set_current_native_scrolling_layer(CurrentlyScrollingLayer()); 2671 scroll_state.set_current_native_scrolling_layer(CurrentlyScrollingLayer());
2677 2672
2678 std::list<LayerImpl*> current_scroll_chain; 2673 std::list<LayerImpl*> current_scroll_chain;
2679 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; 2674 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl;
2680 layer_impl = NextLayerInScrollOrder(layer_impl)) { 2675 layer_impl = NextLayerInScrollOrder(layer_impl)) {
2681 // Skip the outer viewport scroll layer so that we try to scroll the 2676 // Skip the outer viewport scroll layer so that we try to scroll the
2682 // viewport only once. i.e. The inner viewport layer represents the 2677 // viewport only once. i.e. The inner viewport layer represents the
2683 // viewport. 2678 // viewport.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 } 2800 }
2806 2801
2807 void LayerTreeHostImpl::ScrollEnd() { 2802 void LayerTreeHostImpl::ScrollEnd() {
2808 top_controls_manager_->ScrollEnd(); 2803 top_controls_manager_->ScrollEnd();
2809 ClearCurrentlyScrollingLayer(); 2804 ClearCurrentlyScrollingLayer();
2810 } 2805 }
2811 2806
2812 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { 2807 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
2813 if (!CurrentlyScrollingLayer()) 2808 if (!CurrentlyScrollingLayer())
2814 return SCROLL_IGNORED; 2809 return SCROLL_IGNORED;
2815
2816 bool currently_scrolling_viewport =
2817 CurrentlyScrollingLayer() == InnerViewportScrollLayer();
2818 if (!wheel_scrolling_ && !currently_scrolling_viewport) {
2819 // Allow the fling to lock to the first layer that moves after the initial
2820 // fling |ScrollBy()| event, unless we're already scrolling the viewport.
2821 did_lock_scrolling_layer_ = false;
2822 should_bubble_scrolls_ = false;
2823 }
2824
2825 return SCROLL_STARTED; 2810 return SCROLL_STARTED;
2826 } 2811 }
2827 2812
2828 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( 2813 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
2829 const gfx::PointF& device_viewport_point, 2814 const gfx::PointF& device_viewport_point,
2830 LayerImpl* layer_impl) { 2815 LayerImpl* layer_impl) {
2831 if (!layer_impl) 2816 if (!layer_impl)
2832 return std::numeric_limits<float>::max(); 2817 return std::numeric_limits<float>::max();
2833 2818
2834 gfx::Rect layer_impl_bounds(layer_impl->bounds()); 2819 gfx::Rect layer_impl_bounds(layer_impl->bounds());
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3612 if (active_tree()) { 3597 if (active_tree()) {
3613 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); 3598 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
3614 if (layer) 3599 if (layer)
3615 return layer->ScrollOffsetForAnimation(); 3600 return layer->ScrollOffsetForAnimation();
3616 } 3601 }
3617 3602
3618 return gfx::ScrollOffset(); 3603 return gfx::ScrollOffset();
3619 } 3604 }
3620 3605
3621 } // namespace cc 3606 } // 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