Merge "LUTInterpolator needs to have 2 frame at minimal" into nyc-dev

This commit is contained in:
Tenghui Zhu
2016-03-30 20:30:04 +00:00
committed by Android (Google) Code Review

View File

@@ -45,7 +45,8 @@ public class FallbackLUTInterpolator implements NativeInterpolatorFactory, TimeI
private static float[] createLUT(TimeInterpolator interpolator, long duration) {
long frameIntervalNanos = Choreographer.getInstance().getFrameIntervalNanos();
int animIntervalMs = (int) (frameIntervalNanos / TimeUtils.NANOS_PER_MS);
int numAnimFrames = (int) Math.ceil(((double) duration) / animIntervalMs);
// We need 2 frame values as the minimal.
int numAnimFrames = Math.max(2, (int) Math.ceil(((double) duration) / animIntervalMs));
float values[] = new float[numAnimFrames];
float lastFrame = numAnimFrames - 1;
for (int i = 0; i < numAnimFrames; i++) {