Index: ui/aura/gestures/gesture_point.cc |
diff --git a/ui/aura/gestures/gesture_point.cc b/ui/aura/gestures/gesture_point.cc |
index 3402e56673331098a3d8e60233bda7736d52a91e..f6bb59c88bf2420351f6954f5aeb36bb77676ec1 100644 |
--- a/ui/aura/gestures/gesture_point.cc |
+++ b/ui/aura/gestures/gesture_point.cc |
@@ -16,8 +16,9 @@ const double kMinimumTouchDownDurationInSecondsForClick = 0.01; |
const double kMaximumSecondsBetweenDoubleClick = 0.7; |
const int kMaximumTouchMoveInPixelsForClick = 20; |
const float kMinFlickSpeedSquared = 550.f * 550.f; |
+const int kBufferedPoints = 10; |
-} // namespace aura |
+} // namespace |
namespace aura { |
@@ -26,7 +27,8 @@ GesturePoint::GesturePoint() |
last_touch_time_(0.0), |
last_tap_time_(0.0), |
x_velocity_(0.0), |
- y_velocity_(0.0) { |
+ y_velocity_(0.0), |
+ velocity_calculator_(kBufferedPoints) { |
} |
void GesturePoint::Reset() { |
@@ -35,18 +37,24 @@ void GesturePoint::Reset() { |
} |
void GesturePoint::UpdateValues(const TouchEvent& event, GestureState state) { |
+ const double event_timestamp_seconds = event.time_stamp().InSecondsF(); |
rjkroege
2012/02/02 15:58:37
if our compiler is doing the right thing with SSE,
|
if (state != GS_NO_GESTURE && event.type() == ui::ET_TOUCH_MOVED) { |
- double interval(event.time_stamp().InSecondsF() - last_touch_time_); |
- x_velocity_ = (event.x() - last_touch_position_.x()) / interval; |
- y_velocity_ = (event.y() - last_touch_position_.y()) / interval; |
+ velocity_calculator_.PointSeen(event.x(), |
rjkroege
2012/02/02 15:58:37
you need to move these over one char I think.
|
+ event.y(), |
+ event_timestamp_seconds); |
+ velocity_calculator_.Velocity(&x_velocity_, &y_velocity_); |
} |
- last_touch_time_ = event.time_stamp().InSecondsF(); |
+ last_touch_time_ = event_timestamp_seconds; |
last_touch_position_ = event.location(); |
if (state == GS_NO_GESTURE) { |
first_touch_time_ = last_touch_time_; |
first_touch_position_ = event.location(); |
+ velocity_calculator_.ClearHistory(); |
+ velocity_calculator_.PointSeen(event.x(), |
+ event.y(), |
+ event_timestamp_seconds); |
x_velocity_ = 0.0; |
y_velocity_ = 0.0; |
} |