Skip to content

Commit c267610

Browse files
jreckAndroid (Google) Code Review
authored andcommitted
Merge "New WebView input dispatcher."
2 parents 7ff25dd + 9d3bdbd commit c267610

File tree

4 files changed

+1380
-1001
lines changed

4 files changed

+1380
-1001
lines changed

core/java/android/view/MotionEvent.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,67 @@ public final void addBatch(long eventTime, PointerCoords[] pointerCoords, int me
27142714
nativeAddBatch(mNativePtr, eventTime * NS_PER_MS, pointerCoords, metaState);
27152715
}
27162716

2717+
/**
2718+
* Adds all of the movement samples of the specified event to this one if
2719+
* it is compatible. To be compatible, the event must have the same device id,
2720+
* source, action, flags, pointer count, pointer properties.
2721+
*
2722+
* Only applies to {@link #ACTION_MOVE} or {@link #ACTION_HOVER_MOVE} events.
2723+
*
2724+
* @param event The event whose movements samples should be added to this one
2725+
* if possible.
2726+
* @return True if batching was performed or false if batching was not possible.
2727+
* @hide
2728+
*/
2729+
public final boolean addBatch(MotionEvent event) {
2730+
final int action = nativeGetAction(mNativePtr);
2731+
if (action != ACTION_MOVE && action != ACTION_HOVER_MOVE) {
2732+
return false;
2733+
}
2734+
if (action != nativeGetAction(event.mNativePtr)) {
2735+
return false;
2736+
}
2737+
2738+
if (nativeGetDeviceId(mNativePtr) != nativeGetDeviceId(event.mNativePtr)
2739+
|| nativeGetSource(mNativePtr) != nativeGetSource(event.mNativePtr)
2740+
|| nativeGetFlags(mNativePtr) != nativeGetFlags(event.mNativePtr)) {
2741+
return false;
2742+
}
2743+
2744+
final int pointerCount = nativeGetPointerCount(mNativePtr);
2745+
if (pointerCount != nativeGetPointerCount(event.mNativePtr)) {
2746+
return false;
2747+
}
2748+
2749+
synchronized (gSharedTempLock) {
2750+
ensureSharedTempPointerCapacity(Math.max(pointerCount, 2));
2751+
final PointerProperties[] pp = gSharedTempPointerProperties;
2752+
final PointerCoords[] pc = gSharedTempPointerCoords;
2753+
2754+
for (int i = 0; i < pointerCount; i++) {
2755+
nativeGetPointerProperties(mNativePtr, i, pp[0]);
2756+
nativeGetPointerProperties(event.mNativePtr, i, pp[1]);
2757+
if (!pp[0].equals(pp[1])) {
2758+
return false;
2759+
}
2760+
}
2761+
2762+
final int metaState = nativeGetMetaState(event.mNativePtr);
2763+
final int historySize = nativeGetHistorySize(event.mNativePtr);
2764+
for (int h = 0; h <= historySize; h++) {
2765+
final int historyPos = (h == historySize ? HISTORY_CURRENT : h);
2766+
2767+
for (int i = 0; i < pointerCount; i++) {
2768+
nativeGetPointerCoords(event.mNativePtr, i, historyPos, pc[i]);
2769+
}
2770+
2771+
final long eventTimeNanos = nativeGetEventTimeNanos(event.mNativePtr, historyPos);
2772+
nativeAddBatch(mNativePtr, eventTimeNanos, pc, metaState);
2773+
}
2774+
}
2775+
return true;
2776+
}
2777+
27172778
/**
27182779
* Returns true if all points in the motion event are completely within the specified bounds.
27192780
* @hide
@@ -3416,5 +3477,22 @@ public void copyFrom(PointerProperties other) {
34163477
id = other.id;
34173478
toolType = other.toolType;
34183479
}
3480+
3481+
@Override
3482+
public boolean equals(Object other) {
3483+
if (other instanceof PointerProperties) {
3484+
return equals((PointerProperties)other);
3485+
}
3486+
return false;
3487+
}
3488+
3489+
private boolean equals(PointerProperties other) {
3490+
return other != null && id == other.id && toolType == other.toolType;
3491+
}
3492+
3493+
@Override
3494+
public int hashCode() {
3495+
return id | (toolType << 8);
3496+
}
34193497
}
34203498
}

0 commit comments

Comments
 (0)