diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-03-14 19:39:54 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-03-15 19:59:47 -0700 |
commit | 2ed2462aa29c564f5231f317c27b3188da875e52 (patch) | |
tree | 63209b0ae028c1353e79d79b5e4000e7c4402ecc /include/utils/BitSet.h | |
parent | ace13b17866dc9136aeecf6dfaf7077f37434469 (diff) | |
download | frameworks_base-2ed2462aa29c564f5231f317c27b3188da875e52.zip frameworks_base-2ed2462aa29c564f5231f317c27b3188da875e52.tar.gz frameworks_base-2ed2462aa29c564f5231f317c27b3188da875e52.tar.bz2 |
Improve VelocityTracker numerical stability.
Replaced VelocityTracker with a faster and more accurate
native implementation. This avoids the duplicate maintenance
overhead of having two implementations.
The new algorithm requires that the sample duration be at least
10ms in order to contribute to the velocity calculation. This
ensures that the velocity is not severely overestimated when
samples arrive in bursts.
The new algorithm computes the exponentially weighted moving
average using weights based on the relative duration of successive
sample periods.
The new algorithm is also more careful about how it handles
individual pointers going down or up and their effects on the
collected movement traces. The intent is to preserve the last
known velocity of pointers as they go up while also ensuring
that other motion samples do not count twice in that case.
Bug: 4086785
Change-Id: I2632321232c64d6b8faacdb929e33f60e64dcdd3
Diffstat (limited to 'include/utils/BitSet.h')
-rw-r--r-- | include/utils/BitSet.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/utils/BitSet.h b/include/utils/BitSet.h index f03825a..de748b5 100644 --- a/include/utils/BitSet.h +++ b/include/utils/BitSet.h @@ -61,6 +61,10 @@ struct BitSet32 { // Result is undefined if all bits are marked. inline uint32_t firstUnmarkedBit() const { return __builtin_clz(~ value); } + // Finds the last marked bit in the set. + // Result is undefined if all bits are unmarked. + inline uint32_t lastMarkedBit() const { return 31 - __builtin_ctz(value); } + // Gets the index of the specified bit in the set, which is the number of // marked bits that appear before the specified bit. inline uint32_t getIndexOfBit(uint32_t n) const { |