Index: content/browser/renderer_host/input/motion_event_web.cc |
diff --git a/content/browser/renderer_host/input/motion_event_web.cc b/content/browser/renderer_host/input/motion_event_web.cc |
index 6e53773a68e8c14f28d79d1a43e9cca1bab1a7d5..fdb012a21f73ed4e3678465c94c03f1b00f1f55a 100644 |
--- a/content/browser/renderer_host/input/motion_event_web.cc |
+++ b/content/browser/renderer_host/input/motion_event_web.cc |
@@ -2,6 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+// MSVC++ requires this to be set before any other includes to get M_PI. |
+#define _USE_MATH_DEFINES |
+ |
#include "content/browser/renderer_host/input/motion_event_web.h" |
#include "base/logging.h" |
@@ -102,11 +105,32 @@ float MotionEventWeb::GetRawY(size_t pointer_index) const { |
float MotionEventWeb::GetTouchMajor(size_t pointer_index) const { |
DCHECK_LT(pointer_index, GetPointerCount()); |
- // TODO(jdduke): We should be a bit more careful about axes here. |
return 2.f * std::max(event_.touches[pointer_index].radiusX, |
event_.touches[pointer_index].radiusY); |
} |
+float MotionEventWeb::GetTouchMinor(size_t pointer_index) const { |
+ DCHECK_LT(pointer_index, GetPointerCount()); |
+ return 2.f * std::min(event_.touches[pointer_index].radiusX, |
+ event_.touches[pointer_index].radiusY); |
+} |
+ |
+float MotionEventWeb::GetOrientation(size_t pointer_index) const { |
+ DCHECK_LT(pointer_index, GetPointerCount()); |
+ |
+ float rotation_angle_rad = event_.touches[pointer_index].rotationAngle |
+ * M_PI / 180.f; |
+ DCHECK(0 <= rotation_angle_rad && rotation_angle_rad <= M_PI_2) |
+ << "Unexpected touch rotation angle"; |
+ |
+ if (event_.touches[pointer_index].radiusX |
+ < event_.touches[pointer_index].radiusY) { |
+ rotation_angle_rad -= M_PI_2; |
+ } |
+ |
+ return rotation_angle_rad; |
+} |
+ |
float MotionEventWeb::GetPressure(size_t pointer_index) const { |
return 0.f; |
} |