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

Side by Side Diff: ui/events/gesture_detection/motion_event_generic.cc

Issue 1187273004: Pass MotionEvent tilt angles to Blink on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 : id(0), 22 : id(0),
23 tool_type(MotionEvent::TOOL_TYPE_UNKNOWN), 23 tool_type(MotionEvent::TOOL_TYPE_UNKNOWN),
24 x(x), 24 x(x),
25 y(y), 25 y(y),
26 raw_x(x), 26 raw_x(x),
27 raw_y(y), 27 raw_y(y),
28 pressure(0), 28 pressure(0),
29 touch_major(touch_major), 29 touch_major(touch_major),
30 touch_minor(0), 30 touch_minor(0),
31 orientation(0), 31 orientation(0),
32 tilt(0),
32 source_device_id(0) { 33 source_device_id(0) {
33 } 34 }
34 35
35 PointerProperties::PointerProperties(const MotionEvent& event, 36 PointerProperties::PointerProperties(const MotionEvent& event,
36 size_t pointer_index) 37 size_t pointer_index)
37 : id(event.GetPointerId(pointer_index)), 38 : id(event.GetPointerId(pointer_index)),
38 tool_type(event.GetToolType(pointer_index)), 39 tool_type(event.GetToolType(pointer_index)),
39 x(event.GetX(pointer_index)), 40 x(event.GetX(pointer_index)),
40 y(event.GetY(pointer_index)), 41 y(event.GetY(pointer_index)),
41 raw_x(event.GetRawX(pointer_index)), 42 raw_x(event.GetRawX(pointer_index)),
42 raw_y(event.GetRawY(pointer_index)), 43 raw_y(event.GetRawY(pointer_index)),
43 pressure(event.GetPressure(pointer_index)), 44 pressure(event.GetPressure(pointer_index)),
44 touch_major(event.GetTouchMajor(pointer_index)), 45 touch_major(event.GetTouchMajor(pointer_index)),
45 touch_minor(event.GetTouchMinor(pointer_index)), 46 touch_minor(event.GetTouchMinor(pointer_index)),
46 orientation(event.GetOrientation(pointer_index)), 47 orientation(event.GetOrientation(pointer_index)),
48 tilt(event.GetTilt(pointer_index)),
47 source_device_id(0) { 49 source_device_id(0) {
48 } 50 }
49 51
50 void PointerProperties::SetAxesAndOrientation(float radius_x, 52 void PointerProperties::SetAxesAndOrientation(float radius_x,
51 float radius_y, 53 float radius_y,
52 float rotation_angle_degree) { 54 float rotation_angle_degree) {
53 DCHECK(!touch_major && !touch_minor && !orientation); 55 DCHECK(!touch_major && !touch_minor && !orientation);
54 float rotation_angle_rad = rotation_angle_degree * M_PI / 180.f; 56 float rotation_angle_rad = rotation_angle_degree * M_PI / 180.f;
55 DCHECK_GE(radius_x, 0) << "Unexpected x-radius < 0 (" << radius_x << ")"; 57 DCHECK_GE(radius_x, 0) << "Unexpected x-radius < 0 (" << radius_x << ")";
56 DCHECK_GE(radius_y, 0) << "Unexpected y-radius < 0 (" << radius_y << ")"; 58 DCHECK_GE(radius_y, 0) << "Unexpected y-radius < 0 (" << radius_y << ")";
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 float MotionEventGeneric::GetOrientation(size_t pointer_index) const { 165 float MotionEventGeneric::GetOrientation(size_t pointer_index) const {
164 DCHECK_LT(pointer_index, pointers_->size()); 166 DCHECK_LT(pointer_index, pointers_->size());
165 return pointers_[pointer_index].orientation; 167 return pointers_[pointer_index].orientation;
166 } 168 }
167 169
168 float MotionEventGeneric::GetPressure(size_t pointer_index) const { 170 float MotionEventGeneric::GetPressure(size_t pointer_index) const {
169 DCHECK_LT(pointer_index, pointers_->size()); 171 DCHECK_LT(pointer_index, pointers_->size());
170 return pointers_[pointer_index].pressure; 172 return pointers_[pointer_index].pressure;
171 } 173 }
172 174
175 float MotionEventGeneric::GetTilt(size_t pointer_index) const {
176 DCHECK_LT(pointer_index, pointers_->size());
177 return pointers_[pointer_index].tilt;
178 }
179
173 MotionEvent::ToolType MotionEventGeneric::GetToolType( 180 MotionEvent::ToolType MotionEventGeneric::GetToolType(
174 size_t pointer_index) const { 181 size_t pointer_index) const {
175 DCHECK_LT(pointer_index, pointers_->size()); 182 DCHECK_LT(pointer_index, pointers_->size());
176 return pointers_[pointer_index].tool_type; 183 return pointers_[pointer_index].tool_type;
177 } 184 }
178 185
179 int MotionEventGeneric::GetButtonState() const { 186 int MotionEventGeneric::GetButtonState() const {
180 return button_state_; 187 return button_state_;
181 } 188 }
182 189
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 PushHistoricalEvent(other.historical_events_[h]->Clone()); 317 PushHistoricalEvent(other.historical_events_[h]->Clone());
311 return *this; 318 return *this;
312 } 319 }
313 320
314 void MotionEventGeneric::PopPointer() { 321 void MotionEventGeneric::PopPointer() {
315 DCHECK_GT(pointers_->size(), 0U); 322 DCHECK_GT(pointers_->size(), 0U);
316 pointers_->pop_back(); 323 pointers_->pop_back();
317 } 324 }
318 325
319 } // namespace ui 326 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698