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

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: Fixes for clang chromium-style-check. 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
« no previous file with comments | « ui/aura/gestures/gesture_sequence.cc ('k') | ui/aura/gestures/velocity_calculator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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_
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_sequence.cc ('k') | ui/aura/gestures/velocity_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698