Change calculateResampledCoords to preserve PointerCoords data
Changed the logic of calculateResampledCoords to not dispose information
of PointerCoords.
Bug: 297226446
Flag: EXEMPT bugfix
Test: TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="ResamplerTest*"
Change-Id: I81285a65ebb571d11ba35bd18072b5ce18763d2d
diff --git a/libs/input/Resampler.cpp b/libs/input/Resampler.cpp
index af8354c..836a97a 100644
--- a/libs/input/Resampler.cpp
+++ b/libs/input/Resampler.cpp
@@ -62,8 +62,8 @@
const PointerCoords calculateResampledCoords(const PointerCoords& a, const PointerCoords& b,
const float alpha) {
- // Ensure the struct PointerCoords is initialized.
- PointerCoords resampledCoords{};
+ // We use the value of alpha to initialize resampledCoords with the latest sample information.
+ PointerCoords resampledCoords = (alpha < 1.0f) ? a : b;
resampledCoords.isResampled = true;
resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_X, lerp(a.getX(), b.getX(), alpha));
resampledCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, lerp(a.getY(), b.getY(), alpha));