am fe49ca61: am 1451a0fb: Merge "Optimize gesture preview trail drawing a bit" into jb-mr1-dev
* commit 'fe49ca61f949aedc4492c42f213ae650df8ae938': Optimize gesture preview trail drawing a bitmain
commit
a4862f3cf5
|
@ -51,7 +51,7 @@
|
||||||
<integer name="config_key_preview_linger_timeout">70</integer>
|
<integer name="config_key_preview_linger_timeout">70</integer>
|
||||||
<integer name="config_gesture_floating_preview_text_linger_timeout">200</integer>
|
<integer name="config_gesture_floating_preview_text_linger_timeout">200</integer>
|
||||||
<integer name="config_gesture_preview_trail_fadeout_start_delay">100</integer>
|
<integer name="config_gesture_preview_trail_fadeout_start_delay">100</integer>
|
||||||
<integer name="config_gesture_preview_trail_fadeout_duration">1000</integer>
|
<integer name="config_gesture_preview_trail_fadeout_duration">800</integer>
|
||||||
<integer name="config_gesture_preview_trail_update_interval">20</integer>
|
<integer name="config_gesture_preview_trail_update_interval">20</integer>
|
||||||
<!--
|
<!--
|
||||||
Configuration for MainKeyboardView
|
Configuration for MainKeyboardView
|
||||||
|
|
|
@ -32,6 +32,7 @@ class GesturePreviewTrail {
|
||||||
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;
|
private long mCurrentDownTime;
|
||||||
|
private int mTrailStartIndex;
|
||||||
|
|
||||||
// Use this value as imaginary zero because x-coordinates may be zero.
|
// Use this value as imaginary zero because x-coordinates may be zero.
|
||||||
private static final int DOWN_EVENT_MARKER = -128;
|
private static final int DOWN_EVENT_MARKER = -128;
|
||||||
|
@ -80,7 +81,7 @@ class GesturePreviewTrail {
|
||||||
if (isNewStroke) {
|
if (isNewStroke) {
|
||||||
final int elapsedTime = (int)(downTime - mCurrentDownTime);
|
final int elapsedTime = (int)(downTime - mCurrentDownTime);
|
||||||
final int[] eventTimes = mEventTimes.getPrimitiveArray();
|
final int[] eventTimes = mEventTimes.getPrimitiveArray();
|
||||||
for (int i = 0; i < trailSize; i++) {
|
for (int i = mTrailStartIndex; i < trailSize; i++) {
|
||||||
eventTimes[i] -= elapsedTime;
|
eventTimes[i] -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,13 +123,14 @@ class GesturePreviewTrail {
|
||||||
final int lingeringDuration = mPreviewParams.mFadeoutStartDelay
|
final int lingeringDuration = mPreviewParams.mFadeoutStartDelay
|
||||||
+ mPreviewParams.mFadeoutDuration;
|
+ mPreviewParams.mFadeoutDuration;
|
||||||
int startIndex;
|
int startIndex;
|
||||||
for (startIndex = 0; startIndex < trailSize; startIndex++) {
|
for (startIndex = mTrailStartIndex; startIndex < trailSize; startIndex++) {
|
||||||
final int elapsedTime = sinceDown - eventTimes[startIndex];
|
final int elapsedTime = sinceDown - eventTimes[startIndex];
|
||||||
// Skip too old trail points.
|
// Skip too old trail points.
|
||||||
if (elapsedTime < lingeringDuration) {
|
if (elapsedTime < lingeringDuration) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mTrailStartIndex = startIndex;
|
||||||
|
|
||||||
if (startIndex < trailSize) {
|
if (startIndex < trailSize) {
|
||||||
int lastX = getXCoordValue(xCoords[startIndex]);
|
int lastX = getXCoordValue(xCoords[startIndex]);
|
||||||
|
@ -147,15 +149,18 @@ class GesturePreviewTrail {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement ring buffer to avoid moving points.
|
|
||||||
// Discard faded out points.
|
|
||||||
final int newSize = trailSize - startIndex;
|
final int newSize = trailSize - startIndex;
|
||||||
|
if (newSize < startIndex) {
|
||||||
|
mTrailStartIndex = 0;
|
||||||
|
if (newSize > 0) {
|
||||||
System.arraycopy(eventTimes, startIndex, eventTimes, 0, newSize);
|
System.arraycopy(eventTimes, startIndex, eventTimes, 0, newSize);
|
||||||
System.arraycopy(xCoords, startIndex, xCoords, 0, newSize);
|
System.arraycopy(xCoords, startIndex, xCoords, 0, newSize);
|
||||||
System.arraycopy(yCoords, startIndex, yCoords, 0, newSize);
|
System.arraycopy(yCoords, startIndex, yCoords, 0, newSize);
|
||||||
|
}
|
||||||
mEventTimes.setLength(newSize);
|
mEventTimes.setLength(newSize);
|
||||||
mXCoordinates.setLength(newSize);
|
mXCoordinates.setLength(newSize);
|
||||||
mYCoordinates.setLength(newSize);
|
mYCoordinates.setLength(newSize);
|
||||||
|
}
|
||||||
return newSize > 0;
|
return newSize > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue