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