summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew de los Reyes <adlr@google.com>2015-10-01 15:57:25 -0700
committerAndrew de los Reyes <adlr@google.com>2015-10-01 15:57:25 -0700
commitde18f6c32add6fb22065807a00ddc88b363df527 (patch)
treea0f877958b8be34fe0ac5d0e3329f5a898d2c83c
parentb0127aadafbf3b314475e48772fdcc17939c5a9c (diff)
downloadnative-marshmallow-dr-dev.tar.gz
InputResampling: Don't extrapolate for very low frame rates.marshmallow-dr-dev
In very low framerate situations, extrapolation is generally going to either cause no benefit or make a mistake. We can safely turn it off with no user-visible negative impact. BUG=https://buganizer.corp.google.com/u/0/issues/24550942 TEST=Scrolled very slowly and saw mispredictions on Angler. With change, saw the log message that the mispredictions were suppressed. Change-Id: Ic9747d3ff098d7918047ada2ed1c2d21282c65b0
-rw-r--r--libs/input/InputTransport.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 0382f5788f..7f83da523f 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -51,6 +51,10 @@ static const nsecs_t RESAMPLE_LATENCY = 5 * NANOS_PER_MS;
// Minimum time difference between consecutive samples before attempting to resample.
static const nsecs_t RESAMPLE_MIN_DELTA = 2 * NANOS_PER_MS;
+// Maximum time difference between consecutive samples before attempting to resample
+// by extrapolation.
+static const nsecs_t RESAMPLE_MAX_DELTA = 20 * NANOS_PER_MS;
+
// Maximum time to predict forward from the last known state, to avoid predicting too
// far into the future. This time is further bounded by 50% of the last time delta.
static const nsecs_t RESAMPLE_MAX_PREDICTION = 8 * NANOS_PER_MS;
@@ -724,7 +728,7 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
nsecs_t delta = future.eventTime - current->eventTime;
if (delta < RESAMPLE_MIN_DELTA) {
#if DEBUG_RESAMPLING
- ALOGD("Not resampled, delta time is %lld ns.", delta);
+ ALOGD("Not resampled, delta time is too small: %lld ns.", delta);
#endif
return;
}
@@ -736,7 +740,12 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
nsecs_t delta = current->eventTime - other->eventTime;
if (delta < RESAMPLE_MIN_DELTA) {
#if DEBUG_RESAMPLING
- ALOGD("Not resampled, delta time is %lld ns.", delta);
+ ALOGD("Not resampled, delta time is too small: %lld ns.", delta);
+#endif
+ return;
+ } else if (delta > RESAMPLE_MAX_DELTA) {
+#if DEBUG_RESAMPLING
+ ALOGD("Not resampled, delta time is too large: %lld ns.", delta);
#endif
return;
}