FallbackLUTInterpolatorpublic class FallbackLUTInterpolator extends Object implements NativeInterpolatorFactory, android.animation.TimeInterpolatorInterpolator that builds a lookup table to use. This is a fallback for
building a native interpolator from a TimeInterpolator that is not marked
with {@link HasNativeInterpolator}
This implements TimeInterpolator to allow for easier interop with Animators |
Fields Summary |
---|
private android.animation.TimeInterpolator | mSourceInterpolator | private final float[] | mLut |
Constructors Summary |
---|
public FallbackLUTInterpolator(android.animation.TimeInterpolator interpolator, long duration)Used to cache the float[] LUT for use across multiple native
interpolator creation
mSourceInterpolator = interpolator;
mLut = createLUT(interpolator, duration);
|
Methods Summary |
---|
private static float[] | createLUT(android.animation.TimeInterpolator interpolator, long duration)
long frameIntervalNanos = Choreographer.getInstance().getFrameIntervalNanos();
int animIntervalMs = (int) (frameIntervalNanos / TimeUtils.NANOS_PER_MS);
int numAnimFrames = (int) Math.ceil(duration / animIntervalMs);
float values[] = new float[numAnimFrames];
float lastFrame = numAnimFrames - 1;
for (int i = 0; i < numAnimFrames; i++) {
float inValue = i / lastFrame;
values[i] = interpolator.getInterpolation(inValue);
}
return values;
| public long | createNativeInterpolator()
return NativeInterpolatorFactoryHelper.createLutInterpolator(mLut);
| public static long | createNativeInterpolator(android.animation.TimeInterpolator interpolator, long duration)Used to create a one-shot float[] LUT & native interpolator
float[] lut = createLUT(interpolator, duration);
return NativeInterpolatorFactoryHelper.createLutInterpolator(lut);
| public float | getInterpolation(float input)
return mSourceInterpolator.getInterpolation(input);
|
|