summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-03-21 19:49:27 -0700
committerJeff Brown <jeffbrown@google.com>2012-03-21 19:49:54 -0700
commit9ea77fc821918ea562ff4907945b865e39e0201a (patch)
tree87deeb842bef0a836d25fa94ab816b2ab371be0e /core/java
parente67ca420e4eb6ddf8ceefeb0d9dcc47d9ca189fc (diff)
downloadframeworks_base-9ea77fc821918ea562ff4907945b865e39e0201a.zip
frameworks_base-9ea77fc821918ea562ff4907945b865e39e0201a.tar.gz
frameworks_base-9ea77fc821918ea562ff4907945b865e39e0201a.tar.bz2
Avoid calling into JNI if not needed.
Short-circuit a few MotionEvent JNI calls in simple cases. Change-Id: I6c97c06b5a5fd203a423dc88f428637b9dec71ae
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/MotionEvent.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 92e8f4e..77fd8d2 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1654,14 +1654,22 @@ public final class MotionEvent extends InputEvent implements Parcelable {
}
}
}
-
+
/**
- * Scales down the coordination of this event by the given scale.
+ * Applies a scale factor to all points within this event.
+ *
+ * This method is used to adjust touch events to simulate different density
+ * displays for compatibility mode. The values returned by {@link #getRawX()},
+ * {@link #getRawY()}, {@link #getXPrecision()} and {@link #getYPrecision()}
+ * are also affected by the scale factor.
*
+ * @param scale The scale factor to apply.
* @hide
*/
public final void scale(float scale) {
- nativeScale(mNativePtr, scale);
+ if (scale != 1.0f) {
+ nativeScale(mNativePtr, scale);
+ }
}
/** {@inheritDoc} */
@@ -2631,7 +2639,9 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* @param deltaY Amount to add to the current Y coordinate of the event.
*/
public final void offsetLocation(float deltaX, float deltaY) {
- nativeOffsetLocation(mNativePtr, deltaX, deltaY);
+ if (deltaX != 0.0f || deltaY != 0.0f) {
+ nativeOffsetLocation(mNativePtr, deltaX, deltaY);
+ }
}
/**
@@ -2644,7 +2654,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
public final void setLocation(float x, float y) {
float oldX = getX();
float oldY = getY();
- nativeOffsetLocation(mNativePtr, x - oldX, y - oldY);
+ offsetLocation(x - oldX, y - oldY);
}
/**