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

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

Issue 1749343004: Implement Wheel Gesture Scrolling on OSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only high precision scroll begins are used Created 4 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) { 134 void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) {
135 if (visible) { 135 if (visible) {
136 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id, 136 TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id,
137 "LayerTreeHostImpl", id); 137 "LayerTreeHostImpl", id);
138 return; 138 return;
139 } 139 }
140 140
141 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id); 141 TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id);
142 } 142 }
143 143
144 bool IsWheelBasedScroll(InputHandler::ScrollInputType type) {
145 return type == InputHandler::WHEEL || type == InputHandler::ANIMATED_WHEEL;
146 }
147
144 enum ScrollThread { MAIN_THREAD, CC_THREAD }; 148 enum ScrollThread { MAIN_THREAD, CC_THREAD };
145 149
146 void RecordCompositorSlowScrollMetric(InputHandler::ScrollInputType type, 150 void RecordCompositorSlowScrollMetric(InputHandler::ScrollInputType type,
147 ScrollThread scroll_thread) { 151 ScrollThread scroll_thread) {
148 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); 152 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD);
149 if (type == InputHandler::WHEEL || type == InputHandler::ANIMATED_WHEEL) { 153 if (IsWheelBasedScroll(type)) {
150 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", 154 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread",
151 scroll_on_main_thread); 155 scroll_on_main_thread);
152 } else { 156 } else {
153 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", 157 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread",
154 scroll_on_main_thread); 158 scroll_on_main_thread);
155 } 159 }
156 } 160 }
157 161
158 } // namespace 162 } // namespace
159 163
(...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { 2474 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) {
2471 TRACE_EVENT0("cc", 2475 TRACE_EVENT0("cc",
2472 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); 2476 "LayerImpl::tryScroll: Failed NonFastScrollableRegion");
2473 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; 2477 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD;
2474 scroll_status.main_thread_scrolling_reasons = 2478 scroll_status.main_thread_scrolling_reasons =
2475 MainThreadScrollingReason::kNonFastScrollableRegion; 2479 MainThreadScrollingReason::kNonFastScrollableRegion;
2476 return scroll_status; 2480 return scroll_status;
2477 } 2481 }
2478 } 2482 }
2479 2483
2480 if (type == InputHandler::WHEEL || type == InputHandler::ANIMATED_WHEEL) { 2484 if (IsWheelBasedScroll(type) &&
2485 !active_tree()->settings().use_mouse_wheel_gestures) {
2481 EventListenerProperties event_properties = 2486 EventListenerProperties event_properties =
2482 active_tree()->event_listener_properties( 2487 active_tree()->event_listener_properties(
2483 EventListenerClass::kMouseWheel); 2488 EventListenerClass::kMouseWheel);
2484 if (event_properties == EventListenerProperties::kBlocking || 2489 if (event_properties != EventListenerProperties::kNone) {
2485 event_properties == EventListenerProperties::kBlockingAndPassive ||
2486 (!active_tree()->settings().use_mouse_wheel_gestures &&
2487 event_properties == EventListenerProperties::kPassive)) {
2488 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers"); 2490 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers");
2489 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; 2491 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD;
2490 scroll_status.main_thread_scrolling_reasons = 2492 scroll_status.main_thread_scrolling_reasons =
2491 MainThreadScrollingReason::kEventHandlers; 2493 MainThreadScrollingReason::kEventHandlers;
2492 return scroll_status; 2494 return scroll_status;
2493 } 2495 }
2494 } 2496 }
2495 2497
2496 if (!scroll_node->data.scrollable) { 2498 if (!scroll_node->data.scrollable) {
2497 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); 2499 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable");
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 return scroll_status; 2617 return scroll_status;
2616 } 2618 }
2617 scroll_status.thread = SCROLL_ON_IMPL_THREAD; 2619 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
2618 ScrollAnimationAbort(scrolling_layer_impl); 2620 ScrollAnimationAbort(scrolling_layer_impl);
2619 2621
2620 top_controls_manager_->ScrollBegin(); 2622 top_controls_manager_->ScrollBegin();
2621 2623
2622 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); 2624 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl);
2623 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation 2625 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation
2624 // in input_handler_proxy instead. 2626 // in input_handler_proxy instead.
2625 wheel_scrolling_ = (type == WHEEL || type == ANIMATED_WHEEL); 2627 wheel_scrolling_ = IsWheelBasedScroll(type);
2626 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); 2628 scroll_state->set_is_direct_manipulation(!wheel_scrolling_);
2627 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure 2629 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure
2628 // scroll customization callbacks are invoked. 2630 // scroll customization callbacks are invoked.
2629 DistributeScrollDelta(scroll_state); 2631 DistributeScrollDelta(scroll_state);
2630 2632
2631 client_->RenewTreePriority(); 2633 client_->RenewTreePriority();
2632 RecordCompositorSlowScrollMetric(type, CC_THREAD); 2634 RecordCompositorSlowScrollMetric(type, CC_THREAD);
2633 2635
2634 return scroll_status; 2636 return scroll_status;
2635 } 2637 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 if (scroll_on_main_thread) { 2689 if (scroll_on_main_thread) {
2688 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); 2690 RecordCompositorSlowScrollMetric(type, MAIN_THREAD);
2689 2691
2690 scroll_status.thread = SCROLL_ON_MAIN_THREAD; 2692 scroll_status.thread = SCROLL_ON_MAIN_THREAD;
2691 return scroll_status; 2693 return scroll_status;
2692 } 2694 }
2693 2695
2694 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type); 2696 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type);
2695 } 2697 }
2696 2698
2699 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin(
2700 const gfx::Point& viewport_point) {
2701 InputHandler::ScrollStatus scroll_status;
2702 scroll_status.main_thread_scrolling_reasons =
2703 MainThreadScrollingReason::kNotScrollingOnMain;
2704 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2705 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
2706 if (scroll_node) {
2707 gfx::Vector2dF delta;
2708
2709 if (ScrollAnimationUpdateTarget(scroll_node, delta)) {
2710 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
2711 } else {
2712 scroll_status.thread = SCROLL_IGNORED;
2713 scroll_status.main_thread_scrolling_reasons =
2714 MainThreadScrollingReason::kNotScrollable;
2715 }
2716 return scroll_status;
2717 }
2718 ScrollStateData scroll_state_data;
2719 scroll_state_data.start_position_x = viewport_point.x();
2720 scroll_state_data.start_position_y = viewport_point.y();
2721 scroll_state_data.is_in_inertial_phase = true;
2722 ScrollState scroll_state(scroll_state_data);
2723
2724 // ScrollAnimated is used for animated wheel scrolls. We find the first layer
2725 // that can scroll and set up an animation of its scroll offset. Note that
2726 // this does not currently go through the scroll customization and viewport
2727 // machinery that ScrollBy uses for non-animated wheel scrolls.
2728 scroll_status = ScrollBegin(&scroll_state, ANIMATED_WHEEL);
2729 scroll_node = scroll_tree.CurrentlyScrollingNode();
2730 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) {
2731 ScrollStateData scroll_state_end_data;
2732 scroll_state_end_data.is_ending = true;
2733 ScrollState scroll_state_end(scroll_state_end_data);
2734 ScrollEnd(&scroll_state_end);
2735 }
2736 return scroll_status;
2737 }
2738
2697 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( 2739 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
2698 const gfx::Point& viewport_point, 2740 const gfx::Point& viewport_point,
2699 const gfx::Vector2dF& scroll_delta) { 2741 const gfx::Vector2dF& scroll_delta) {
2700 InputHandler::ScrollStatus scroll_status; 2742 InputHandler::ScrollStatus scroll_status;
2701 scroll_status.main_thread_scrolling_reasons = 2743 scroll_status.main_thread_scrolling_reasons =
2702 MainThreadScrollingReason::kNotScrollingOnMain; 2744 MainThreadScrollingReason::kNotScrollingOnMain;
2703 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 2745 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2704 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 2746 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
2705 if (scroll_node) { 2747 if (scroll_node) {
2706 gfx::Vector2dF delta = scroll_delta; 2748 gfx::Vector2dF delta = scroll_delta;
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3963 return task_runner_provider_->HasImplThread(); 4005 return task_runner_provider_->HasImplThread();
3964 } 4006 }
3965 4007
3966 bool LayerTreeHostImpl::CommitToActiveTree() const { 4008 bool LayerTreeHostImpl::CommitToActiveTree() const {
3967 // In single threaded mode we skip the pending tree and commit directly to the 4009 // In single threaded mode we skip the pending tree and commit directly to the
3968 // active tree. 4010 // active tree.
3969 return !task_runner_provider_->HasImplThread(); 4011 return !task_runner_provider_->HasImplThread();
3970 } 4012 }
3971 4013
3972 } // namespace cc 4014 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | content/browser/renderer_host/input/composited_scrolling_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698