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

Unified Diff: content/browser/renderer_host/input/motion_event_android.h

Issue 189693002: [Android] Cache additional MotionEvent bits in MotionEventAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final cleanup Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/motion_event_android.h
diff --git a/content/browser/renderer_host/input/motion_event_android.h b/content/browser/renderer_host/input/motion_event_android.h
index 4b6299b1b97e300100b44c1944517df797df810a..8f81a8a4d379575599328fc176bdf6522a247f3b 100644
--- a/content/browser/renderer_host/input/motion_event_android.h
+++ b/content/browser/renderer_host/input/motion_event_android.h
@@ -11,13 +11,30 @@
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "ui/events/gesture_detection/motion_event.h"
+#include "ui/gfx/geometry/point_f.h"
namespace content {
// Implementation of ui::MotionEvent wrapping a native Android MotionEvent.
class MotionEventAndroid : public ui::MotionEvent {
public:
- MotionEventAndroid(JNIEnv* env, jobject event, bool recycle);
+ // Forcing the caller to provide all cached values upon construction
+ // eliminates the need to perform a JNI call to retrieve values individually.
+ MotionEventAndroid(JNIEnv* env,
+ jobject event,
+ jlong time_ms,
+ jint android_action,
+ jint pointer_count,
+ jint history_size,
+ jint action_index,
+ jfloat pos_x_0,
+ jfloat pos_y_0,
+ jfloat pos_x_1,
+ jfloat pos_y_1,
+ jint pointer_id_0,
+ jint pointer_id_1,
+ jfloat touch_major_0,
+ jfloat touch_major_1);
virtual ~MotionEventAndroid();
// ui::MotionEvent methods.
@@ -64,9 +81,15 @@ class MotionEventAndroid : public ui::MotionEvent {
private:
MotionEventAndroid();
+ MotionEventAndroid(JNIEnv* env, jobject event);
MotionEventAndroid(const MotionEventAndroid&);
MotionEventAndroid& operator=(const MotionEventAndroid&);
+ // Cache pointer coords, id's and major lengths for the most common
+ // touch-related scenarios, i.e., scrolling and pinching. This prevents
+ // redundant JNI fetches for the same bits.
+ enum { MAX_POINTERS_TO_CACHE = 2 };
+
// The Java reference to the underlying MotionEvent.
base::android::ScopedJavaGlobalRef<jobject> event_;
@@ -75,8 +98,9 @@ class MotionEventAndroid : public ui::MotionEvent {
size_t cached_pointer_count_;
size_t cached_history_size_;
int cached_action_index_;
- float cached_x_;
- float cached_y_;
+ gfx::PointF cached_positions_[MAX_POINTERS_TO_CACHE];
+ int cached_pointer_ids_[MAX_POINTERS_TO_CACHE];
+ float cached_touch_majors_[MAX_POINTERS_TO_CACHE];
// Whether |event_| should be recycled on destruction. This will only be true
// for those events generated via |Obtain(...)|.
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | content/browser/renderer_host/input/motion_event_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698