summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-08-23 12:01:46 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-23 12:01:46 -0700
commita931e9a15840f9074f1803b5adb2f23b40a1ab1b (patch)
tree02b03b74d062a389551478b75871ce5d3563c470
parentd218526bf6e2309580a4640e9591480a5c159c5f (diff)
parent6bacd9c6fb799f185be580a0596214b0ce998999 (diff)
downloadframeworks_base-a931e9a15840f9074f1803b5adb2f23b40a1ab1b.zip
frameworks_base-a931e9a15840f9074f1803b5adb2f23b40a1ab1b.tar.gz
frameworks_base-a931e9a15840f9074f1803b5adb2f23b40a1ab1b.tar.bz2
am 6bacd9c6: am 2f6d975b: Minor MotionEvent optimization.
Merge commit '6bacd9c6fb799f185be580a0596214b0ce998999' * commit '6bacd9c6fb799f185be580a0596214b0ce998999': Minor MotionEvent optimization.
-rw-r--r--core/java/android/view/MotionEvent.java63
1 files changed, 34 insertions, 29 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index 1328525..74318ba 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1319,21 +1319,24 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* @param y New absolute Y location.
*/
public final void setLocation(float x, float y) {
- mXOffset = x - mDataSamples[mLastDataSampleIndex + SAMPLE_X];
- mYOffset = y - mDataSamples[mLastDataSampleIndex + SAMPLE_Y];
+ final float[] dataSamples = mDataSamples;
+ final int lastDataSampleIndex = mLastDataSampleIndex;
+ mXOffset = x - dataSamples[lastDataSampleIndex + SAMPLE_X];
+ mYOffset = y - dataSamples[lastDataSampleIndex + SAMPLE_Y];
}
private final void getPointerCoordsAtSampleIndex(int sampleIndex,
PointerCoords outPointerCoords) {
- outPointerCoords.x = mDataSamples[sampleIndex + SAMPLE_X] + mXOffset;
- outPointerCoords.y = mDataSamples[sampleIndex + SAMPLE_Y] + mYOffset;
- outPointerCoords.pressure = mDataSamples[sampleIndex + SAMPLE_PRESSURE];
- outPointerCoords.size = mDataSamples[sampleIndex + SAMPLE_SIZE];
- outPointerCoords.touchMajor = mDataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR];
- outPointerCoords.touchMinor = mDataSamples[sampleIndex + SAMPLE_TOUCH_MINOR];
- outPointerCoords.toolMajor = mDataSamples[sampleIndex + SAMPLE_TOOL_MAJOR];
- outPointerCoords.toolMinor = mDataSamples[sampleIndex + SAMPLE_TOOL_MINOR];
- outPointerCoords.orientation = mDataSamples[sampleIndex + SAMPLE_ORIENTATION];
+ final float[] dataSamples = mDataSamples;
+ outPointerCoords.x = dataSamples[sampleIndex + SAMPLE_X] + mXOffset;
+ outPointerCoords.y = dataSamples[sampleIndex + SAMPLE_Y] + mYOffset;
+ outPointerCoords.pressure = dataSamples[sampleIndex + SAMPLE_PRESSURE];
+ outPointerCoords.size = dataSamples[sampleIndex + SAMPLE_SIZE];
+ outPointerCoords.touchMajor = dataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR];
+ outPointerCoords.touchMinor = dataSamples[sampleIndex + SAMPLE_TOUCH_MINOR];
+ outPointerCoords.toolMajor = dataSamples[sampleIndex + SAMPLE_TOOL_MAJOR];
+ outPointerCoords.toolMinor = dataSamples[sampleIndex + SAMPLE_TOOL_MINOR];
+ outPointerCoords.orientation = dataSamples[sampleIndex + SAMPLE_ORIENTATION];
}
private final void setPointerCoordsAtSampleIndex(int sampleIndex,
@@ -1347,28 +1350,30 @@ public final class MotionEvent extends InputEvent implements Parcelable {
private final void setPointerCoordsAtSampleIndex(int sampleIndex,
PointerCoords pointerCoords) {
- mDataSamples[sampleIndex + SAMPLE_X] = pointerCoords.x - mXOffset;
- mDataSamples[sampleIndex + SAMPLE_Y] = pointerCoords.y - mYOffset;
- mDataSamples[sampleIndex + SAMPLE_PRESSURE] = pointerCoords.pressure;
- mDataSamples[sampleIndex + SAMPLE_SIZE] = pointerCoords.size;
- mDataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR] = pointerCoords.touchMajor;
- mDataSamples[sampleIndex + SAMPLE_TOUCH_MINOR] = pointerCoords.touchMinor;
- mDataSamples[sampleIndex + SAMPLE_TOOL_MAJOR] = pointerCoords.toolMajor;
- mDataSamples[sampleIndex + SAMPLE_TOOL_MINOR] = pointerCoords.toolMinor;
- mDataSamples[sampleIndex + SAMPLE_ORIENTATION] = pointerCoords.orientation;
+ final float[] dataSamples = mDataSamples;
+ dataSamples[sampleIndex + SAMPLE_X] = pointerCoords.x - mXOffset;
+ dataSamples[sampleIndex + SAMPLE_Y] = pointerCoords.y - mYOffset;
+ dataSamples[sampleIndex + SAMPLE_PRESSURE] = pointerCoords.pressure;
+ dataSamples[sampleIndex + SAMPLE_SIZE] = pointerCoords.size;
+ dataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR] = pointerCoords.touchMajor;
+ dataSamples[sampleIndex + SAMPLE_TOUCH_MINOR] = pointerCoords.touchMinor;
+ dataSamples[sampleIndex + SAMPLE_TOOL_MAJOR] = pointerCoords.toolMajor;
+ dataSamples[sampleIndex + SAMPLE_TOOL_MINOR] = pointerCoords.toolMinor;
+ dataSamples[sampleIndex + SAMPLE_ORIENTATION] = pointerCoords.orientation;
}
private final void setPointerCoordsAtSampleIndex(int sampleIndex,
float x, float y, float pressure, float size) {
- mDataSamples[sampleIndex + SAMPLE_X] = x - mXOffset;
- mDataSamples[sampleIndex + SAMPLE_Y] = y - mYOffset;
- mDataSamples[sampleIndex + SAMPLE_PRESSURE] = pressure;
- mDataSamples[sampleIndex + SAMPLE_SIZE] = size;
- mDataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR] = pressure;
- mDataSamples[sampleIndex + SAMPLE_TOUCH_MINOR] = pressure;
- mDataSamples[sampleIndex + SAMPLE_TOOL_MAJOR] = size;
- mDataSamples[sampleIndex + SAMPLE_TOOL_MINOR] = size;
- mDataSamples[sampleIndex + SAMPLE_ORIENTATION] = 0;
+ final float[] dataSamples = mDataSamples;
+ dataSamples[sampleIndex + SAMPLE_X] = x - mXOffset;
+ dataSamples[sampleIndex + SAMPLE_Y] = y - mYOffset;
+ dataSamples[sampleIndex + SAMPLE_PRESSURE] = pressure;
+ dataSamples[sampleIndex + SAMPLE_SIZE] = size;
+ dataSamples[sampleIndex + SAMPLE_TOUCH_MAJOR] = pressure;
+ dataSamples[sampleIndex + SAMPLE_TOUCH_MINOR] = pressure;
+ dataSamples[sampleIndex + SAMPLE_TOOL_MAJOR] = size;
+ dataSamples[sampleIndex + SAMPLE_TOOL_MINOR] = size;
+ dataSamples[sampleIndex + SAMPLE_ORIENTATION] = 0;
}
private final void incrementNumSamplesAndReserveStorage(int dataSampleStride) {