John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 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.view; |
| 18 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 19 | import android.animation.Animator; |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 20 | import android.animation.TimeInterpolator; |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 21 | import android.animation.ValueAnimator; |
John Reck | 1c058e9 | 2014-05-02 14:20:53 -0700 | [diff] [blame] | 22 | import android.graphics.Canvas; |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 23 | import android.graphics.CanvasProperty; |
| 24 | import android.graphics.Paint; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 25 | import android.util.SparseIntArray; |
| 26 | |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 27 | import com.android.internal.util.VirtualRefBasePtr; |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 28 | import com.android.internal.view.animation.FallbackLUTInterpolator; |
| 29 | import com.android.internal.view.animation.HasNativeInterpolator; |
| 30 | import com.android.internal.view.animation.NativeInterpolatorFactory; |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 31 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 32 | import java.lang.ref.WeakReference; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 33 | import java.util.ArrayList; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * @hide |
| 37 | */ |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 38 | public class RenderNodeAnimator extends Animator { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 39 | // Keep in sync with enum RenderProperty in Animator.h |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 40 | public static final int TRANSLATION_X = 0; |
| 41 | public static final int TRANSLATION_Y = 1; |
| 42 | public static final int TRANSLATION_Z = 2; |
| 43 | public static final int SCALE_X = 3; |
| 44 | public static final int SCALE_Y = 4; |
| 45 | public static final int ROTATION = 5; |
| 46 | public static final int ROTATION_X = 6; |
| 47 | public static final int ROTATION_Y = 7; |
| 48 | public static final int X = 8; |
| 49 | public static final int Y = 9; |
| 50 | public static final int Z = 10; |
| 51 | public static final int ALPHA = 11; |
John Reck | 918988c | 2014-05-19 10:28:35 -0700 | [diff] [blame] | 52 | // The last value in the enum, used for array size initialization |
| 53 | public static final int LAST_VALUE = ALPHA; |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 54 | |
| 55 | // Keep in sync with enum PaintFields in Animator.h |
| 56 | public static final int PAINT_STROKE_WIDTH = 0; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Field for the Paint alpha channel, which should be specified as a value |
| 60 | * between 0 and 255. |
| 61 | */ |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 62 | public static final int PAINT_ALPHA = 1; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 63 | |
| 64 | // ViewPropertyAnimator uses a mask for its values, we need to remap them |
| 65 | // to the enum values here. RenderPropertyAnimator can't use the mask values |
| 66 | // directly as internally it uses a lookup table so it needs the values to |
| 67 | // be sequential starting from 0 |
| 68 | private static final SparseIntArray sViewPropertyAnimatorMap = new SparseIntArray(15) {{ |
| 69 | put(ViewPropertyAnimator.TRANSLATION_X, TRANSLATION_X); |
| 70 | put(ViewPropertyAnimator.TRANSLATION_Y, TRANSLATION_Y); |
| 71 | put(ViewPropertyAnimator.TRANSLATION_Z, TRANSLATION_Z); |
| 72 | put(ViewPropertyAnimator.SCALE_X, SCALE_X); |
| 73 | put(ViewPropertyAnimator.SCALE_Y, SCALE_Y); |
| 74 | put(ViewPropertyAnimator.ROTATION, ROTATION); |
| 75 | put(ViewPropertyAnimator.ROTATION_X, ROTATION_X); |
| 76 | put(ViewPropertyAnimator.ROTATION_Y, ROTATION_Y); |
| 77 | put(ViewPropertyAnimator.X, X); |
| 78 | put(ViewPropertyAnimator.Y, Y); |
| 79 | put(ViewPropertyAnimator.Z, Z); |
| 80 | put(ViewPropertyAnimator.ALPHA, ALPHA); |
| 81 | }}; |
| 82 | |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 83 | private VirtualRefBasePtr mNativePtr; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 84 | |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 85 | private RenderNode mTarget; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 86 | private View mViewTarget; |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 87 | private int mRenderProperty = -1; |
| 88 | private float mFinalValue; |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 89 | private TimeInterpolator mInterpolator; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 90 | |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 91 | private boolean mStarted = false; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 92 | private boolean mFinished = false; |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 93 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 94 | private long mUnscaledDuration = 300; |
| 95 | private long mUnscaledStartDelay = 0; |
| 96 | |
John Reck | 918988c | 2014-05-19 10:28:35 -0700 | [diff] [blame] | 97 | public static int mapViewPropertyToRenderProperty(int viewProperty) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 98 | return sViewPropertyAnimatorMap.get(viewProperty); |
| 99 | } |
| 100 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 101 | public RenderNodeAnimator(int property, float finalValue) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 102 | mRenderProperty = property; |
| 103 | mFinalValue = finalValue; |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 104 | init(nCreateAnimator(new WeakReference<RenderNodeAnimator>(this), |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 105 | property, finalValue)); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 106 | } |
| 107 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 108 | public RenderNodeAnimator(CanvasProperty<Float> property, float finalValue) { |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 109 | init(nCreateCanvasPropertyFloatAnimator( |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 110 | new WeakReference<RenderNodeAnimator>(this), |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 111 | property.getNativeContainer(), finalValue)); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Creates a new render node animator for a field on a Paint property. |
| 116 | * |
| 117 | * @param property The paint property to target |
| 118 | * @param paintField Paint field to animate, one of {@link #PAINT_ALPHA} or |
| 119 | * {@link #PAINT_STROKE_WIDTH} |
| 120 | * @param finalValue The target value for the property |
| 121 | */ |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 122 | public RenderNodeAnimator(CanvasProperty<Paint> property, int paintField, float finalValue) { |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 123 | init(nCreateCanvasPropertyPaintAnimator( |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 124 | new WeakReference<RenderNodeAnimator>(this), |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 125 | property.getNativeContainer(), paintField, finalValue)); |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 126 | } |
| 127 | |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame^] | 128 | public RenderNodeAnimator(int x, int y, boolean inverseClip, |
| 129 | float startRadius, float endRadius) { |
| 130 | init(nCreateRevealAnimator(new WeakReference<>(this), |
| 131 | x, y, inverseClip, startRadius, endRadius)); |
| 132 | } |
| 133 | |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame] | 134 | private void init(long ptr) { |
| 135 | mNativePtr = new VirtualRefBasePtr(ptr); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 136 | } |
| 137 | |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 138 | private void checkMutable() { |
| 139 | if (mStarted) { |
| 140 | throw new IllegalStateException("Animator has already started, cannot change it now!"); |
| 141 | } |
| 142 | } |
| 143 | |
John Reck | 918988c | 2014-05-19 10:28:35 -0700 | [diff] [blame] | 144 | static boolean isNativeInterpolator(TimeInterpolator interpolator) { |
| 145 | return interpolator.getClass().isAnnotationPresent(HasNativeInterpolator.class); |
| 146 | } |
| 147 | |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 148 | private void applyInterpolator() { |
| 149 | if (mInterpolator == null) return; |
| 150 | |
| 151 | long ni; |
John Reck | 918988c | 2014-05-19 10:28:35 -0700 | [diff] [blame] | 152 | if (isNativeInterpolator(mInterpolator)) { |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 153 | ni = ((NativeInterpolatorFactory)mInterpolator).createNativeInterpolator(); |
| 154 | } else { |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 155 | long duration = nGetDuration(mNativePtr.get()); |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 156 | ni = FallbackLUTInterpolator.createNativeInterpolator(mInterpolator, duration); |
| 157 | } |
| 158 | nSetInterpolator(mNativePtr.get(), ni); |
| 159 | } |
| 160 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 161 | @Override |
| 162 | public void start() { |
| 163 | if (mTarget == null) { |
| 164 | throw new IllegalStateException("Missing target!"); |
| 165 | } |
| 166 | |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 167 | if (mStarted) { |
| 168 | throw new IllegalStateException("Already started!"); |
| 169 | } |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 170 | |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 171 | mStarted = true; |
| 172 | applyInterpolator(); |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 173 | nStart(mNativePtr.get()); |
| 174 | |
| 175 | // Alpha is a special snowflake that has the canonical value stored |
| 176 | // in mTransformationInfo instead of in RenderNode, so we need to update |
| 177 | // it with the final value here. |
| 178 | if (mRenderProperty == RenderNodeAnimator.ALPHA) { |
| 179 | // Don't need null check because ViewPropertyAnimator's |
| 180 | // ctor calls ensureTransformationInfo() |
| 181 | mViewTarget.mTransformationInfo.mAlpha = mFinalValue; |
| 182 | } |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 183 | |
| 184 | final ArrayList<AnimatorListener> listeners = getListeners(); |
| 185 | final int numListeners = listeners == null ? 0 : listeners.size(); |
| 186 | for (int i = 0; i < numListeners; i++) { |
| 187 | listeners.get(i).onAnimationStart(this); |
| 188 | } |
| 189 | |
| 190 | if (mViewTarget != null) { |
| 191 | // Kick off a frame to start the process |
| 192 | mViewTarget.invalidateViewProperty(true, false); |
| 193 | } |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 196 | @Override |
| 197 | public void cancel() { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 198 | if (!mFinished) { |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame^] | 199 | nEnd(mNativePtr.get()); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 200 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 201 | final ArrayList<AnimatorListener> listeners = getListeners(); |
| 202 | final int numListeners = listeners == null ? 0 : listeners.size(); |
| 203 | for (int i = 0; i < numListeners; i++) { |
| 204 | listeners.get(i).onAnimationCancel(this); |
| 205 | } |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 206 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 207 | } |
| 208 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 209 | @Override |
| 210 | public void end() { |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame^] | 211 | if (!mFinished) { |
| 212 | nEnd(mNativePtr.get()); |
| 213 | } |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public void pause() { |
| 218 | throw new UnsupportedOperationException(); |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public void resume() { |
| 223 | throw new UnsupportedOperationException(); |
| 224 | } |
| 225 | |
| 226 | public void setTarget(View view) { |
| 227 | mViewTarget = view; |
| 228 | mTarget = view.mRenderNode; |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 229 | mTarget.addAnimator(this); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | public void setTarget(Canvas canvas) { |
John Reck | 1c058e9 | 2014-05-02 14:20:53 -0700 | [diff] [blame] | 233 | if (!(canvas instanceof GLES20RecordingCanvas)) { |
| 234 | throw new IllegalArgumentException("Not a GLES20RecordingCanvas"); |
| 235 | } |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 236 | |
| 237 | final GLES20RecordingCanvas recordingCanvas = (GLES20RecordingCanvas) canvas; |
| 238 | setTarget(recordingCanvas.mNode); |
John Reck | 1c058e9 | 2014-05-02 14:20:53 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 241 | public void setTarget(RenderNode node) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 242 | if (mTarget != null) { |
| 243 | throw new IllegalStateException("Target already set!"); |
| 244 | } |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 245 | mViewTarget = null; |
| 246 | mTarget = node; |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 247 | mTarget.addAnimator(this); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 248 | } |
| 249 | |
John Reck | c6b3264 | 2014-06-02 11:00:09 -0700 | [diff] [blame] | 250 | public void setStartValue(float startValue) { |
| 251 | checkMutable(); |
| 252 | nSetStartValue(mNativePtr.get(), startValue); |
| 253 | } |
| 254 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 255 | @Override |
| 256 | public void setStartDelay(long startDelay) { |
| 257 | checkMutable(); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 258 | if (startDelay < 0) { |
| 259 | throw new IllegalArgumentException("startDelay must be positive; " + startDelay); |
| 260 | } |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 261 | mUnscaledStartDelay = startDelay; |
| 262 | nSetStartDelay(mNativePtr.get(), (long) (startDelay * ValueAnimator.getDurationScale())); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | @Override |
| 266 | public long getStartDelay() { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 267 | return mUnscaledStartDelay; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | @Override |
| 271 | public RenderNodeAnimator setDuration(long duration) { |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 272 | checkMutable(); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 273 | if (duration < 0) { |
| 274 | throw new IllegalArgumentException("duration must be positive; " + duration); |
| 275 | } |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 276 | mUnscaledDuration = duration; |
| 277 | nSetDuration(mNativePtr.get(), (long) (duration * ValueAnimator.getDurationScale())); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 278 | return this; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 281 | @Override |
| 282 | public long getDuration() { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 283 | return mUnscaledDuration; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | @Override |
| 287 | public boolean isRunning() { |
| 288 | return mStarted && !mFinished; |
| 289 | } |
| 290 | |
| 291 | @Override |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame^] | 292 | public boolean isStarted() { |
| 293 | return mStarted; |
| 294 | } |
| 295 | |
| 296 | @Override |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 297 | public void setInterpolator(TimeInterpolator interpolator) { |
| 298 | checkMutable(); |
| 299 | mInterpolator = interpolator; |
| 300 | } |
| 301 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 302 | @Override |
| 303 | public TimeInterpolator getInterpolator() { |
| 304 | return mInterpolator; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | private void onFinished() { |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 308 | mFinished = true; |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 309 | |
| 310 | final ArrayList<AnimatorListener> listeners = getListeners(); |
| 311 | final int numListeners = listeners == null ? 0 : listeners.size(); |
| 312 | for (int i = 0; i < numListeners; i++) { |
| 313 | listeners.get(i).onAnimationEnd(this); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | long getNativeAnimator() { |
| 318 | return mNativePtr.get(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | // Called by native |
| 322 | private static void callOnFinished(WeakReference<RenderNodeAnimator> weakThis) { |
| 323 | RenderNodeAnimator animator = weakThis.get(); |
| 324 | if (animator != null) { |
| 325 | animator.onFinished(); |
| 326 | } |
| 327 | } |
| 328 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 329 | private static native long nCreateAnimator(WeakReference<RenderNodeAnimator> weakThis, |
John Reck | c6b3264 | 2014-06-02 11:00:09 -0700 | [diff] [blame] | 330 | int property, float finalValue); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 331 | private static native long nCreateCanvasPropertyFloatAnimator(WeakReference<RenderNodeAnimator> weakThis, |
John Reck | c6b3264 | 2014-06-02 11:00:09 -0700 | [diff] [blame] | 332 | long canvasProperty, float finalValue); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 333 | private static native long nCreateCanvasPropertyPaintAnimator(WeakReference<RenderNodeAnimator> weakThis, |
John Reck | c6b3264 | 2014-06-02 11:00:09 -0700 | [diff] [blame] | 334 | long canvasProperty, int paintField, float finalValue); |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame^] | 335 | private static native long nCreateRevealAnimator(WeakReference<RenderNodeAnimator> weakThis, |
| 336 | int x, int y, boolean inverseClip, float startRadius, float endRadius); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 337 | |
John Reck | c6b3264 | 2014-06-02 11:00:09 -0700 | [diff] [blame] | 338 | private static native void nSetStartValue(long nativePtr, float startValue); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 339 | private static native void nSetDuration(long nativePtr, long duration); |
| 340 | private static native long nGetDuration(long nativePtr); |
| 341 | private static native void nSetStartDelay(long nativePtr, long startDelay); |
| 342 | private static native long nGetStartDelay(long nativePtr); |
John Reck | 315c329 | 2014-05-09 19:21:04 -0700 | [diff] [blame] | 343 | private static native void nSetInterpolator(long animPtr, long interpolatorPtr); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 344 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 345 | private static native void nStart(long animPtr); |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame^] | 346 | private static native void nEnd(long animPtr); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 347 | } |