| 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 8d36c812cc0084dc9ba3d5cb2d9fa0459ff23832..4045a1875fd9e200d55c37457c14947e9ca33f7e 100644
|
| --- a/content/browser/renderer_host/input/motion_event_android.cc
|
| +++ b/content/browser/renderer_host/input/motion_event_android.cc
|
| @@ -125,6 +125,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),
|
| @@ -132,6 +133,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) {
|
| }
|
|
|
| @@ -140,6 +142,7 @@ MotionEventAndroid::CachedPointer::CachedPointer()
|
| touch_major(0),
|
| touch_minor(0),
|
| orientation(0),
|
| + tilt(0),
|
| tool_type(TOOL_TYPE_UNKNOWN) {
|
| }
|
|
|
| @@ -269,6 +272,56 @@ 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));
|
| +}
|
| +
|
| +// TODO(e_hakkinen): Remove either this or GetTiltX and GetTiltY.
|
| +float MotionEventAndroid::GetTiltOrientation(size_t pointer_index) const {
|
| + DCHECK_LT(pointer_index, cached_pointer_count_);
|
| + if (GetToolType(pointer_index) != MotionEvent::TOOL_TYPE_STYLUS)
|
| + return 0.f;
|
| + float orientation;
|
| + if (pointer_index < MAX_POINTERS_TO_CACHE)
|
| + orientation = cached_pointers_[pointer_index].orientation;
|
| + else if (!event_.obj())
|
| + return 0.f;
|
| + else
|
| + orientation = ToValidFloat(Java_MotionEvent_getOrientationF_I(
|
| + AttachCurrentThread(), event_.obj(), pointer_index));
|
| + return orientation < 0 ? orientation + M_PI : orientation - M_PI;
|
| +}
|
| +
|
| +// TODO(e_hakkinen): Remove either this and GetTiltY or GetTiltOrientation.
|
| +float MotionEventAndroid::GetTiltX(size_t pointer_index) const {
|
| + DCHECK_LT(pointer_index, cached_pointer_count_);
|
| + if (GetToolType(pointer_index) != MotionEvent::TOOL_TYPE_STYLUS)
|
| + return 0.f;
|
| + float orientation = GetOrientation(pointer_index);
|
| + float tilt = GetTilt(pointer_index);
|
| + // A stylus points to a direction specified by orientation and tilts to
|
| + // the opposite direction. Coordinate system is left-handed.
|
| + return atan2(sin(-orientation) * sin(tilt), cos(tilt));
|
| +}
|
| +
|
| +// TODO(e_hakkinen): Remove either this and GetTiltX or GetTiltOrientation.
|
| +float MotionEventAndroid::GetTiltY(size_t pointer_index) const {
|
| + DCHECK_LT(pointer_index, cached_pointer_count_);
|
| + if (GetToolType(pointer_index) != MotionEvent::TOOL_TYPE_STYLUS)
|
| + return 0.f;
|
| + float orientation = GetOrientation(pointer_index);
|
| + float tilt = GetTilt(pointer_index);
|
| + // A stylus points to a direction specified by orientation and tilts to
|
| + // the opposite direction. Coordinate system is left-handed.
|
| + return atan2(cos(-orientation) * sin(tilt), cos(tilt));
|
| +}
|
| +
|
| base::TimeTicks MotionEventAndroid::GetEventTime() const {
|
| return cached_time_;
|
| }
|
| @@ -332,6 +385,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;
|
| }
|
|
|