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

Side by Side Diff: content/browser/renderer_host/input/motion_event_web.cc

Issue 2860793003: Pass through tilt_x and tilt_y to blink (Closed)
Patch Set: Pass through tilt_x and tilt_y to blink Created 3 years, 7 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 "content/browser/renderer_host/input/motion_event_web.h" 8 #include "content/browser/renderer_host/input/motion_event_web.h"
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 orientation_rad -= static_cast<float>(M_PI_2); 161 orientation_rad -= static_cast<float>(M_PI_2);
162 } 162 }
163 163
164 return orientation_rad; 164 return orientation_rad;
165 } 165 }
166 166
167 float MotionEventWeb::GetPressure(size_t pointer_index) const { 167 float MotionEventWeb::GetPressure(size_t pointer_index) const {
168 return 0.f; 168 return 0.f;
169 } 169 }
170 170
171 float MotionEventWeb::GetTilt(size_t pointer_index) const { 171 float MotionEventWeb::GetTiltX(size_t pointer_index) const {
172 DCHECK_LT(pointer_index, GetPointerCount()); 172 DCHECK_LT(pointer_index, GetPointerCount());
173 173
174 if (GetToolType(pointer_index) != TOOL_TYPE_STYLUS) 174 if (GetToolType(pointer_index) != TOOL_TYPE_STYLUS)
175 return 0.f; 175 return 0.f;
176 176
177 const WebPointerProperties& pointer = event_.touches[pointer_index]; 177 return event_.touches[pointer_index].tilt_x;
178 }
178 179
179 float tilt_x_r = sin(pointer.tilt_x * M_PI / 180.f); 180 float MotionEventWeb::GetTiltY(size_t pointer_index) const {
180 float tilt_x_z = cos(pointer.tilt_x * M_PI / 180.f); 181 DCHECK_LT(pointer_index, GetPointerCount());
181 float tilt_y_r = sin(pointer.tilt_y * M_PI / 180.f);
182 float tilt_y_z = cos(pointer.tilt_y * M_PI / 180.f);
183 float r_x = tilt_x_r * tilt_y_z;
184 float r_y = tilt_y_r * tilt_x_z;
185 float r = sqrt(r_x * r_x + r_y * r_y);
186 float z = tilt_x_z * tilt_y_z;
187 182
188 return atan2(r, z); 183 if (GetToolType(pointer_index) != TOOL_TYPE_STYLUS)
184 return 0.f;
185
186 return event_.touches[pointer_index].tilt_y;
189 } 187 }
190 188
191 base::TimeTicks MotionEventWeb::GetEventTime() const { 189 base::TimeTicks MotionEventWeb::GetEventTime() const {
192 return base::TimeTicks() + 190 return base::TimeTicks() +
193 base::TimeDelta::FromMicroseconds(event_.TimeStampSeconds() * 191 base::TimeDelta::FromMicroseconds(event_.TimeStampSeconds() *
194 base::Time::kMicrosecondsPerSecond); 192 base::Time::kMicrosecondsPerSecond);
195 } 193 }
196 194
197 ui::MotionEvent::ToolType MotionEventWeb::GetToolType( 195 ui::MotionEvent::ToolType MotionEventWeb::GetToolType(
198 size_t pointer_index) const { 196 size_t pointer_index) const {
(...skipping 19 matching lines...) Expand all
218 216
219 int MotionEventWeb::GetButtonState() const { 217 int MotionEventWeb::GetButtonState() const {
220 return 0; 218 return 0;
221 } 219 }
222 220
223 int MotionEventWeb::GetFlags() const { 221 int MotionEventWeb::GetFlags() const {
224 return ui::WebEventModifiersToEventFlags(event_.GetModifiers()); 222 return ui::WebEventModifiersToEventFlags(event_.GetModifiers());
225 } 223 }
226 224
227 } // namespace content 225 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698