FileDocCategorySizeDatePackage
FallbackLUTInterpolator.javaAPI DocAndroid 5.1 API2764Thu Mar 12 22:22:10 GMT 2015com.android.internal.view.animation

FallbackLUTInterpolator

public class FallbackLUTInterpolator extends Object implements NativeInterpolatorFactory, android.animation.TimeInterpolator
Interpolator 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 longcreateNativeInterpolator()

        return NativeInterpolatorFactoryHelper.createLutInterpolator(mLut);
    
public static longcreateNativeInterpolator(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 floatgetInterpolation(float input)

        return mSourceInterpolator.getInterpolation(input);