am 2554fe1e: am b922da84: Merge "Fix bimanual gesture preview trail" into jb-mr1-dev
* commit '2554fe1ed1a3e78f199964cdd607d82e004b2ed4': Fix bimanual gesture preview trailmain
commit
34e9791dbd
|
@ -573,6 +573,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private void endBatchInput() {
|
private void endBatchInput() {
|
||||||
synchronized (sAggregratedPointers) {
|
synchronized (sAggregratedPointers) {
|
||||||
mGestureStrokeWithPreviewTrail.appendAllBatchPoints(sAggregratedPointers);
|
mGestureStrokeWithPreviewTrail.appendAllBatchPoints(sAggregratedPointers);
|
||||||
|
mGestureStrokeWithPreviewTrail.reset();
|
||||||
if (getActivePointerTrackerCount() == 1) {
|
if (getActivePointerTrackerCount() == 1) {
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, "onEndBatchInput: batchPoints="
|
Log.d(TAG, "onEndBatchInput: batchPoints="
|
||||||
|
|
|
@ -33,15 +33,10 @@ final class GesturePreviewTrail {
|
||||||
private final ResizableIntArray mYCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
|
private final ResizableIntArray mYCoordinates = new ResizableIntArray(DEFAULT_CAPACITY);
|
||||||
private final ResizableIntArray mEventTimes = new ResizableIntArray(DEFAULT_CAPACITY);
|
private final ResizableIntArray mEventTimes = new ResizableIntArray(DEFAULT_CAPACITY);
|
||||||
private int mCurrentStrokeId = -1;
|
private int mCurrentStrokeId = -1;
|
||||||
private long mCurrentDownTime;
|
// The wall time of the zero value in {@link #mEventTimes}
|
||||||
|
private long mCurrentTimeBase;
|
||||||
private int mTrailStartIndex;
|
private int mTrailStartIndex;
|
||||||
|
|
||||||
private final static Xfermode PORTER_DUFF_MODE_SRC =
|
|
||||||
new PorterDuffXfermode(PorterDuff.Mode.SRC);
|
|
||||||
|
|
||||||
// Use this value as imaginary zero because x-coordinates may be zero.
|
|
||||||
private static final int DOWN_EVENT_MARKER = -128;
|
|
||||||
|
|
||||||
static final class Params {
|
static final class Params {
|
||||||
public final int mTrailColor;
|
public final int mTrailColor;
|
||||||
public final float mTrailStartWidth;
|
public final float mTrailStartWidth;
|
||||||
|
@ -69,6 +64,9 @@ final class GesturePreviewTrail {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use this value as imaginary zero because x-coordinates may be zero.
|
||||||
|
private static final int DOWN_EVENT_MARKER = -128;
|
||||||
|
|
||||||
private static int markAsDownEvent(final int xCoord) {
|
private static int markAsDownEvent(final int xCoord) {
|
||||||
return DOWN_EVENT_MARKER - xCoord;
|
return DOWN_EVENT_MARKER - xCoord;
|
||||||
}
|
}
|
||||||
|
@ -83,26 +81,23 @@ final class GesturePreviewTrail {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStroke(final GestureStrokeWithPreviewTrail stroke, final long downTime) {
|
public void addStroke(final GestureStrokeWithPreviewTrail stroke, final long downTime) {
|
||||||
final int strokeId = stroke.getGestureStrokeId();
|
|
||||||
final boolean isNewStroke = strokeId != mCurrentStrokeId;
|
|
||||||
final int trailSize = mEventTimes.getLength();
|
final int trailSize = mEventTimes.getLength();
|
||||||
stroke.appendPreviewStroke(mEventTimes, mXCoordinates, mYCoordinates);
|
stroke.appendPreviewStroke(mEventTimes, mXCoordinates, mYCoordinates);
|
||||||
final int newTrailSize = mEventTimes.getLength();
|
if (mEventTimes.getLength() == trailSize) {
|
||||||
if (stroke.getGestureStrokePreviewSize() == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isNewStroke) {
|
final int[] eventTimes = mEventTimes.getPrimitiveArray();
|
||||||
final int elapsedTime = (int)(downTime - mCurrentDownTime);
|
final int strokeId = stroke.getGestureStrokeId();
|
||||||
final int[] eventTimes = mEventTimes.getPrimitiveArray();
|
if (strokeId != mCurrentStrokeId) {
|
||||||
|
final int elapsedTime = (int)(downTime - mCurrentTimeBase);
|
||||||
for (int i = mTrailStartIndex; i < trailSize; i++) {
|
for (int i = mTrailStartIndex; i < trailSize; i++) {
|
||||||
|
// Decay the previous strokes' event times.
|
||||||
eventTimes[i] -= elapsedTime;
|
eventTimes[i] -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
final int[] xCoords = mXCoordinates.getPrimitiveArray();
|
||||||
if (newTrailSize > trailSize) {
|
final int downIndex = trailSize;
|
||||||
final int[] xCoords = mXCoordinates.getPrimitiveArray();
|
xCoords[downIndex] = markAsDownEvent(xCoords[downIndex]);
|
||||||
xCoords[trailSize] = markAsDownEvent(xCoords[trailSize]);
|
mCurrentTimeBase = downTime - eventTimes[downIndex];
|
||||||
}
|
|
||||||
mCurrentDownTime = downTime;
|
|
||||||
mCurrentStrokeId = strokeId;
|
mCurrentStrokeId = strokeId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +118,9 @@ final class GesturePreviewTrail {
|
||||||
/ params.mTrailLingerDuration, 0.0f);
|
/ params.mTrailLingerDuration, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final static Xfermode PORTER_DUFF_MODE_SRC =
|
||||||
|
new PorterDuffXfermode(PorterDuff.Mode.SRC);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw gesture preview trail
|
* Draw gesture preview trail
|
||||||
* @param canvas The canvas to draw the gesture preview trail
|
* @param canvas The canvas to draw the gesture preview trail
|
||||||
|
@ -139,7 +137,7 @@ final class GesturePreviewTrail {
|
||||||
final int[] eventTimes = mEventTimes.getPrimitiveArray();
|
final int[] eventTimes = mEventTimes.getPrimitiveArray();
|
||||||
final int[] xCoords = mXCoordinates.getPrimitiveArray();
|
final int[] xCoords = mXCoordinates.getPrimitiveArray();
|
||||||
final int[] yCoords = mYCoordinates.getPrimitiveArray();
|
final int[] yCoords = mYCoordinates.getPrimitiveArray();
|
||||||
final int sinceDown = (int)(SystemClock.uptimeMillis() - mCurrentDownTime);
|
final int sinceDown = (int)(SystemClock.uptimeMillis() - mCurrentTimeBase);
|
||||||
int startIndex;
|
int startIndex;
|
||||||
for (startIndex = mTrailStartIndex; startIndex < trailSize; startIndex++) {
|
for (startIndex = mTrailStartIndex; startIndex < trailSize; startIndex++) {
|
||||||
final int elapsedTime = sinceDown - eventTimes[startIndex];
|
final int elapsedTime = sinceDown - eventTimes[startIndex];
|
||||||
|
|
|
@ -158,7 +158,6 @@ public class PreviewPlacerView extends RelativeLayout {
|
||||||
|
|
||||||
final Paint textPaint = new Paint();
|
final Paint textPaint = new Paint();
|
||||||
textPaint.setAntiAlias(true);
|
textPaint.setAntiAlias(true);
|
||||||
textPaint.setStyle(Paint.Style.FILL);
|
|
||||||
textPaint.setTextAlign(Align.CENTER);
|
textPaint.setTextAlign(Align.CENTER);
|
||||||
textPaint.setTextSize(gestureFloatingPreviewTextSize);
|
textPaint.setTextSize(gestureFloatingPreviewTextSize);
|
||||||
mTextPaint = textPaint;
|
mTextPaint = textPaint;
|
||||||
|
|
Loading…
Reference in New Issue