OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/events/gesture_detection/velocity_tracker.h" | 5 #include "ui/events/gesture_detection/velocity_tracker.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/events/gesture_detection/motion_event.h" | 10 #include "ui/events/gesture_detection/motion_event.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 BitSet32 id_bits, | 25 BitSet32 id_bits, |
26 const Position* positions) = 0; | 26 const Position* positions) = 0; |
27 virtual bool GetEstimator(uint32_t id, Estimator* out_estimator) const = 0; | 27 virtual bool GetEstimator(uint32_t id, Estimator* out_estimator) const = 0; |
28 | 28 |
29 protected: | 29 protected: |
30 VelocityTrackerStrategy() {} | 30 VelocityTrackerStrategy() {} |
31 }; | 31 }; |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 COMPILE_ASSERT(MotionEvent::MAX_POINTER_ID < 32, max_pointer_id_too_large); | 35 static_assert(MotionEvent::MAX_POINTER_ID < 32, "max pointer id too large"); |
36 | 36 |
37 // Threshold between ACTION_MOVE events for determining that a pointer has | 37 // Threshold between ACTION_MOVE events for determining that a pointer has |
38 // stopped moving. Some input devices do not send ACTION_MOVE events in the case | 38 // stopped moving. Some input devices do not send ACTION_MOVE events in the case |
39 // where a pointer has stopped. We need to detect this case so that we can | 39 // where a pointer has stopped. We need to detect this case so that we can |
40 // accurately predict the velocity after the pointer starts moving again. | 40 // accurately predict the velocity after the pointer starts moving again. |
41 const int kAssumePointerMoveStoppedTimeMs = 40; | 41 const int kAssumePointerMoveStoppedTimeMs = 40; |
42 | 42 |
43 // Threshold between ACTION_MOVE and ACTION_{UP|POINTER_UP} events for | 43 // Threshold between ACTION_MOVE and ACTION_{UP|POINTER_UP} events for |
44 // determining that a pointer has stopped moving. This is a larger threshold | 44 // determining that a pointer has stopped moving. This is a larger threshold |
45 // than |kAssumePointerMoveStoppedTimeMs|, as some devices may delay synthesis | 45 // than |kAssumePointerMoveStoppedTimeMs|, as some devices may delay synthesis |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 out_estimator->degree = state.degree; | 845 out_estimator->degree = state.degree; |
846 out_estimator->xcoeff[0] = state.xpos; | 846 out_estimator->xcoeff[0] = state.xpos; |
847 out_estimator->xcoeff[1] = state.xvel; | 847 out_estimator->xcoeff[1] = state.xvel; |
848 out_estimator->xcoeff[2] = state.xaccel / 2; | 848 out_estimator->xcoeff[2] = state.xaccel / 2; |
849 out_estimator->ycoeff[0] = state.ypos; | 849 out_estimator->ycoeff[0] = state.ypos; |
850 out_estimator->ycoeff[1] = state.yvel; | 850 out_estimator->ycoeff[1] = state.yvel; |
851 out_estimator->ycoeff[2] = state.yaccel / 2; | 851 out_estimator->ycoeff[2] = state.yaccel / 2; |
852 } | 852 } |
853 | 853 |
854 } // namespace ui | 854 } // namespace ui |
OLD | NEW |