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

Side by Side Diff: ui/events/android/motion_event_android.h

Issue 2770613002: Forward GenericMotionEvent to EventForwarder (Closed)
Patch Set: comments Created 3 years, 8 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/android/view_client.cc ('k') | ui/events/android/motion_event_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_ 5 #ifndef UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_
6 #define UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_ 6 #define UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 28 matching lines...) Expand all
39 jfloat pos_y_pixels; 39 jfloat pos_y_pixels;
40 jfloat touch_major_pixels; 40 jfloat touch_major_pixels;
41 jfloat touch_minor_pixels; 41 jfloat touch_minor_pixels;
42 jfloat orientation_rad; 42 jfloat orientation_rad;
43 jfloat tilt_rad; 43 jfloat tilt_rad;
44 jint tool_type; 44 jint tool_type;
45 }; 45 };
46 46
47 // Forcing the caller to provide all cached values upon construction 47 // Forcing the caller to provide all cached values upon construction
48 // eliminates the need to perform a JNI call to retrieve values individually. 48 // eliminates the need to perform a JNI call to retrieve values individually.
49 MotionEventAndroid(float pix_to_dip, 49 MotionEventAndroid(JNIEnv* env,
50 JNIEnv* env,
51 jobject event, 50 jobject event,
51 jfloat pix_to_dip,
52 jfloat ticks_x,
53 jfloat ticks_y,
54 jfloat tick_multiplier,
52 jlong time_ms, 55 jlong time_ms,
53 jint android_action, 56 jint android_action,
54 jint pointer_count, 57 jint pointer_count,
55 jint history_size, 58 jint history_size,
56 jint action_index, 59 jint action_index,
57 jint android_action_button, 60 jint android_action_button,
58 jint android_button_state, 61 jint android_button_state,
59 jint meta_state, 62 jint meta_state,
60 jfloat raw_offset_x_pixels, 63 jfloat raw_offset_x_pixels,
61 jfloat raw_offset_y_pixels, 64 jfloat raw_offset_y_pixels,
(...skipping 26 matching lines...) Expand all
88 size_t historical_index) const override; 91 size_t historical_index) const override;
89 float GetHistoricalX(size_t pointer_index, 92 float GetHistoricalX(size_t pointer_index,
90 size_t historical_index) const override; 93 size_t historical_index) const override;
91 float GetHistoricalY(size_t pointer_index, 94 float GetHistoricalY(size_t pointer_index,
92 size_t historical_index) const override; 95 size_t historical_index) const override;
93 ToolType GetToolType(size_t pointer_index) const override; 96 ToolType GetToolType(size_t pointer_index) const override;
94 int GetButtonState() const override; 97 int GetButtonState() const override;
95 int GetFlags() const override; 98 int GetFlags() const override;
96 99
97 int GetActionButton() const; 100 int GetActionButton() const;
101 float ticks_x() const { return ticks_x_; }
102 float ticks_y() const { return ticks_y_; }
103 float time_sec() const { return time_sec_; }
104 float GetTickMultiplier() const;
105
98 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() const; 106 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() const;
99 107
100 private: 108 private:
101 struct CachedPointer; 109 struct CachedPointer;
102 110
103 float ToDips(float pixels) const; 111 float ToDips(float pixels) const;
104 CachedPointer FromAndroidPointer(const Pointer& pointer) const; 112 CachedPointer FromAndroidPointer(const Pointer& pointer) const;
105 CachedPointer OffsetCachedPointer(const CachedPointer& pointer, 113 CachedPointer OffsetCachedPointer(const CachedPointer& pointer,
106 float x, 114 float x,
107 float y) const; 115 float y) const;
108 116
109 // Cache pointer coords, id's and major lengths for the most common 117 // Cache pointer coords, id's and major lengths for the most common
110 // touch-related scenarios, i.e., scrolling and pinching. This prevents 118 // touch-related scenarios, i.e., scrolling and pinching. This prevents
111 // redundant JNI fetches for the same bits. 119 // redundant JNI fetches for the same bits.
112 enum { MAX_POINTERS_TO_CACHE = 2 }; 120 enum { MAX_POINTERS_TO_CACHE = 2 };
113 121
114 // The Java reference to the underlying MotionEvent. 122 // The Java reference to the underlying MotionEvent.
115 base::android::ScopedJavaGlobalRef<jobject> event_; 123 base::android::ScopedJavaGlobalRef<jobject> event_;
116 124
117 // Used to convert pixel coordinates from the Java-backed MotionEvent to 125 // Used to convert pixel coordinates from the Java-backed MotionEvent to
118 // DIP coordinates cached/returned by the MotionEventAndroid. 126 // DIP coordinates cached/returned by the MotionEventAndroid.
119 const float pix_to_dip_; 127 const float pix_to_dip_;
120 128
129 // Variables for mouse wheel event.
130 const float ticks_x_;
131 const float ticks_y_;
132 const float tick_multiplier_;
133 const uint64_t time_sec_;
134
121 const base::TimeTicks cached_time_; 135 const base::TimeTicks cached_time_;
122 const Action cached_action_; 136 const Action cached_action_;
123 const size_t cached_pointer_count_; 137 const size_t cached_pointer_count_;
124 const size_t cached_history_size_; 138 const size_t cached_history_size_;
125 const int cached_action_index_; 139 const int cached_action_index_;
126 const int cached_action_button_; 140 const int cached_action_button_;
127 const int cached_button_state_; 141 const int cached_button_state_;
128 const int cached_flags_; 142 const int cached_flags_;
129 const gfx::Vector2dF cached_raw_position_offset_; 143 const gfx::Vector2dF cached_raw_position_offset_;
130 struct CachedPointer { 144 struct CachedPointer {
(...skipping 11 matching lines...) Expand all
142 const uint32_t unique_event_id_; 156 const uint32_t unique_event_id_;
143 157
144 // Disallow copy/assign. 158 // Disallow copy/assign.
145 MotionEventAndroid(const MotionEventAndroid& e); // private ctor 159 MotionEventAndroid(const MotionEventAndroid& e); // private ctor
146 void operator=(const MotionEventAndroid&) = delete; 160 void operator=(const MotionEventAndroid&) = delete;
147 }; 161 };
148 162
149 } // namespace content 163 } // namespace content
150 164
151 #endif // UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_ 165 #endif // UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_H_
OLDNEW
« no previous file with comments | « ui/android/view_client.cc ('k') | ui/events/android/motion_event_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698