Use RingBuffer in VelocityTracker
Several strategies used to store data points in an array design to work
as a circular buffer. Now that we've the RingBuffer data structure,
migrate to using that.
Bug: 267211645
Test: atest libinput_tests
Change-Id: Id1253c646c81d3c30baea496b2e3a75f5726c616
diff --git a/include/input/VelocityTracker.h b/include/input/VelocityTracker.h
index 6d51515..6d1de64 100644
--- a/include/input/VelocityTracker.h
+++ b/include/input/VelocityTracker.h
@@ -17,6 +17,7 @@
#pragma once
#include <input/Input.h>
+#include <input/RingBuffer.h>
#include <utils/BitSet.h>
#include <utils/Timers.h>
#include <map>
@@ -172,8 +173,7 @@
// protected const field.
static constexpr uint32_t HISTORY_SIZE = 20;
- std::map<int32_t /*pointerId*/, size_t /*positionInArray*/> mIndex;
- std::map<int32_t /*pointerId*/, std::array<Movement, HISTORY_SIZE>> mMovements;
+ std::map<int32_t /*pointerId*/, RingBuffer<Movement>> mMovements;
};
/*