| OLD | NEW | 
|---|
| 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. | 
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES | 
| 7 | 7 | 
| 8 #include "ui/events/gesture_detection/motion_event_generic.h" | 8 #include "ui/events/gesture_detection/motion_event_generic.h" | 
| 9 | 9 | 
| 10 #include <cmath> | 10 #include <cmath> | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 24     : id(0), | 24     : id(0), | 
| 25       tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), | 25       tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), | 
| 26       x(x), | 26       x(x), | 
| 27       y(y), | 27       y(y), | 
| 28       raw_x(x), | 28       raw_x(x), | 
| 29       raw_y(y), | 29       raw_y(y), | 
| 30       pressure(0), | 30       pressure(0), | 
| 31       touch_major(touch_major), | 31       touch_major(touch_major), | 
| 32       touch_minor(0), | 32       touch_minor(0), | 
| 33       orientation(0), | 33       orientation(0), | 
| 34       tilt(0), | 34       tilt_x(0), | 
| 35       source_device_id(0) { | 35       tilt_y(0), | 
| 36 } | 36       source_device_id(0) {} | 
| 37 | 37 | 
| 38 PointerProperties::PointerProperties(const MotionEvent& event, | 38 PointerProperties::PointerProperties(const MotionEvent& event, | 
| 39                                      size_t pointer_index) | 39                                      size_t pointer_index) | 
| 40     : id(event.GetPointerId(pointer_index)), | 40     : id(event.GetPointerId(pointer_index)), | 
| 41       tool_type(event.GetToolType(pointer_index)), | 41       tool_type(event.GetToolType(pointer_index)), | 
| 42       x(event.GetX(pointer_index)), | 42       x(event.GetX(pointer_index)), | 
| 43       y(event.GetY(pointer_index)), | 43       y(event.GetY(pointer_index)), | 
| 44       raw_x(event.GetRawX(pointer_index)), | 44       raw_x(event.GetRawX(pointer_index)), | 
| 45       raw_y(event.GetRawY(pointer_index)), | 45       raw_y(event.GetRawY(pointer_index)), | 
| 46       pressure(event.GetPressure(pointer_index)), | 46       pressure(event.GetPressure(pointer_index)), | 
| 47       touch_major(event.GetTouchMajor(pointer_index)), | 47       touch_major(event.GetTouchMajor(pointer_index)), | 
| 48       touch_minor(event.GetTouchMinor(pointer_index)), | 48       touch_minor(event.GetTouchMinor(pointer_index)), | 
| 49       orientation(event.GetOrientation(pointer_index)), | 49       orientation(event.GetOrientation(pointer_index)), | 
| 50       tilt(event.GetTilt(pointer_index)), | 50       tilt_x(event.GetTiltX(pointer_index)), | 
| 51       source_device_id(0) { | 51       tilt_y(event.GetTiltY(pointer_index)), | 
| 52 } | 52       source_device_id(0) {} | 
| 53 | 53 | 
| 54 PointerProperties::PointerProperties(const PointerProperties& other) = default; | 54 PointerProperties::PointerProperties(const PointerProperties& other) = default; | 
| 55 | 55 | 
| 56 void PointerProperties::SetAxesAndOrientation(float radius_x, | 56 void PointerProperties::SetAxesAndOrientation(float radius_x, | 
| 57                                               float radius_y, | 57                                               float radius_y, | 
| 58                                               float rotation_angle_degree) { | 58                                               float rotation_angle_degree) { | 
| 59   DCHECK(!touch_major && !touch_minor && !orientation); | 59   DCHECK(!touch_major && !touch_minor && !orientation); | 
| 60   float rotation_angle_rad = rotation_angle_degree * M_PI / 180.f; | 60   float rotation_angle_rad = rotation_angle_degree * M_PI / 180.f; | 
| 61   DCHECK_GE(radius_x, 0) << "Unexpected x-radius < 0 (" << radius_x << ")"; | 61   DCHECK_GE(radius_x, 0) << "Unexpected x-radius < 0 (" << radius_x << ")"; | 
| 62   DCHECK_GE(radius_y, 0) << "Unexpected y-radius < 0 (" << radius_y << ")"; | 62   DCHECK_GE(radius_y, 0) << "Unexpected y-radius < 0 (" << radius_y << ")"; | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 169 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { | 169 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { | 
| 170   DCHECK_LT(pointer_index, pointers_->size()); | 170   DCHECK_LT(pointer_index, pointers_->size()); | 
| 171   return pointers_[pointer_index].orientation; | 171   return pointers_[pointer_index].orientation; | 
| 172 } | 172 } | 
| 173 | 173 | 
| 174 float MotionEventGeneric::GetPressure(size_t pointer_index) const { | 174 float MotionEventGeneric::GetPressure(size_t pointer_index) const { | 
| 175   DCHECK_LT(pointer_index, pointers_->size()); | 175   DCHECK_LT(pointer_index, pointers_->size()); | 
| 176   return pointers_[pointer_index].pressure; | 176   return pointers_[pointer_index].pressure; | 
| 177 } | 177 } | 
| 178 | 178 | 
| 179 float MotionEventGeneric::GetTilt(size_t pointer_index) const { | 179 float MotionEventGeneric::GetTiltX(size_t pointer_index) const { | 
| 180   DCHECK_LT(pointer_index, pointers_->size()); | 180   DCHECK_LT(pointer_index, pointers_->size()); | 
| 181   return pointers_[pointer_index].tilt; | 181   return pointers_[pointer_index].tilt_x; | 
|  | 182 } | 
|  | 183 | 
|  | 184 float MotionEventGeneric::GetTiltY(size_t pointer_index) const { | 
|  | 185   DCHECK_LT(pointer_index, pointers_->size()); | 
|  | 186   return pointers_[pointer_index].tilt_y; | 
| 182 } | 187 } | 
| 183 | 188 | 
| 184 MotionEvent::ToolType MotionEventGeneric::GetToolType( | 189 MotionEvent::ToolType MotionEventGeneric::GetToolType( | 
| 185     size_t pointer_index) const { | 190     size_t pointer_index) const { | 
| 186   DCHECK_LT(pointer_index, pointers_->size()); | 191   DCHECK_LT(pointer_index, pointers_->size()); | 
| 187   return pointers_[pointer_index].tool_type; | 192   return pointers_[pointer_index].tool_type; | 
| 188 } | 193 } | 
| 189 | 194 | 
| 190 int MotionEventGeneric::GetButtonState() const { | 195 int MotionEventGeneric::GetButtonState() const { | 
| 191   return button_state_; | 196   return button_state_; | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 323     PushHistoricalEvent(other.historical_events_[h]->Clone()); | 328     PushHistoricalEvent(other.historical_events_[h]->Clone()); | 
| 324   return *this; | 329   return *this; | 
| 325 } | 330 } | 
| 326 | 331 | 
| 327 void MotionEventGeneric::PopPointer() { | 332 void MotionEventGeneric::PopPointer() { | 
| 328   DCHECK_GT(pointers_->size(), 0U); | 333   DCHECK_GT(pointers_->size(), 0U); | 
| 329   pointers_->pop_back(); | 334   pointers_->pop_back(); | 
| 330 } | 335 } | 
| 331 | 336 | 
| 332 }  // namespace ui | 337 }  // namespace ui | 
| OLD | NEW | 
|---|