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

Unified Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add an ack type for async touch move Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/touch_event_queue.cc
diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc
index b766b3d1b51530ec4b49d9685cde78ebb302b525..469745fe774c10eba5ab4ac5ec75016988d2dc6e 100644
--- a/content/browser/renderer_host/input/touch_event_queue.cc
+++ b/content/browser/renderer_host/input/touch_event_queue.cc
@@ -372,6 +372,9 @@ TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client,
drop_remaining_touches_in_sequence_(false),
touchmove_slop_suppressor_(new TouchMoveSlopSuppressor),
send_touch_events_async_(false),
+ receive_async_touch_move_ack_(false),
+ ignore_ack_(0),
+ sent_async_touch_move_count_(0),
last_sent_touch_timestamp_sec_(0) {
DCHECK(client);
if (config.touch_ack_timeout_supported) {
@@ -430,7 +433,6 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result,
return;
touchmove_slop_suppressor_->ConfirmTouchEvent(ack_result);
-
if (touch_queue_.empty())
return;
@@ -438,6 +440,23 @@ void TouchEventQueue::ProcessTouchAck(InputEventAckState ack_result,
TryForwardNextEventToRenderer();
}
+void TouchEventQueue::ProcessAsyncTouchAck() {
+ TRACE_EVENT0("input", "TouchEventQueue::ProcessAsyncTouchAck");
+
+ DCHECK(!dispatching_touch_ack_);
+ dispatching_touch_ = false;
+ --sent_async_touch_move_count_;
+ if (ignore_ack_ > 0)
+ --ignore_ack_;
+ receive_async_touch_move_ack_ = true;
+
+ if (pending_async_touchmove_) {
+ touch_queue_.push_front(
+ new CoalescedWebTouchEvent(*pending_async_touchmove_, true));
+ SendTouchEventImmediately(pending_async_touchmove_.get());
+ }
+}
+
void TouchEventQueue::TryForwardNextEventToRenderer() {
DCHECK(!dispatching_touch_ack_);
// If there are queued touch events, then try to forward them to the renderer
@@ -480,6 +499,8 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
touch.event.timeStampSeconds >=
last_sent_touch_timestamp_sec_ + kAsyncTouchMoveIntervalSec;
+ if (ignore_ack_ == 0)
+ send_touchmove_now &= receive_async_touch_move_ack_;
if (!send_touchmove_now) {
if (!pending_async_touchmove_) {
pending_async_touchmove_.reset(new TouchEventWithLatencyInfo(touch));
@@ -496,6 +517,7 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
TryForwardNextEventToRenderer();
return;
}
+ receive_async_touch_move_ack_ = false;
}
last_sent_touch_timestamp_sec_ = touch.event.timeStampSeconds;
@@ -509,7 +531,12 @@ void TouchEventQueue::ForwardNextEventToRenderer() {
pending_async_touchmove_->event.cancelable = !send_touch_events_async_;
touch = *pending_async_touchmove_;
pending_async_touchmove_.reset();
+ if (!touch.event.cancelable)
+ ++sent_async_touch_move_count_;
} else {
+ // Once we flish the pending async touch move, we ignore all the acks
tdresser 2015/03/23 19:21:44 flish -> flush
lanwei 2015/03/24 18:46:38 Done.
+ // from the aysnc touch moves that we sent out and wait for acks back.
tdresser 2015/03/23 19:21:44 Fix aysnc spelling.
lanwei 2015/03/24 18:46:38 Done.
+ ignore_ack_ = ++sent_async_touch_move_count_;
tdresser 2015/03/23 19:21:44 Split into two statements.
lanwei 2015/03/24 18:46:38 Done.
scoped_ptr<TouchEventWithLatencyInfo> async_move =
pending_async_touchmove_.Pass();
async_move->event.cancelable = false;

Powered by Google App Engine
This is Rietveld 408576698