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

Side by Side Diff: ui/events/blink/input_handler_proxy.cc

Issue 2040543002: Take MT jank into account when animating the scroll offset on CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 ReportInputEventLatencyUma(event, *latency_info); 269 ReportInputEventLatencyUma(event, *latency_info);
270 270
271 TRACE_EVENT_WITH_FLOW1("input,benchmark", 271 TRACE_EVENT_WITH_FLOW1("input,benchmark",
272 "LatencyInfo.Flow", 272 "LatencyInfo.Flow",
273 TRACE_ID_DONT_MANGLE(latency_info->trace_id()), 273 TRACE_ID_DONT_MANGLE(latency_info->trace_id()),
274 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, 274 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
275 "step", "HandleInputEventImpl"); 275 "step", "HandleInputEventImpl");
276 276
277 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = 277 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor =
278 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); 278 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info);
279 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); 279 InputHandlerProxy::EventDisposition disposition =
280 HandleInputEvent(event, latency_info);
280 return disposition; 281 return disposition;
281 } 282 }
282 283
283 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( 284 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent(
284 const WebInputEvent& event) { 285 const WebInputEvent& event, ui::LatencyInfo* latency_info) {
285 DCHECK(input_handler_); 286 DCHECK(input_handler_);
286 287
287 if (FilterInputEventForFlingBoosting(event)) 288 if (FilterInputEventForFlingBoosting(event))
288 return DID_HANDLE; 289 return DID_HANDLE;
289 290
290 switch (event.type) { 291 switch (event.type) {
291 case WebInputEvent::MouseWheel: 292 case WebInputEvent::MouseWheel:
292 return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event)); 293 return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event));
293 294
294 case WebInputEvent::GestureScrollBegin: 295 case WebInputEvent::GestureScrollBegin:
295 return HandleGestureScrollBegin( 296 return HandleGestureScrollBegin(
296 static_cast<const WebGestureEvent&>(event)); 297 static_cast<const WebGestureEvent&>(event));
297 298
298 case WebInputEvent::GestureScrollUpdate: 299 case WebInputEvent::GestureScrollUpdate:
299 return HandleGestureScrollUpdate( 300 return HandleGestureScrollUpdate(
300 static_cast<const WebGestureEvent&>(event)); 301 static_cast<const WebGestureEvent&>(event), latency_info);
301 302
302 case WebInputEvent::GestureScrollEnd: 303 case WebInputEvent::GestureScrollEnd:
303 return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event)); 304 return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event));
304 305
305 case WebInputEvent::GesturePinchBegin: { 306 case WebInputEvent::GesturePinchBegin: {
306 DCHECK(!gesture_pinch_on_impl_thread_); 307 DCHECK(!gesture_pinch_on_impl_thread_);
307 const WebGestureEvent& gesture_event = 308 const WebGestureEvent& gesture_event =
308 static_cast<const WebGestureEvent&>(event); 309 static_cast<const WebGestureEvent&>(event);
309 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && 310 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad &&
310 input_handler_->GetEventListenerProperties( 311 input_handler_->GetEventListenerProperties(
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 641 }
641 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) 642 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE)
642 HandleScrollElasticityOverscroll(gesture_event, 643 HandleScrollElasticityOverscroll(gesture_event,
643 cc::InputHandlerScrollResult()); 644 cc::InputHandlerScrollResult());
644 645
645 return result; 646 return result;
646 } 647 }
647 648
648 InputHandlerProxy::EventDisposition 649 InputHandlerProxy::EventDisposition
649 InputHandlerProxy::HandleGestureScrollUpdate( 650 InputHandlerProxy::HandleGestureScrollUpdate(
650 const WebGestureEvent& gesture_event) { 651 const WebGestureEvent& gesture_event, ui::LatencyInfo* latency_info) {
651 #ifndef NDEBUG 652 #ifndef NDEBUG
652 DCHECK(expect_scroll_update_end_); 653 DCHECK(expect_scroll_update_end_);
653 #endif 654 #endif
654 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) 655 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_)
655 return DID_NOT_HANDLE; 656 return DID_NOT_HANDLE;
656 657
657 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); 658 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event);
658 gfx::Point scroll_point(gesture_event.x, gesture_event.y); 659 gfx::Point scroll_point(gesture_event.x, gesture_event.y);
659 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, 660 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX,
660 -gesture_event.data.scrollUpdate.deltaY); 661 -gesture_event.data.scrollUpdate.deltaY);
661 662
662 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits != 663 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits !=
663 blink::WebGestureEvent::ScrollUnits::Pixels)) { 664 blink::WebGestureEvent::ScrollUnits::Pixels)) {
664 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta).thread) { 665 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta).thread) {
665 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: 666 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: {
667 for (const auto& lc : latency_info->latency_components()) {
668 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) {
669 LatencyInfo::LatencyComponent o_component;
670 if (latency_info->FindLatency(
671 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, &o_component)) {
672 input_handler_->AdjustDuration(
673 lc.second.event_time - o_component.event_time);
skobes 2016/06/08 22:47:28 I don't really understand what this is doing, is i
674 }
675 break;
676 }
677 }
666 return DID_HANDLE; 678 return DID_HANDLE;
679 }
667 case cc::InputHandler::SCROLL_IGNORED: 680 case cc::InputHandler::SCROLL_IGNORED:
668 return DROP_EVENT; 681 return DROP_EVENT;
669 default: 682 default:
670 return DID_NOT_HANDLE; 683 return DID_NOT_HANDLE;
671 } 684 }
672 } 685 }
673 cc::InputHandlerScrollResult scroll_result = 686 cc::InputHandlerScrollResult scroll_result =
674 input_handler_->ScrollBy(&scroll_state); 687 input_handler_->ScrollBy(&scroll_state);
675 HandleOverscroll(scroll_point, scroll_result); 688 HandleOverscroll(scroll_point, scroll_result);
676 689
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 // is made asynchronously, to minimize divergence between main thread and 1376 // is made asynchronously, to minimize divergence between main thread and
1364 // impl thread event handling paths. 1377 // impl thread event handling paths.
1365 base::ThreadTaskRunnerHandle::Get()->PostTask( 1378 base::ThreadTaskRunnerHandle::Get()->PostTask(
1366 FROM_HERE, 1379 FROM_HERE,
1367 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, 1380 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult,
1368 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, 1381 scroll_elasticity_controller_->GetWeakPtr(), gesture_event,
1369 scroll_result)); 1382 scroll_result));
1370 } 1383 }
1371 1384
1372 } // namespace ui 1385 } // namespace ui
OLDNEW
« cc/input/input_handler.h ('K') | « ui/events/blink/input_handler_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698