| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 ACTION_DOWN = 0, | 22 ACTION_DOWN = 0, |
| 23 ACTION_UP = 1, | 23 ACTION_UP = 1, |
| 24 ACTION_MOVE = 2, | 24 ACTION_MOVE = 2, |
| 25 ACTION_CANCEL = 3, | 25 ACTION_CANCEL = 3, |
| 26 // Purposefully removed, as there is no analogous action in Chromium. | 26 // Purposefully removed, as there is no analogous action in Chromium. |
| 27 // ACTION_OUTSIDE = 4, | 27 // ACTION_OUTSIDE = 4, |
| 28 ACTION_POINTER_DOWN = 5, | 28 ACTION_POINTER_DOWN = 5, |
| 29 ACTION_POINTER_UP = 6 | 29 ACTION_POINTER_UP = 6 |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 explicit MotionEventAndroid(jobject event); | 32 MotionEventAndroid(JNIEnv* env, jobject event, bool should_recycle); |
| 33 MotionEventAndroid(const MotionEventAndroid& other); |
| 34 MotionEventAndroid& operator=(const MotionEventAndroid& other); |
| 33 ~MotionEventAndroid(); | 35 ~MotionEventAndroid(); |
| 34 | 36 |
| 35 Action GetActionMasked() const; | 37 Action GetActionMasked() const; |
| 36 size_t GetActionIndex() const; | 38 int GetActionIndex() const; |
| 37 size_t GetPointerCount() const; | 39 size_t GetPointerCount() const; |
| 38 int GetPointerId(size_t pointer_index) const; | 40 int GetPointerId(size_t pointer_index) const; |
| 39 float GetPressure() const { return GetPressure(0); } | 41 float GetPressure() const { return GetPressure(0); } |
| 40 float GetPressure(size_t pointer_index) const; | 42 float GetPressure(size_t pointer_index) const; |
| 41 float GetX() const { return GetX(0); } | 43 float GetX() const { return GetX(0); } |
| 42 float GetY() const { return GetY(0); } | 44 float GetY() const { return GetY(0); } |
| 43 float GetX(size_t pointer_index) const; | 45 float GetX(size_t pointer_index) const; |
| 44 float GetY(size_t pointer_index) const; | 46 float GetY(size_t pointer_index) const; |
| 45 float GetRawX() const { return GetX(); } | 47 float GetRawX() const { return GetX(); } |
| 46 float GetRawY() const { return GetY(); } | 48 float GetRawY() const { return GetY(); } |
| 47 float GetTouchMajor() const { return GetTouchMajor(0); } | 49 float GetTouchMajor() const { return GetTouchMajor(0); } |
| 48 float GetTouchMajor(size_t pointer_index) const; | 50 float GetTouchMajor(size_t pointer_index) const; |
| 49 float GetTouchMinor() const { return GetTouchMinor(0); } | 51 float GetTouchMinor() const { return GetTouchMinor(0); } |
| 50 float GetTouchMinor(size_t pointer_index) const; | 52 float GetTouchMinor(size_t pointer_index) const; |
| 51 float GetOrientation() const; | 53 float GetOrientation() const; |
| 52 base::TimeTicks GetEventTime() const; | 54 base::TimeTicks GetEventTime() const; |
| 53 base::TimeTicks GetDownTime() const; | 55 base::TimeTicks GetDownTime() const; |
| 54 | 56 |
| 55 size_t GetHistorySize() const; | 57 size_t GetHistorySize() const; |
| 56 base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; | 58 base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; |
| 57 float GetHistoricalTouchMajor(size_t pointer_index, | 59 float GetHistoricalTouchMajor(size_t pointer_index, |
| 58 size_t historical_index) const; | 60 size_t historical_index) const; |
| 59 float GetHistoricalX(size_t pointer_index, size_t historical_index) const; | 61 float GetHistoricalX(size_t pointer_index, size_t historical_index) const; |
| 60 float GetHistoricalY(size_t pointer_index, size_t historical_index) const; | 62 float GetHistoricalY(size_t pointer_index, size_t historical_index) const; |
| 61 | 63 |
| 62 static bool RegisterMotionEventAndroid(JNIEnv* env); | 64 static bool RegisterMotionEventAndroid(JNIEnv* env); |
| 63 | 65 |
| 64 static scoped_ptr<MotionEventAndroid> Obtain(const MotionEventAndroid& event); | 66 static base::android::ScopedJavaLocalRef<jobject> Obtain( |
| 65 static scoped_ptr<MotionEventAndroid> Obtain(base::TimeTicks down_time, | 67 const MotionEventAndroid& event); |
| 66 base::TimeTicks event_time, | 68 static base::android::ScopedJavaLocalRef<jobject> Obtain( |
| 67 Action action, | 69 base::TimeTicks down_time, |
| 68 float x, | 70 base::TimeTicks event_time, |
| 69 float y); | 71 Action action, |
| 72 float x, |
| 73 float y); |
| 70 | 74 |
| 71 private: | 75 private: |
| 72 MotionEventAndroid(const base::android::ScopedJavaLocalRef<jobject>& event, | 76 MotionEventAndroid(); |
| 73 bool should_recycle); | |
| 74 | 77 |
| 75 // The Java reference to the underlying MotionEvent. | 78 // The Java reference to the underlying MotionEvent. |
| 76 base::android::ScopedJavaGlobalRef<jobject> event_; | 79 base::android::ScopedJavaGlobalRef<jobject> event_; |
| 77 | 80 |
| 81 base::TimeTicks cached_time_; |
| 82 Action cached_action_; |
| 83 size_t cached_pointer_count_; |
| 84 size_t cached_history_size_; |
| 85 int cached_action_index_; |
| 86 float cached_x_; |
| 87 float cached_y_; |
| 88 |
| 78 // Whether |event_| should be recycled on destruction. This will only be true | 89 // Whether |event_| should be recycled on destruction. This will only be true |
| 79 // for those events generated via |Obtain(...)|. | 90 // for those events generated via |Obtain(...)|. |
| 80 bool should_recycle_; | 91 bool should_recycle_; |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(MotionEventAndroid); | |
| 83 }; | 92 }; |
| 84 | 93 |
| 85 } // namespace content | 94 } // namespace content |
| 86 | 95 |
| 87 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ | 96 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOTION_EVENT_ANDROID_H_ |
| OLD | NEW |