diff options
author | John Reck <jreck@google.com> | 2014-05-12 16:39:41 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-05-12 16:42:02 -0700 |
commit | c8ac775659fd252ce2cc9a61837c170ff70f0a1a (patch) | |
tree | 6c6d78c22810d76c5091b0e9ff6d618920c9c071 /core/java/android | |
parent | 315c329544d7c593d1072b071cbb92d9afe74021 (diff) | |
download | frameworks_base-c8ac775659fd252ce2cc9a61837c170ff70f0a1a.zip frameworks_base-c8ac775659fd252ce2cc9a61837c170ff70f0a1a.tar.gz frameworks_base-c8ac775659fd252ce2cc9a61837c170ff70f0a1a.tar.bz2 |
More native interpolators
Gotta collect 'em all
Change-Id: I3ccc2b5c842b27b906c8a0470fbedc2bf285bc38
Diffstat (limited to 'core/java/android')
8 files changed, 97 insertions, 8 deletions
diff --git a/core/java/android/view/animation/AccelerateInterpolator.java b/core/java/android/view/animation/AccelerateInterpolator.java index dcab743..c08f348 100644 --- a/core/java/android/view/animation/AccelerateInterpolator.java +++ b/core/java/android/view/animation/AccelerateInterpolator.java @@ -20,12 +20,17 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * An interpolator where the rate of change starts out slowly and * and then accelerates. * */ -public class AccelerateInterpolator implements Interpolator { +@HasNativeInterpolator +public class AccelerateInterpolator implements Interpolator, NativeInterpolatorFactory { private final float mFactor; private final double mDoubleFactor; @@ -64,4 +69,10 @@ public class AccelerateInterpolator implements Interpolator { return (float)Math.pow(input, mDoubleFactor); } } + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createAccelerateInterpolator(mFactor); + } } diff --git a/core/java/android/view/animation/AnticipateInterpolator.java b/core/java/android/view/animation/AnticipateInterpolator.java index a6f110e..83a8007 100644 --- a/core/java/android/view/animation/AnticipateInterpolator.java +++ b/core/java/android/view/animation/AnticipateInterpolator.java @@ -20,10 +20,15 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * An interpolator where the change starts backward then flings forward. */ -public class AnticipateInterpolator implements Interpolator { +@HasNativeInterpolator +public class AnticipateInterpolator implements Interpolator, NativeInterpolatorFactory { private final float mTension; public AnticipateInterpolator() { @@ -53,4 +58,10 @@ public class AnticipateInterpolator implements Interpolator { // a(t) = t * t * ((tension + 1) * t - tension) return t * t * ((mTension + 1) * t - mTension); } + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createAnticipateInterpolator(mTension); + } } diff --git a/core/java/android/view/animation/AnticipateOvershootInterpolator.java b/core/java/android/view/animation/AnticipateOvershootInterpolator.java index 3dc9722..1a8adfd 100644 --- a/core/java/android/view/animation/AnticipateOvershootInterpolator.java +++ b/core/java/android/view/animation/AnticipateOvershootInterpolator.java @@ -19,6 +19,11 @@ package android.view.animation; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; + +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_extraTension; import static com.android.internal.R.styleable.AnticipateOvershootInterpolator_tension; import static com.android.internal.R.styleable.AnticipateOvershootInterpolator; @@ -27,7 +32,8 @@ import static com.android.internal.R.styleable.AnticipateOvershootInterpolator; * An interpolator where the change starts backward then flings forward and overshoots * the target value and finally goes back to the final value. */ -public class AnticipateOvershootInterpolator implements Interpolator { +@HasNativeInterpolator +public class AnticipateOvershootInterpolator implements Interpolator, NativeInterpolatorFactory { private final float mTension; public AnticipateOvershootInterpolator() { @@ -80,4 +86,10 @@ public class AnticipateOvershootInterpolator implements Interpolator { if (t < 0.5f) return 0.5f * a(t * 2.0f, mTension); else return 0.5f * (o(t * 2.0f - 2.0f, mTension) + 2.0f); } + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createAnticipateOvershootInterpolator(mTension); + } } diff --git a/core/java/android/view/animation/BounceInterpolator.java b/core/java/android/view/animation/BounceInterpolator.java index ecf99a7..9d8ca90 100644 --- a/core/java/android/view/animation/BounceInterpolator.java +++ b/core/java/android/view/animation/BounceInterpolator.java @@ -19,10 +19,15 @@ package android.view.animation; import android.content.Context; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * An interpolator where the change bounces at the end. */ -public class BounceInterpolator implements Interpolator { +@HasNativeInterpolator +public class BounceInterpolator implements Interpolator, NativeInterpolatorFactory { public BounceInterpolator() { } @@ -47,4 +52,10 @@ public class BounceInterpolator implements Interpolator { else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f; else return bounce(t - 1.0435f) + 0.95f; } + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createBounceInterpolator(); + } }
\ No newline at end of file diff --git a/core/java/android/view/animation/CycleInterpolator.java b/core/java/android/view/animation/CycleInterpolator.java index d355c23..d1ebf05 100644 --- a/core/java/android/view/animation/CycleInterpolator.java +++ b/core/java/android/view/animation/CycleInterpolator.java @@ -20,12 +20,17 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * Repeats the animation for a specified number of cycles. The * rate of change follows a sinusoidal pattern. * */ -public class CycleInterpolator implements Interpolator { +@HasNativeInterpolator +public class CycleInterpolator implements Interpolator, NativeInterpolatorFactory { public CycleInterpolator(float cycles) { mCycles = cycles; } @@ -44,4 +49,10 @@ public class CycleInterpolator implements Interpolator { } private float mCycles; + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createCycleInterpolator(mCycles); + } } diff --git a/core/java/android/view/animation/DecelerateInterpolator.java b/core/java/android/view/animation/DecelerateInterpolator.java index 20e079b..0789a0e 100644 --- a/core/java/android/view/animation/DecelerateInterpolator.java +++ b/core/java/android/view/animation/DecelerateInterpolator.java @@ -20,12 +20,17 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * An interpolator where the rate of change starts out quickly and * and then decelerates. * */ -public class DecelerateInterpolator implements Interpolator { +@HasNativeInterpolator +public class DecelerateInterpolator implements Interpolator, NativeInterpolatorFactory { public DecelerateInterpolator() { } @@ -60,4 +65,10 @@ public class DecelerateInterpolator implements Interpolator { } private float mFactor = 1.0f; + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createDecelerateInterpolator(mFactor); + } } diff --git a/core/java/android/view/animation/LinearInterpolator.java b/core/java/android/view/animation/LinearInterpolator.java index 96a039f..552c611 100644 --- a/core/java/android/view/animation/LinearInterpolator.java +++ b/core/java/android/view/animation/LinearInterpolator.java @@ -19,11 +19,16 @@ package android.view.animation; import android.content.Context; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * An interpolator where the rate of change is constant * */ -public class LinearInterpolator implements Interpolator { +@HasNativeInterpolator +public class LinearInterpolator implements Interpolator, NativeInterpolatorFactory { public LinearInterpolator() { } @@ -34,4 +39,10 @@ public class LinearInterpolator implements Interpolator { public float getInterpolation(float input) { return input; } + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createLinearInterpolator(); + } } diff --git a/core/java/android/view/animation/OvershootInterpolator.java b/core/java/android/view/animation/OvershootInterpolator.java index 494f8ab..a2466f1 100644 --- a/core/java/android/view/animation/OvershootInterpolator.java +++ b/core/java/android/view/animation/OvershootInterpolator.java @@ -20,11 +20,16 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; +import com.android.internal.view.animation.HasNativeInterpolator; +import com.android.internal.view.animation.NativeInterpolatorFactory; +import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; + /** * An interpolator where the change flings forward and overshoots the last value * then comes back. */ -public class OvershootInterpolator implements Interpolator { +@HasNativeInterpolator +public class OvershootInterpolator implements Interpolator, NativeInterpolatorFactory { private final float mTension; public OvershootInterpolator() { @@ -56,4 +61,10 @@ public class OvershootInterpolator implements Interpolator { t -= 1.0f; return t * t * ((mTension + 1) * t + mTension) + 1.0f; } + + /** @hide */ + @Override + public long createNativeInterpolator() { + return NativeInterpolatorFactoryHelper.createOvershootInterpolator(mTension); + } } |