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

Side by Side Diff: content/browser/renderer_host/input/motion_event_android.h

Issue 321563002: Support minimum gesture bounds in GestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 19 matching lines...) Expand all
30 jint pointer_count, 30 jint pointer_count,
31 jint history_size, 31 jint history_size,
32 jint action_index, 32 jint action_index,
33 jfloat pos_x_0_pixels, 33 jfloat pos_x_0_pixels,
34 jfloat pos_y_0_pixels, 34 jfloat pos_y_0_pixels,
35 jfloat pos_x_1_pixels, 35 jfloat pos_x_1_pixels,
36 jfloat pos_y_1_pixels, 36 jfloat pos_y_1_pixels,
37 jint pointer_id_0, 37 jint pointer_id_0,
38 jint pointer_id_1, 38 jint pointer_id_1,
39 jfloat touch_major_0_pixels, 39 jfloat touch_major_0_pixels,
40 jfloat touch_major_1_pixels); 40 jfloat touch_major_1_pixels,
41 jint tool_type);
41 virtual ~MotionEventAndroid(); 42 virtual ~MotionEventAndroid();
42 43
43 // ui::MotionEvent methods. 44 // ui::MotionEvent methods.
44 virtual int GetId() const OVERRIDE; 45 virtual int GetId() const OVERRIDE;
45 virtual Action GetAction() const OVERRIDE; 46 virtual Action GetAction() const OVERRIDE;
46 virtual int GetActionIndex() const OVERRIDE; 47 virtual int GetActionIndex() const OVERRIDE;
47 virtual size_t GetPointerCount() const OVERRIDE; 48 virtual size_t GetPointerCount() const OVERRIDE;
48 virtual int GetPointerId(size_t pointer_index) const OVERRIDE; 49 virtual int GetPointerId(size_t pointer_index) const OVERRIDE;
49 virtual float GetX(size_t pointer_index) const OVERRIDE; 50 virtual float GetX(size_t pointer_index) const OVERRIDE;
50 virtual float GetY(size_t pointer_index) const OVERRIDE; 51 virtual float GetY(size_t pointer_index) const OVERRIDE;
51 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE; 52 virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE;
52 virtual float GetPressure(size_t pointer_index) const OVERRIDE; 53 virtual float GetPressure(size_t pointer_index) const OVERRIDE;
53 virtual base::TimeTicks GetEventTime() const OVERRIDE; 54 virtual base::TimeTicks GetEventTime() const OVERRIDE;
54 virtual size_t GetHistorySize() const OVERRIDE; 55 virtual size_t GetHistorySize() const OVERRIDE;
55 virtual base::TimeTicks GetHistoricalEventTime( 56 virtual base::TimeTicks GetHistoricalEventTime(
56 size_t historical_index) const OVERRIDE; 57 size_t historical_index) const OVERRIDE;
57 virtual float GetHistoricalTouchMajor( 58 virtual float GetHistoricalTouchMajor(
58 size_t pointer_index, 59 size_t pointer_index,
59 size_t historical_index) const OVERRIDE; 60 size_t historical_index) const OVERRIDE;
60 virtual float GetHistoricalX( 61 virtual float GetHistoricalX(
61 size_t pointer_index, 62 size_t pointer_index,
62 size_t historical_index) const OVERRIDE; 63 size_t historical_index) const OVERRIDE;
63 virtual float GetHistoricalY( 64 virtual float GetHistoricalY(
64 size_t pointer_index, 65 size_t pointer_index,
65 size_t historical_index) const OVERRIDE; 66 size_t historical_index) const OVERRIDE;
66 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE; 67 virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE;
67 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE; 68 virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE;
68 69
69 // Additional Android MotionEvent methods. 70 // Note that raw indicates values unadjusted by any min/max (the reported
70 float GetTouchMinor() const { return GetTouchMinor(0); } 71 // values are still in DIPs).
71 float GetTouchMinor(size_t pointer_index) const; 72 float GetRawTouchMajor() const { return GetRawTouchMajor(0); }
73 float GetRawTouchMajor(size_t pointer_index) const;
74 float GetRawTouchMinor() const { return GetRawTouchMinor(0); }
tdresser 2014/06/06 16:58:04 Hmmm, it's a little weird to have GetRawTouchMinor
jdduke (slow) 2014/06/06 17:18:13 There's never been a |MotionEvent::GetTouchMinor()
75 float GetRawTouchMinor(size_t pointer_index) const;
72 float GetOrientation() const; 76 float GetOrientation() const;
73 base::TimeTicks GetDownTime() const; 77 base::TimeTicks GetDownTime() const;
74 78
75 static bool RegisterMotionEventAndroid(JNIEnv* env); 79 static bool RegisterMotionEventAndroid(JNIEnv* env);
76 80
77 static base::android::ScopedJavaLocalRef<jobject> Obtain( 81 static base::android::ScopedJavaLocalRef<jobject> Obtain(
78 const MotionEventAndroid& event); 82 const MotionEventAndroid& event);
79 static base::android::ScopedJavaLocalRef<jobject> Obtain( 83 static base::android::ScopedJavaLocalRef<jobject> Obtain(
80 base::TimeTicks down_time, 84 base::TimeTicks down_time,
81 base::TimeTicks event_time, 85 base::TimeTicks event_time,
82 Action action, 86 Action action,
83 float x_pixels, 87 float x_pixels,
84 float y_pixels); 88 float y_pixels);
85 89
86 private: 90 private:
87 MotionEventAndroid(); 91 MotionEventAndroid();
88 MotionEventAndroid(float pix_to_dip, JNIEnv* env, jobject event); 92 MotionEventAndroid(float pix_to_dip,
93 float min_touch_major_dips,
94 JNIEnv* env,
95 jobject event);
89 MotionEventAndroid(const MotionEventAndroid&); 96 MotionEventAndroid(const MotionEventAndroid&);
90 MotionEventAndroid& operator=(const MotionEventAndroid&); 97 MotionEventAndroid& operator=(const MotionEventAndroid&);
91 98
92 float ToDips(float pixels) const; 99 float ToDips(float pixels) const;
93 gfx::PointF ToDips(const gfx::PointF& pixels) const; 100 gfx::PointF ToDips(const gfx::PointF& pixels) const;
94 101
95 // Cache pointer coords, id's and major lengths for the most common 102 // Cache pointer coords, id's and major lengths for the most common
96 // touch-related scenarios, i.e., scrolling and pinching. This prevents 103 // touch-related scenarios, i.e., scrolling and pinching. This prevents
97 // redundant JNI fetches for the same bits. 104 // redundant JNI fetches for the same bits.
98 enum { MAX_POINTERS_TO_CACHE = 2 }; 105 enum { MAX_POINTERS_TO_CACHE = 2 };
99 106
100 // The Java reference to the underlying MotionEvent. 107 // The Java reference to the underlying MotionEvent.
101 base::android::ScopedJavaGlobalRef<jobject> event_; 108 base::android::ScopedJavaGlobalRef<jobject> event_;
102 109
103 base::TimeTicks cached_time_; 110 base::TimeTicks cached_time_;
104 Action cached_action_; 111 Action cached_action_;
105 size_t cached_pointer_count_; 112 size_t cached_pointer_count_;
106 size_t cached_history_size_; 113 size_t cached_history_size_;
107 int cached_action_index_; 114 int cached_action_index_;
108 gfx::PointF cached_positions_[MAX_POINTERS_TO_CACHE]; 115 gfx::PointF cached_positions_[MAX_POINTERS_TO_CACHE];
109 int cached_pointer_ids_[MAX_POINTERS_TO_CACHE]; 116 int cached_pointer_ids_[MAX_POINTERS_TO_CACHE];
110 float cached_touch_majors_[MAX_POINTERS_TO_CACHE]; 117 float cached_touch_majors_[MAX_POINTERS_TO_CACHE];
111 118
112 // Used to convert pixel coordinates from the Java-backed MotionEvent to 119 // Used to convert pixel coordinates from the Java-backed MotionEvent to
113 // DIP coordinates cached/returned by the MotionEventAndroid. 120 // DIP coordinates cached/returned by the MotionEventAndroid.
114 const float pix_to_dip_; 121 const float pix_to_dip_;
115 122
123 // Optional minimum used to report meaningful values for |GetTouchMajor()| on
124 // devices that otherwise report zero or inappropriatley small values. Note
tdresser 2014/06/06 16:58:04 s/inappropriatly/inappropriately
jdduke (slow) 2014/06/06 17:18:13 Done.
125 // that this is will be zero for stylus or mouse touch sources.
126 const float min_touch_major_dips_;
127
116 // Whether |event_| should be recycled on destruction. This will only be true 128 // Whether |event_| should be recycled on destruction. This will only be true
117 // for those events generated via |Obtain(...)|. 129 // for those events generated via |Obtain(...)|.
118 bool should_recycle_; 130 bool should_recycle_;
119 }; 131 };
120 132
121 } // namespace content 133 } // namespace content
122 134
123 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ 135 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | content/browser/renderer_host/input/motion_event_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698