1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.graphics.animation; 18 19 import android.animation.TimeInterpolator; 20 21 /** 22 * Static utility class for constructing native interpolators to keep the 23 * JNI simpler 24 * 25 * @hide 26 */ 27 public final class NativeInterpolatorFactory { NativeInterpolatorFactory()28 private NativeInterpolatorFactory() {} 29 30 /** 31 * Create a native interpolator from the provided param generating a LUT variant if a native 32 * implementation does not exist. 33 */ createNativeInterpolator(TimeInterpolator interpolator, long duration)34 public static long createNativeInterpolator(TimeInterpolator interpolator, long 35 duration) { 36 if (interpolator == null) { 37 return createLinearInterpolator(); 38 } else if (RenderNodeAnimator.isNativeInterpolator(interpolator)) { 39 return ((NativeInterpolator) interpolator).createNativeInterpolator(); 40 } else { 41 return FallbackLUTInterpolator.createNativeInterpolator(interpolator, duration); 42 } 43 } 44 45 /** Creates a specialized native interpolator for Accelerate/Decelerate */ createAccelerateDecelerateInterpolator()46 public static native long createAccelerateDecelerateInterpolator(); 47 /** Creates a specialized native interpolator for Accelerate */ createAccelerateInterpolator(float factor)48 public static native long createAccelerateInterpolator(float factor); 49 /** Creates a specialized native interpolator for Anticipate */ createAnticipateInterpolator(float tension)50 public static native long createAnticipateInterpolator(float tension); 51 /** Creates a specialized native interpolator for Anticipate with Overshoot */ createAnticipateOvershootInterpolator(float tension)52 public static native long createAnticipateOvershootInterpolator(float tension); 53 /** Creates a specialized native interpolator for Bounce */ createBounceInterpolator()54 public static native long createBounceInterpolator(); 55 /** Creates a specialized native interpolator for Cycle */ createCycleInterpolator(float cycles)56 public static native long createCycleInterpolator(float cycles); 57 /** Creates a specialized native interpolator for Decelerate */ createDecelerateInterpolator(float factor)58 public static native long createDecelerateInterpolator(float factor); 59 /** Creates a specialized native interpolator for Linear interpolation */ createLinearInterpolator()60 public static native long createLinearInterpolator(); 61 /** Creates a specialized native interpolator for Overshoot */ createOvershootInterpolator(float tension)62 public static native long createOvershootInterpolator(float tension); 63 /** Creates a specialized native interpolator for along traveling along a Path */ createPathInterpolator(float[] x, float[] y)64 public static native long createPathInterpolator(float[] x, float[] y); 65 /** Creates a specialized native interpolator for LUT */ createLutInterpolator(float[] values)66 public static native long createLutInterpolator(float[] values); 67 } 68