summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-06-01 12:39:25 -0700
committerJeff Brown <jeffbrown@google.com>2012-06-03 19:21:49 -0700
commit9eb7d86181729c3eb769d71123c4ce9ffc868f08 (patch)
tree5844b6bfd4c9eac8bc5015fa54f5255a376805c8 /include
parent6e8e41a336dfc0c43b672fd105a23aa48c93ec67 (diff)
downloadframeworks_base-9eb7d86181729c3eb769d71123c4ce9ffc868f08.zip
frameworks_base-9eb7d86181729c3eb769d71123c4ce9ffc868f08.tar.gz
frameworks_base-9eb7d86181729c3eb769d71123c4ce9ffc868f08.tar.bz2
Make velocity tracker strategy configurable.
This change is very useful for testing purposes because it makes it easy to compare different implementations to see how they behave. There is no change to the current default strategy. Bug: 6413587 Change-Id: I4d8567aa4160571ba9fa397ce419882cd9366749
Diffstat (limited to 'include')
-rw-r--r--include/androidfw/VelocityTracker.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/include/androidfw/VelocityTracker.h b/include/androidfw/VelocityTracker.h
index cbb0782..1d44f13 100644
--- a/include/androidfw/VelocityTracker.h
+++ b/include/androidfw/VelocityTracker.h
@@ -35,7 +35,7 @@ public:
};
struct Estimator {
- static const size_t MAX_DEGREE = 2;
+ static const size_t MAX_DEGREE = 4;
// Estimator time base.
nsecs_t time;
@@ -61,7 +61,10 @@ public:
}
};
- VelocityTracker();
+ // Creates a velocity tracker using the specified strategy.
+ // If strategy is NULL, uses the default strategy for the platform.
+ VelocityTracker(const char* strategy = NULL);
+
~VelocityTracker();
// Resets the velocity tracker state.
@@ -99,10 +102,16 @@ public:
inline BitSet32 getCurrentPointerIdBits() const { return mCurrentPointerIdBits; }
private:
+ static const char* DEFAULT_STRATEGY;
+
nsecs_t mLastEventTime;
BitSet32 mCurrentPointerIdBits;
int32_t mActivePointerId;
VelocityTrackerStrategy* mStrategy;
+
+ bool configureStrategy(const char* strategy);
+
+ static VelocityTrackerStrategy* createStrategy(const char* strategy);
};
@@ -129,7 +138,8 @@ public:
*/
class LeastSquaresVelocityTrackerStrategy : public VelocityTrackerStrategy {
public:
- LeastSquaresVelocityTrackerStrategy();
+ // Degree must be no greater than Estimator::MAX_DEGREE.
+ LeastSquaresVelocityTrackerStrategy(uint32_t degree);
virtual ~LeastSquaresVelocityTrackerStrategy();
virtual void clear();
@@ -139,9 +149,6 @@ public:
virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const;
private:
- // Polynomial degree. Must be less than or equal to Estimator::MAX_DEGREE.
- static const uint32_t DEGREE = 2;
-
// Sample horizon.
// We don't use too much history by default since we want to react to quick
// changes in direction.
@@ -160,6 +167,7 @@ private:
}
};
+ const uint32_t mDegree;
uint32_t mIndex;
Movement mMovements[HISTORY_SIZE];
};