OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ | |
6 #define UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ | |
7 #pragma once | |
8 | |
9 #include <vector> | |
10 #include "ui/aura/aura_export.h" | |
11 #include "base/basictypes.h" | |
12 | |
13 namespace aura { | |
14 | |
15 class AURA_EXPORT VelocityCalculator { | |
rjkroege
2012/02/02 20:24:17
Am not convinced that you need this. This class is
| |
16 public: | |
17 explicit VelocityCalculator(int bufferSize); | |
18 ~VelocityCalculator(); | |
19 void PointSeen(int x, int y, int64 time); | |
20 float x_velocity() const { return x_velocity_; } | |
21 float y_velocity() const { return y_velocity_; } | |
22 float VelocitySquared() const; | |
23 void ClearHistory(); | |
24 | |
25 private: | |
26 struct Point { | |
27 int x; | |
28 int y; | |
29 int64 time; | |
30 }; | |
31 | |
32 void UpdateVelocity(); | |
33 | |
34 typedef Point* HistoryBuffer; | |
35 HistoryBuffer buffer_; | |
36 | |
37 // index_ points directly after the last point added | |
38 int index_; | |
39 size_t num_valid_entries_; | |
40 const size_t buffer_size_; | |
41 float x_velocity_; | |
42 float y_velocity_; | |
43 }; | |
44 } // namespace aura | |
45 | |
46 #endif // UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ | |
OLD | NEW |