Commit 1256b579 authored by Axel Antoine's avatar Axel Antoine Committed by Commit Bot

Fix wrong predictor used when computing cutoff for input events

The MaxResampleTime used to compute the cutoff prediction delta is always
retrieved from the mouse_predictor_.
This CL fixes the behavior by using the right predictor stored in the
pointer_id_predictor_map when computing cutoff for touch/pointer events.

Bug: 986963
Change-Id: I36b72d0e3f8cd76fd293ff3b37ec637701271e9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715098Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Axel Antoine <axantoine@google.com>
Cr-Commit-Position: refs/heads/master@{#681478}
parent 02655b7d
...@@ -113,28 +113,51 @@ void InputEventPrediction::UpdatePrediction(const WebInputEvent& event) { ...@@ -113,28 +113,51 @@ void InputEventPrediction::UpdatePrediction(const WebInputEvent& event) {
last_event_timestamp_ = event.TimeStamp(); last_event_timestamp_ = event.TimeStamp();
} }
// When resampling, we don't want to predict too far away because the result
// will likely be inaccurate in that case. We then cut off the prediction to
// the maximum available for the current predictor
void InputEventPrediction::ApplyResampling(base::TimeTicks frame_time, void InputEventPrediction::ApplyResampling(base::TimeTicks frame_time,
WebInputEvent* event) { WebInputEvent* event) {
// When resampling, we don't want to predict too far away because the base::TimeDelta prediction_delta = frame_time - event->TimeStamp();
// result will likely be inaccurate in that case. We then cut off the base::TimeTicks predict_time;
// prediction to the maximum available for the current mouse predictor WebPointerProperties* wpp_event;
base::TimeDelta prediction_delta = std::min(
frame_time - event->TimeStamp(), mouse_predictor_->MaxResampleTime());
base::TimeTicks predict_time = event->TimeStamp() + prediction_delta;
if (event->GetType() == WebInputEvent::kTouchMove) { if (event->GetType() == WebInputEvent::kTouchMove) {
WebTouchEvent* touch_event = static_cast<WebTouchEvent*>(event); WebTouchEvent* touch_event = static_cast<WebTouchEvent*>(event);
for (unsigned i = 0; i < touch_event->touches_length; ++i) { for (unsigned i = 0; i < touch_event->touches_length; ++i) {
if (GetPointerPrediction(predict_time, &touch_event->touches[i])) wpp_event = &touch_event->touches[i];
event->SetTimeStamp(predict_time); // Cutoff prediction if delta > MaxResampleTime
auto predictor = pointer_id_predictor_map_.find(wpp_event->id);
if (predictor != pointer_id_predictor_map_.end()) {
prediction_delta =
std::min(prediction_delta, predictor->second->MaxResampleTime());
predict_time = event->TimeStamp() + prediction_delta;
// Compute the prediction
if (GetPointerPrediction(predict_time, wpp_event))
event->SetTimeStamp(predict_time);
}
} }
} else if (event->GetType() == WebInputEvent::kMouseMove) { } else if (event->GetType() == WebInputEvent::kMouseMove) {
if (GetPointerPrediction(predict_time, static_cast<WebMouseEvent*>(event))) wpp_event = static_cast<WebMouseEvent*>(event);
// Cutoff prediction if delta > MaxResampleTime
prediction_delta =
std::min(prediction_delta, mouse_predictor_->MaxResampleTime());
predict_time = event->TimeStamp() + prediction_delta;
// Compute the prediction
if (GetPointerPrediction(predict_time, wpp_event))
event->SetTimeStamp(predict_time); event->SetTimeStamp(predict_time);
} else if (event->GetType() == WebInputEvent::kPointerMove) { } else if (event->GetType() == WebInputEvent::kPointerMove) {
if (GetPointerPrediction(predict_time, wpp_event = static_cast<WebPointerEvent*>(event);
static_cast<WebPointerEvent*>(event))) // Cutoff prediction if delta > MaxResampleTime
event->SetTimeStamp(predict_time); auto predictor = pointer_id_predictor_map_.find(wpp_event->id);
if (predictor != pointer_id_predictor_map_.end()) {
prediction_delta =
std::min(prediction_delta, predictor->second->MaxResampleTime());
predict_time = event->TimeStamp() + prediction_delta;
// Compute the prediction
if (GetPointerPrediction(predict_time, wpp_event))
event->SetTimeStamp(predict_time);
}
} }
} }
......
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