diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-04-27 15:13:25 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-04-27 15:58:42 -0700 |
commit | 771526c88f5cc4b56a41cb12aa06a28d377a07d5 (patch) | |
tree | 71c36f271192ee66f069f0d1130a73e91b8302b9 /core/java | |
parent | 330314c6fb7c178c0f0da65d6aa8c9e7d3004568 (diff) | |
download | frameworks_base-771526c88f5cc4b56a41cb12aa06a28d377a07d5.zip frameworks_base-771526c88f5cc4b56a41cb12aa06a28d377a07d5.tar.gz frameworks_base-771526c88f5cc4b56a41cb12aa06a28d377a07d5.tar.bz2 |
Resample touch events on frame boundaries.
Bug: 6375101
Change-Id: I8774e366306bb2b6b4e42b913525bf25b0380ec3
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/view/InputEventReceiver.java | 12 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 6 |
2 files changed, 11 insertions, 7 deletions
diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java index 6a457ec..9c56782 100644 --- a/core/java/android/view/InputEventReceiver.java +++ b/core/java/android/view/InputEventReceiver.java @@ -46,7 +46,8 @@ public abstract class InputEventReceiver { InputChannel inputChannel, MessageQueue messageQueue); private static native void nativeDispose(int receiverPtr); private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled); - private static native void nativeConsumeBatchedInputEvents(int receiverPtr); + private static native void nativeConsumeBatchedInputEvents(int receiverPtr, + long frameTimeNanos); /** * Creates an input event receiver bound to the specified input channel. @@ -114,7 +115,7 @@ public abstract class InputEventReceiver { * immediately (such as a pointer up event). */ public void onBatchedInputEventPending() { - consumeBatchedInputEvents(); + consumeBatchedInputEvents(-1); } /** @@ -150,13 +151,16 @@ public abstract class InputEventReceiver { * * This method forces all batched input events to be delivered immediately. * Should be called just before animating or drawing a new frame in the UI. + * + * @param frameTimeNanos The time in the {@link System#nanoTime()} time base + * when the current display frame started rendering, or -1 if unknown. */ - public final void consumeBatchedInputEvents() { + public final void consumeBatchedInputEvents(long frameTimeNanos) { if (mReceiverPtr == 0) { Log.w(TAG, "Attempted to consume batched input events but the input event " + "receiver has already been disposed."); } else { - nativeConsumeBatchedInputEvents(mReceiverPtr); + nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos); } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index afa9b12..1ee7934 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -4204,11 +4204,11 @@ public final class ViewRootImpl implements ViewParent, } } - void doConsumeBatchedInput() { + void doConsumeBatchedInput(long frameTimeNanos) { if (mConsumeBatchedInputScheduled) { mConsumeBatchedInputScheduled = false; if (mInputEventReceiver != null) { - mInputEventReceiver.consumeBatchedInputEvents(); + mInputEventReceiver.consumeBatchedInputEvents(frameTimeNanos); } doProcessInputEvents(); } @@ -4248,7 +4248,7 @@ public final class ViewRootImpl implements ViewParent, final class ConsumeBatchedInputRunnable implements Runnable { @Override public void run() { - doConsumeBatchedInput(); + doConsumeBatchedInput(mChoreographer.getFrameTimeNanos()); } } final ConsumeBatchedInputRunnable mConsumedBatchedInputRunnable = |