OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_VELOCITY_TRACKER_STATE_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_VELOCITY_TRACKER_STATE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "content/browser/renderer_host/input/gestures/bitset_32.h" |
| 10 #include "content/browser/renderer_host/input/gestures/velocity_tracker.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 class MotionEvent; |
| 15 |
| 16 // Port of VelocityTrackerState from Android |
| 17 // * platform/frameworks/base/core/jni/android_view_VelocityTracker.cpp |
| 18 // * Change-Id: I3517881b87b47dcc209d80dbd0ac6b5cf29a766f |
| 19 // * Changes to this class should be cosmetic only, easing fork maintenance. |
| 20 class VelocityTrackerState { |
| 21 public: |
| 22 VelocityTrackerState(); |
| 23 |
| 24 void Clear(); |
| 25 void AddMovement(const MotionEvent& event); |
| 26 void ComputeCurrentVelocity(int32_t units, float max_velocity); |
| 27 float GetXVelocity(int32_t id) const; |
| 28 float GetYVelocity(int32_t id) const; |
| 29 |
| 30 private: |
| 31 struct Velocity { |
| 32 float vx, vy; |
| 33 }; |
| 34 |
| 35 void GetVelocity(int32_t id, float* out_vx, float* out_vy) const; |
| 36 |
| 37 VelocityTracker velocity_tracker_; |
| 38 int32_t active_pointer_id_; |
| 39 BitSet32 calculated_id_bits_; |
| 40 Velocity calculated_velocity_[VelocityTracker::MAX_POINTERS]; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(VelocityTrackerState); |
| 43 }; |
| 44 |
| 45 } // namespace content |
| 46 |
| 47 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_VELOCITY_TRACKER_STATE_H_ |
OLD | NEW |