Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: ui/aura/gestures/velocity_calculator.h

Issue 9310031: Event smoothing in CrOS gesture recognizer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Time stored in microseconds. All velocity logic moved from GesturePoint to VelocityCalculator. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
13 namespace aura {
14
15 class AURA_EXPORT VelocityCalculator {
rjkroege 2012/02/02 20:24:17 Am not convinced that you need this. This class is
16 public:
17 explicit VelocityCalculator(int bufferSize);
18 ~VelocityCalculator();
19 void PointSeen(int x, int y, int64 time);
20 float x_velocity() const { return x_velocity_; }
21 float y_velocity() const { return y_velocity_; }
22 float VelocitySquared() const;
23 void ClearHistory();
24
25 private:
26 struct Point {
27 int x;
28 int y;
29 int64 time;
30 };
31
32 void UpdateVelocity();
33
34 typedef Point* HistoryBuffer;
35 HistoryBuffer buffer_;
36
37 // index_ points directly after the last point added
38 int index_;
39 size_t num_valid_entries_;
40 const size_t buffer_size_;
41 float x_velocity_;
42 float y_velocity_;
43 };
44 } // namespace aura
45
46 #endif // UI_AURA_GESTURES_VELOCITY_CALCULATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698