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

Unified Diff: content/browser/renderer_host/input/motion_event_android.cc

Issue 1417803002: Pass MotionEvent tilt angles to Blink on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Flattened nested ifs, fixed a special case Created 5 years, 1 month 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/motion_event_android.cc
diff --git a/content/browser/renderer_host/input/motion_event_android.cc b/content/browser/renderer_host/input/motion_event_android.cc
index 4d30a3f13bb4a268aa419e104c4eda0afda4ef16..6392e906232c5fac34afc0f899fbac8cef5ddb33 100644
--- a/content/browser/renderer_host/input/motion_event_android.cc
+++ b/content/browser/renderer_host/input/motion_event_android.cc
@@ -129,6 +129,7 @@ MotionEventAndroid::Pointer::Pointer(jint id,
jfloat touch_major_pixels,
jfloat touch_minor_pixels,
jfloat orientation_rad,
+ jfloat tilt_rad,
jint tool_type)
: id(id),
pos_x_pixels(pos_x_pixels),
@@ -136,6 +137,7 @@ MotionEventAndroid::Pointer::Pointer(jint id,
touch_major_pixels(touch_major_pixels),
touch_minor_pixels(touch_minor_pixels),
orientation_rad(orientation_rad),
+ tilt_rad(tilt_rad),
tool_type(tool_type) {
}
@@ -144,6 +146,7 @@ MotionEventAndroid::CachedPointer::CachedPointer()
touch_major(0),
touch_minor(0),
orientation(0),
+ tilt(0),
tool_type(TOOL_TYPE_UNKNOWN) {
}
@@ -273,6 +276,16 @@ float MotionEventAndroid::GetPressure(size_t pointer_index) const {
AttachCurrentThread(), event_.obj(), pointer_index);
}
+float MotionEventAndroid::GetTilt(size_t pointer_index) const {
+ DCHECK_LT(pointer_index, cached_pointer_count_);
+ if (pointer_index < MAX_POINTERS_TO_CACHE)
+ return cached_pointers_[pointer_index].tilt;
+ if (!event_.obj())
+ return 0.f;
+ return ToValidFloat(Java_MotionEvent_getAxisValueF_I_I(
+ AttachCurrentThread(), event_.obj(), AXIS_TILT, pointer_index));
+}
+
base::TimeTicks MotionEventAndroid::GetEventTime() const {
return cached_time_;
}
@@ -336,6 +349,7 @@ MotionEventAndroid::CachedPointer MotionEventAndroid::FromAndroidPointer(
result.touch_major = ToDips(pointer.touch_major_pixels);
result.touch_minor = ToDips(pointer.touch_minor_pixels);
result.orientation = ToValidFloat(pointer.orientation_rad);
+ result.tilt = ToValidFloat(pointer.tilt_rad);
result.tool_type = FromAndroidToolType(pointer.tool_type);
return result;
}

Powered by Google App Engine
This is Rietveld 408576698