summaryrefslogtreecommitdiff
path: root/include/input/Resampler.h
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-10-09 17:36:53 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-10-09 17:36:53 +0000
commitcfc6759f73e9d28f91ed6a74c93038d03afc4fcc (patch)
treed5b75481e284a2dc5b1de224d99154b378d19869 /include/input/Resampler.h
parentdce984fda4f17f62b82b5160cec6a8ac8729747d (diff)
parent4679e55027a36e63cfdc642de313cb2c46c58c54 (diff)
Merge changes I41cb79ea,I12eb8eae into main
* changes: Add logic to overwrite pointer coordinates if event time is too old Add logic to overwrite pointer coordinates in motion event
Diffstat (limited to 'include/input/Resampler.h')
-rw-r--r--include/input/Resampler.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/input/Resampler.h b/include/input/Resampler.h
index da0c5b2150..47519c2cfd 100644
--- a/include/input/Resampler.h
+++ b/include/input/Resampler.h
@@ -100,6 +100,17 @@ private:
RingBuffer<Sample> mLatestSamples{/*capacity=*/2};
/**
+ * Latest sample in mLatestSamples after resampling motion event. Used to compare if a pointer
+ * does not move between samples.
+ */
+ std::optional<Sample> mLastRealSample;
+
+ /**
+ * Latest prediction. Used to overwrite motion event samples if a set of conditions is met.
+ */
+ std::optional<Sample> mPreviousPrediction;
+
+ /**
* Adds up to mLatestSamples.capacity() of motionEvent's latest samples to mLatestSamples. If
* motionEvent has fewer samples than mLatestSamples.capacity(), then the available samples are
* added to mLatestSamples.
@@ -144,6 +155,23 @@ private:
*/
std::optional<Sample> attemptExtrapolation(std::chrono::nanoseconds resampleTime) const;
+ /**
+ * Iterates through motion event samples, and calls overwriteStillPointers on each sample.
+ */
+ void overwriteMotionEventSamples(MotionEvent& motionEvent) const;
+
+ /**
+ * Overwrites with resampled data the pointer coordinates that did not move between motion event
+ * samples, that is, both x and y values are identical to mLastRealSample.
+ */
+ void overwriteStillPointers(MotionEvent& motionEvent, size_t sampleIndex) const;
+
+ /**
+ * Overwrites the pointer coordinates of a sample with event time older than
+ * that of mPreviousPrediction.
+ */
+ void overwriteOldPointers(MotionEvent& motionEvent, size_t sampleIndex) const;
+
inline static void addSampleToMotionEvent(const Sample& sample, MotionEvent& motionEvent);
};
} // namespace android