Commit 4f0ec3cf authored by jdduke's avatar jdduke Committed by Commit bot

[Android] Always request BeginFrame when touch received

Android's vsync listener will now only dispatch a BeginFrame message if
such was requested. This exposed a hole in our BeginFrame request
pipeline, where short-circuited touch forwarding would bypass the vsync
request. Instead, always request the BeginFrame if a touch event was
received from the platform, potentially reducing the first frame's
latency when the page lacks a touch handler.
latency.

BUG=408377

Review URL: https://codereview.chromium.org/535453002

Cr-Commit-Position: refs/heads/master@{#292992}
parent 2a70090f
......@@ -683,14 +683,21 @@ bool RenderWidgetHostViewAndroid::OnTouchEvent(
return true;
}
// Short-circuit touch forwarding if no touch handlers exist.
if (!host_->ShouldForwardTouchEvent()) {
if (host_->ShouldForwardTouchEvent()) {
blink::WebTouchEvent web_event = CreateWebTouchEventFromMotionEvent(event);
host_->ForwardTouchEventWithLatencyInfo(web_event,
CreateLatencyInfo(web_event));
} else {
const bool event_consumed = false;
gesture_provider_.OnTouchEventAck(event_consumed);
return true;
}
SendTouchEvent(CreateWebTouchEventFromMotionEvent(event));
// Send a proactive BeginFrame on the next vsync to reduce latency.
// This is good enough as long as the first touch event has Begin semantics
// and the actual scroll happens on the next vsync.
if (observing_root_window_)
RequestVSyncUpdate(BEGIN_FRAME);
return true;
}
......@@ -1508,19 +1515,6 @@ void RenderWidgetHostViewAndroid::SendKeyEvent(
host_->ForwardKeyboardEvent(event);
}
void RenderWidgetHostViewAndroid::SendTouchEvent(
const blink::WebTouchEvent& event) {
if (host_)
host_->ForwardTouchEventWithLatencyInfo(event, CreateLatencyInfo(event));
// Send a proactive BeginFrame on the next vsync to reduce latency.
// This is good enough as long as the first touch event has Begin semantics
// and the actual scroll happens on the next vsync.
// TODO: Is this actually still needed?
if (observing_root_window_)
RequestVSyncUpdate(BEGIN_FRAME);
}
void RenderWidgetHostViewAndroid::SendMouseEvent(
const blink::WebMouseEvent& event) {
if (host_)
......
......@@ -224,7 +224,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void SetContentViewCore(ContentViewCoreImpl* content_view_core);
SkColor GetCachedBackgroundColor() const;
void SendKeyEvent(const NativeWebKeyboardEvent& event);
void SendTouchEvent(const blink::WebTouchEvent& event);
void SendMouseEvent(const blink::WebMouseEvent& event);
void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event);
void SendGestureEvent(const blink::WebGestureEvent& event);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment