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.
5 #ifndef UI_EVENTS_GESTURES_VELOCITY_CALCULATOR_H_
6 #define UI_EVENTS_GESTURES_VELOCITY_CALCULATOR_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/events/events_export.h"
16 class EVENTS_EXPORT VelocityCalculator {
18 explicit VelocityCalculator(int bufferSize);
19 ~VelocityCalculator();
20 void PointSeen(float x, float y, int64 time);
23 float VelocitySquared();
33 void UpdateVelocity();
35 typedef scoped_ptr<Point[]> HistoryBuffer;
36 HistoryBuffer buffer_;
38 // index_ points directly after the last point added.
40 size_t num_valid_entries_;
41 const size_t buffer_size_;
44 bool velocities_stale_;
45 DISALLOW_COPY_AND_ASSIGN(VelocityCalculator);
50 #endif // UI_EVENTS_GESTURES_VELOCITY_CALCULATOR_H_