Chromium Code Reviews| 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..63419a85925d01a3783a7e5c73f6a238eb9d6bd4 |
| --- /dev/null |
| +++ b/ui/aura/gestures/velocity_calculator.h |
| @@ -0,0 +1,46 @@ |
| +// 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 { |
|
rjkroege
2012/02/02 20:24:17
Am not convinced that you need this. This class is
|
| + public: |
| + explicit VelocityCalculator(int bufferSize); |
| + ~VelocityCalculator(); |
| + void PointSeen(int x, int y, int64 time); |
| + float x_velocity() const { return x_velocity_; } |
| + float y_velocity() const { return y_velocity_; } |
| + float VelocitySquared() const; |
| + void ClearHistory(); |
| + |
| + private: |
| + struct Point { |
| + int x; |
| + int y; |
| + int64 time; |
| + }; |
| + |
| + void UpdateVelocity(); |
| + |
| + typedef Point* HistoryBuffer; |
| + HistoryBuffer buffer_; |
| + |
| + // 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_; |
| +}; |
| +} // namespace aura |
| + |
| +#endif // UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_ |