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 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/aura/aura_export.h" |
| 14 |
| 15 namespace aura { |
| 16 |
| 17 class AURA_EXPORT VelocityCalculator { |
| 18 public: |
| 19 explicit VelocityCalculator(int bufferSize); |
| 20 ~VelocityCalculator(); |
| 21 void PointSeen(int x, int y, int64 time); |
| 22 float XVelocity(); |
| 23 float YVelocity(); |
| 24 float VelocitySquared(); |
| 25 void ClearHistory(); |
| 26 |
| 27 private: |
| 28 struct Point { |
| 29 int x; |
| 30 int y; |
| 31 int64 time; |
| 32 }; |
| 33 |
| 34 void UpdateVelocity(); |
| 35 |
| 36 typedef scoped_array<Point> HistoryBuffer; |
| 37 HistoryBuffer buffer_; |
| 38 |
| 39 // index_ points directly after the last point added. |
| 40 int index_; |
| 41 size_t num_valid_entries_; |
| 42 const size_t buffer_size_; |
| 43 float x_velocity_; |
| 44 float y_velocity_; |
| 45 bool velocities_stale_; |
| 46 DISALLOW_COPY_AND_ASSIGN(VelocityCalculator); |
| 47 }; |
| 48 |
| 49 } // namespace aura |
| 50 |
| 51 #endif // UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ |
OLD | NEW |