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

Unified Diff: content/browser/renderer_host/input/gestures/velocity_tracker_state.h

Issue 128613003: [Tracking Patch] Unified gesture detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/gestures/velocity_tracker_state.h
diff --git a/content/browser/renderer_host/input/gestures/velocity_tracker_state.h b/content/browser/renderer_host/input/gestures/velocity_tracker_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..9a2a7f166f07227720615c0063ad18e809d8fd52
--- /dev/null
+++ b/content/browser/renderer_host/input/gestures/velocity_tracker_state.h
@@ -0,0 +1,47 @@
+// Copyright 2014 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 CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_VELOCITY_TRACKER_STATE_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_VELOCITY_TRACKER_STATE_H_
+
+#include "base/basictypes.h"
+#include "content/browser/renderer_host/input/gestures/bitset_32.h"
+#include "content/browser/renderer_host/input/gestures/velocity_tracker.h"
+
+namespace content {
+
+class MotionEvent;
+
+// Port of VelocityTrackerState from Android
+// * platform/frameworks/base/core/jni/android_view_VelocityTracker.cpp
+// * Change-Id: I3517881b87b47dcc209d80dbd0ac6b5cf29a766f
+// * Changes to this class should be cosmetic only, easing fork maintenance.
+class VelocityTrackerState {
+public:
+ VelocityTrackerState();
+
+ void Clear();
+ void AddMovement(const MotionEvent& event);
+ void ComputeCurrentVelocity(int32_t units, float max_velocity);
+ float GetXVelocity(int32_t id) const;
+ float GetYVelocity(int32_t id) const;
+
+private:
+ struct Velocity {
+ float vx, vy;
+ };
+
+ void GetVelocity(int32_t id, float* out_vx, float* out_vy) const;
+
+ VelocityTracker velocity_tracker_;
+ int32_t active_pointer_id_;
+ BitSet32 calculated_id_bits_;
+ Velocity calculated_velocity_[VelocityTracker::MAX_POINTERS];
+
+ DISALLOW_COPY_AND_ASSIGN(VelocityTrackerState);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_VELOCITY_TRACKER_STATE_H_

Powered by Google App Engine
This is Rietveld 408576698