diff options
| author | Jeff Brown <jeffbrown@google.com> | 2010-08-23 12:01:02 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2010-09-30 11:52:48 -0700 |
| commit | 20e987bfc35d0ae6cb6344ead65ed44ee7cf8750 (patch) | |
| tree | 7ae616a2c7a21a09950760babb0b980c40e4651a /core/java/android/view/MotionEvent.java | |
| parent | 4f4870f0bb7009e6d974b5d2c371924214684735 (diff) | |
Add MotionEvent Matrix transformations.
Fixed issued in ViewGroup's transformation of MotionEvents to ensure
that the entire historical trace is transformed, not just the current
pointer.
Simplified the code in ViewGroup for splitting events across Views.
The new code also handles the case where some pointers are dispatched
to the ViewGroup in addition to its children whereas the previous
code would drop some pointers on the floor.
Change-Id: I56ac31903e1de8a9c376d9c935b7217b0c42d93e
Diffstat (limited to 'core/java/android/view/MotionEvent.java')
| -rw-r--r-- | core/java/android/view/MotionEvent.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 6705596854a1..dfbe65c8e307 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -16,6 +16,7 @@ package android.view; +import android.graphics.Matrix; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; @@ -347,6 +348,8 @@ public final class MotionEvent extends InputEvent implements Parcelable { private RuntimeException mRecycledLocation; private boolean mRecycled; + private native void nativeTransform(Matrix matrix); + private MotionEvent(int pointerCount, int sampleCount) { mPointerIdentifiers = new int[pointerCount]; mDataSamples = new float[pointerCount * sampleCount * NUM_SAMPLE_DATA]; @@ -1413,6 +1416,19 @@ public final class MotionEvent extends InputEvent implements Parcelable { mYOffset = y - dataSamples[lastDataSampleIndex + SAMPLE_Y]; } + /** + * Applies a transformation matrix to all of the points in the event. + * + * @param matrix The transformation matrix to apply. + */ + public final void transform(Matrix matrix) { + if (matrix == null) { + throw new IllegalArgumentException("matrix must not be null"); + } + + nativeTransform(matrix); + } + private final void getPointerCoordsAtSampleIndex(int sampleIndex, PointerCoords outPointerCoords) { final float[] dataSamples = mDataSamples; |
