| 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 #include "ui/events/android/motion_event_android.h" | 5 #include "ui/events/android/motion_event_android.h" |
| 6 | 6 |
| 7 #include <android/input.h> | 7 #include <android/input.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 uint32_t MotionEventAndroid::GetUniqueEventId() const { | 223 uint32_t MotionEventAndroid::GetUniqueEventId() const { |
| 224 return unique_event_id_; | 224 return unique_event_id_; |
| 225 } | 225 } |
| 226 | 226 |
| 227 MotionEventAndroid::Action MotionEventAndroid::GetAction() const { | 227 MotionEventAndroid::Action MotionEventAndroid::GetAction() const { |
| 228 return cached_action_; | 228 return cached_action_; |
| 229 } | 229 } |
| 230 | 230 |
| 231 int MotionEventAndroid::GetActionIndex() const { | 231 int MotionEventAndroid::GetActionIndex() const { |
| 232 DCHECK(cached_action_ == ACTION_POINTER_UP || | 232 DCHECK(cached_action_ == MotionEvent::ACTION_POINTER_UP || |
| 233 cached_action_ == ACTION_POINTER_DOWN) | 233 cached_action_ == MotionEvent::ACTION_POINTER_DOWN) |
| 234 << "Invalid action for GetActionIndex(): " << cached_action_; | 234 << "Invalid action for GetActionIndex(): " << cached_action_; |
| 235 DCHECK_GE(cached_action_index_, 0); | 235 DCHECK_GE(cached_action_index_, 0); |
| 236 DCHECK_LT(cached_action_index_, static_cast<int>(cached_pointer_count_)); | 236 DCHECK_LT(cached_action_index_, static_cast<int>(cached_pointer_count_)); |
| 237 return cached_action_index_; | 237 return cached_action_index_; |
| 238 } | 238 } |
| 239 | 239 |
| 240 size_t MotionEventAndroid::GetPointerCount() const { | 240 size_t MotionEventAndroid::GetPointerCount() const { |
| 241 return cached_pointer_count_; | 241 return cached_pointer_count_; |
| 242 } | 242 } |
| 243 | 243 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 AttachCurrentThread(), event_, pointer_index)); | 297 AttachCurrentThread(), event_, pointer_index)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 float MotionEventAndroid::GetPressure(size_t pointer_index) const { | 300 float MotionEventAndroid::GetPressure(size_t pointer_index) const { |
| 301 DCHECK_LT(pointer_index, cached_pointer_count_); | 301 DCHECK_LT(pointer_index, cached_pointer_count_); |
| 302 // Note that this early return is a special case exercised only in testing, as | 302 // Note that this early return is a special case exercised only in testing, as |
| 303 // caching the pressure values is not a worthwhile optimization (they're | 303 // caching the pressure values is not a worthwhile optimization (they're |
| 304 // accessed at most once per event instance). | 304 // accessed at most once per event instance). |
| 305 if (!event_.obj()) | 305 if (!event_.obj()) |
| 306 return 0.f; | 306 return 0.f; |
| 307 if (cached_action_ == MotionEvent::ACTION_UP) |
| 308 return 0.f; |
| 307 return Java_MotionEvent_getPressureF_I(AttachCurrentThread(), event_, | 309 return Java_MotionEvent_getPressureF_I(AttachCurrentThread(), event_, |
| 308 pointer_index); | 310 pointer_index); |
| 309 } | 311 } |
| 310 | 312 |
| 311 float MotionEventAndroid::GetTilt(size_t pointer_index) const { | 313 float MotionEventAndroid::GetTilt(size_t pointer_index) const { |
| 312 DCHECK_LT(pointer_index, cached_pointer_count_); | 314 DCHECK_LT(pointer_index, cached_pointer_count_); |
| 313 if (pointer_index < MAX_POINTERS_TO_CACHE) | 315 if (pointer_index < MAX_POINTERS_TO_CACHE) |
| 314 return cached_pointers_[pointer_index].tilt; | 316 return cached_pointers_[pointer_index].tilt; |
| 315 if (!event_.obj()) | 317 if (!event_.obj()) |
| 316 return 0.f; | 318 return 0.f; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 gfx::PointF(ToDips(pointer.pos_x_pixels), ToDips(pointer.pos_y_pixels)); | 382 gfx::PointF(ToDips(pointer.pos_x_pixels), ToDips(pointer.pos_y_pixels)); |
| 381 result.touch_major = ToDips(pointer.touch_major_pixels); | 383 result.touch_major = ToDips(pointer.touch_major_pixels); |
| 382 result.touch_minor = ToDips(pointer.touch_minor_pixels); | 384 result.touch_minor = ToDips(pointer.touch_minor_pixels); |
| 383 result.orientation = ToValidFloat(pointer.orientation_rad); | 385 result.orientation = ToValidFloat(pointer.orientation_rad); |
| 384 result.tilt = ToValidFloat(pointer.tilt_rad); | 386 result.tilt = ToValidFloat(pointer.tilt_rad); |
| 385 result.tool_type = FromAndroidToolType(pointer.tool_type); | 387 result.tool_type = FromAndroidToolType(pointer.tool_type); |
| 386 return result; | 388 return result; |
| 387 } | 389 } |
| 388 | 390 |
| 389 } // namespace content | 391 } // namespace content |
| OLD | NEW |