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 { | |
sadrul
2012/02/02 22:04:06
Avoid AURA_EXPORT here. GesturePoint isn't exporte
tdresser
2012/02/02 22:25:42
AURA_EXPORT is necessary for the unit tests to run
sadrul
2012/02/02 22:31:10
Aah, OK. Makes sense.
| |
16 public: | |
17 explicit VelocityCalculator(int bufferSize); | |
18 ~VelocityCalculator(); | |
19 void PointSeen(int x, int y, int64 time); | |
20 float XVelocity(); | |
21 float YVelocity(); | |
22 float VelocitySquared(); | |
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_; | |
sadrul
2012/02/02 22:04:06
Use a scoped_ptr here so you don't have to explici
| |
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 bool velocities_stale_; | |
sadrul
2012/02/02 22:04:06
DISALLOW_COPY_AND_ASSIGN(VelocityCalculator);
| |
44 }; | |
45 } // namespace aura | |
sadrul
2012/02/02 22:04:06
newline after line-44
| |
46 | |
47 #endif // UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ | |
OLD | NEW |