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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -5760,6 +5760,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the given point, in local coordinates is inside the view.
|
||||
*/
|
||||
/*package*/ final boolean pointInView(float localX, float localY) {
|
||||
return localX >= 0 && localX < (mRight - mLeft)
|
||||
&& localY >= 0 && localY < (mBottom - mTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to determine whether the given point, in local coordinates,
|
||||
* is inside the view, where the area of the view is expanded by the slop factor.
|
||||
@@ -5767,7 +5775,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
|
||||
* is still within the view.
|
||||
*/
|
||||
private boolean pointInView(float localX, float localY, float slop) {
|
||||
return localX > -slop && localY > -slop && localX < ((mRight - mLeft) + slop) &&
|
||||
return localX >= -slop && localY >= -slop && localX < ((mRight - mLeft) + slop) &&
|
||||
localY < ((mBottom - mTop) + slop);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user