diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-06-03 23:14:14 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-06-04 12:34:03 -0700 |
commit | 51df04b93e8e362edd867abd7efaf1659b8b8b82 (patch) | |
tree | 5c416d400d53da96891465fd5b602e063925622b /include | |
parent | a5b0698231459ac5b54cf8e8952ac5c2b2b2198b (diff) | |
download | frameworks_base-51df04b93e8e362edd867abd7efaf1659b8b8b82.zip frameworks_base-51df04b93e8e362edd867abd7efaf1659b8b8b82.tar.gz frameworks_base-51df04b93e8e362edd867abd7efaf1659b8b8b82.tar.bz2 |
Port the legacy velocity tracker strategy.
For comparison purposes, port the legacy velocity tracker
algorithm as it behaved prior to ICS.
Bug: 6413587
Change-Id: I7e8e56584dcdb1a3c660ca9d8f9c5bd5d868e449
Diffstat (limited to 'include')
-rw-r--r-- | include/androidfw/VelocityTracker.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/androidfw/VelocityTracker.h b/include/androidfw/VelocityTracker.h index 3e6436a..8c24219 100644 --- a/include/androidfw/VelocityTracker.h +++ b/include/androidfw/VelocityTracker.h @@ -225,6 +225,45 @@ private: void populateEstimator(const State& state, VelocityTracker::Estimator* outEstimator) const; }; + +/* + * Velocity tracker strategy used prior to ICS. + */ +class LegacyVelocityTrackerStrategy : public VelocityTrackerStrategy { +public: + LegacyVelocityTrackerStrategy(); + virtual ~LegacyVelocityTrackerStrategy(); + + virtual void clear(); + virtual void clearPointers(BitSet32 idBits); + virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, + const VelocityTracker::Position* positions); + virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; + +private: + // Oldest sample to consider when calculating the velocity. + static const nsecs_t HORIZON = 200 * 1000000; // 100 ms + + // Number of samples to keep. + static const uint32_t HISTORY_SIZE = 20; + + // The minimum duration between samples when estimating velocity. + static const nsecs_t MIN_DURATION = 10 * 1000000; // 10 ms + + struct Movement { + nsecs_t eventTime; + BitSet32 idBits; + VelocityTracker::Position positions[MAX_POINTERS]; + + inline const VelocityTracker::Position& getPosition(uint32_t id) const { + return positions[idBits.getIndexOfBit(id)]; + } + }; + + uint32_t mIndex; + Movement mMovements[HISTORY_SIZE]; +}; + } // namespace android #endif // _ANDROIDFW_VELOCITY_TRACKER_H |