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

Unified Diff: ui/events/gestures/motion_event_aura.cc

Issue 494833003: Completed webkit radiusX, radiusY and rotationAngle handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaked NaN checks Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/gestures/motion_event_aura.cc
diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc
index bfe3321bed42f0972e1430cc80ca67c64677c202..483e33af8a4b2c92895f6e87c4554de9ff0cad33 100644
--- a/ui/events/gestures/motion_event_aura.cc
+++ b/ui/events/gestures/motion_event_aura.cc
@@ -2,8 +2,13 @@
// 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 "ui/events/gestures/motion_event_aura.h"
+#include <cmath>
+
#include "base/logging.h"
#include "ui/events/gestures/gesture_configuration.h"
@@ -41,11 +46,30 @@ MotionEventAura::PointData MotionEventAura::GetPointDataFromTouchEvent(
point_data.pressure = touch.force();
point_data.source_device_id = touch.source_device_id();
- // TODO(tdresser): at some point we should start using both radii if they are
- // available, but for now we use the max.
- point_data.major_radius = std::max(touch.radius_x(), touch.radius_y());
- if (!point_data.major_radius)
+ float radius_x = touch.radius_x();
+ float radius_y = touch.radius_y();
+ float rotation_angle_rad = touch.rotation_angle() * M_PI / 180.f;
+ DCHECK_GE(radius_x, 0) << "Unexpected x-radius < 0";
+ DCHECK_GE(radius_y, 0) << "Unexpected y-radius < 0";
+ DCHECK(0 <= rotation_angle_rad && rotation_angle_rad <= M_PI_2)
+ << "Unexpected touch rotation angle";
+
+ if (radius_x >= radius_y) {
jdduke (slow) 2014/08/29 16:45:08 tdresser@: Is it still the case that we see touche
mustaq 2014/08/29 17:28:44 See crbug.com/406004 On 2014/08/29 16:45:08, jddu
+ point_data.major_radius = radius_x;
+ point_data.minor_radius = radius_y;
+ point_data.orientation = rotation_angle_rad - M_PI_2;
+ } else {
+ point_data.major_radius = radius_y;
+ point_data.minor_radius = radius_x;
+ point_data.orientation = rotation_angle_rad;
+ }
+
+ if (!point_data.major_radius) {
point_data.major_radius = GestureConfiguration::default_radius();
+ point_data.minor_radius = GestureConfiguration::default_radius();
+ point_data.orientation = 0;
+ }
+
return point_data;
}
@@ -118,7 +142,17 @@ float MotionEventAura::GetRawY(size_t pointer_index) const {
float MotionEventAura::GetTouchMajor(size_t pointer_index) const {
DCHECK_LT(pointer_index, pointer_count_);
- return active_touches_[pointer_index].major_radius * 2;
+ return active_touches_[pointer_index].major_radius * 2.f;
+}
+
+float MotionEventAura::GetTouchMinor(size_t pointer_index) const {
+ DCHECK_LE(pointer_index, pointer_count_);
+ return active_touches_[pointer_index].minor_radius * 2.f;
+}
+
+float MotionEventAura::GetOrientation(size_t pointer_index) const {
+ DCHECK_LE(pointer_index, pointer_count_);
+ return active_touches_[pointer_index].orientation;
}
float MotionEventAura::GetPressure(size_t pointer_index) const {
@@ -172,7 +206,9 @@ MotionEventAura::PointData::PointData()
touch_id(0),
pressure(0),
source_device_id(0),
- major_radius(0) {
+ major_radius(0),
+ minor_radius(0),
+ orientation(0) {
}
int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const {

Powered by Google App Engine
This is Rietveld 408576698