Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / gesture_detection / velocity_tracker_state.h
blob780871cb80bead8aa8f9b1e3826c91ca4ef93123
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_GESTURE_DETECTION_VELOCITY_TRACKER_STATE_H_
6 #define UI_EVENTS_GESTURE_DETECTION_VELOCITY_TRACKER_STATE_H_
8 #include "base/basictypes.h"
9 #include "ui/events/gesture_detection/bitset_32.h"
10 #include "ui/events/gesture_detection/gesture_detection_export.h"
11 #include "ui/events/gesture_detection/velocity_tracker.h"
13 namespace ui {
15 class MotionEvent;
17 // Port of VelocityTrackerState from Android
18 // * platform/frameworks/base/core/jni/android_view_VelocityTracker.cpp
19 // * Change-Id: I3517881b87b47dcc209d80dbd0ac6b5cf29a766f
20 // * Please update the Change-Id as upstream Android changes are pulled.
21 class GESTURE_DETECTION_EXPORT VelocityTrackerState {
22 public:
23 VelocityTrackerState();
24 explicit VelocityTrackerState(VelocityTracker::Strategy strategy);
25 ~VelocityTrackerState();
27 void Clear();
28 void AddMovement(const MotionEvent& event);
29 void ComputeCurrentVelocity(int32_t units, float max_velocity);
30 float GetXVelocity(int32_t id) const;
31 float GetYVelocity(int32_t id) const;
33 private:
34 struct Velocity {
35 float vx, vy;
38 void GetVelocity(int32_t id, float* out_vx, float* out_vy) const;
40 VelocityTracker velocity_tracker_;
41 int32_t active_pointer_id_;
42 BitSet32 calculated_id_bits_;
43 Velocity calculated_velocity_[VelocityTracker::MAX_POINTERS];
45 DISALLOW_COPY_AND_ASSIGN(VelocityTrackerState);
48 } // namespace ui
50 #endif // UI_EVENTS_GESTURE_DETECTION_VELOCITY_TRACKER_STATE_H_