Index: ui/aura/gestures/velocity_calculator.h |
diff --git a/ui/aura/gestures/velocity_calculator.h b/ui/aura/gestures/velocity_calculator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a6f57a35dc4d82cf3ccef7e96e39f0910846fded |
--- /dev/null |
+++ b/ui/aura/gestures/velocity_calculator.h |
@@ -0,0 +1,47 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ |
+#define UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ |
+#pragma once |
+ |
+#include <vector> |
+#include "ui/aura/aura_export.h" |
+#include "base/basictypes.h" |
+ |
+namespace aura { |
+ |
+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.
|
+ public: |
+ explicit VelocityCalculator(int bufferSize); |
+ ~VelocityCalculator(); |
+ void PointSeen(int x, int y, int64 time); |
+ float XVelocity(); |
+ float YVelocity(); |
+ float VelocitySquared(); |
+ void ClearHistory(); |
+ |
+ private: |
+ struct Point { |
+ int x; |
+ int y; |
+ int64 time; |
+ }; |
+ |
+ void UpdateVelocity(); |
+ |
+ typedef Point* HistoryBuffer; |
+ HistoryBuffer buffer_; |
sadrul
2012/02/02 22:04:06
Use a scoped_ptr here so you don't have to explici
|
+ |
+ // index_ points directly after the last point added |
+ int index_; |
+ size_t num_valid_entries_; |
+ const size_t buffer_size_; |
+ float x_velocity_; |
+ float y_velocity_; |
+ bool velocities_stale_; |
sadrul
2012/02/02 22:04:06
DISALLOW_COPY_AND_ASSIGN(VelocityCalculator);
|
+}; |
+} // namespace aura |
sadrul
2012/02/02 22:04:06
newline after line-44
|
+ |
+#endif // UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ |