am 418c8549: Merge "It\'s super critical to call nStart" into lmp-mr1-dev
* commit '418c8549dca8bff8c38c67ed7f7d7fbbaccd4e71': It's super critical to call nStart
This commit is contained in:
@@ -189,9 +189,6 @@ public class RenderNodeAnimator extends Animator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doStart() {
|
private void doStart() {
|
||||||
mState = STATE_RUNNING;
|
|
||||||
nStart(mNativePtr.get(), this);
|
|
||||||
|
|
||||||
// Alpha is a special snowflake that has the canonical value stored
|
// Alpha is a special snowflake that has the canonical value stored
|
||||||
// in mTransformationInfo instead of in RenderNode, so we need to update
|
// in mTransformationInfo instead of in RenderNode, so we need to update
|
||||||
// it with the final value here.
|
// it with the final value here.
|
||||||
@@ -201,7 +198,7 @@ public class RenderNodeAnimator extends Animator {
|
|||||||
mViewTarget.mTransformationInfo.mAlpha = mFinalValue;
|
mViewTarget.mTransformationInfo.mAlpha = mFinalValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyStartListeners();
|
moveToRunningState();
|
||||||
|
|
||||||
if (mViewTarget != null) {
|
if (mViewTarget != null) {
|
||||||
// Kick off a frame to start the process
|
// Kick off a frame to start the process
|
||||||
@@ -209,6 +206,12 @@ public class RenderNodeAnimator extends Animator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveToRunningState() {
|
||||||
|
mState = STATE_RUNNING;
|
||||||
|
nStart(mNativePtr.get(), this);
|
||||||
|
notifyStartListeners();
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyStartListeners() {
|
private void notifyStartListeners() {
|
||||||
final ArrayList<AnimatorListener> listeners = cloneListeners();
|
final ArrayList<AnimatorListener> listeners = cloneListeners();
|
||||||
final int numListeners = listeners == null ? 0 : listeners.size();
|
final int numListeners = listeners == null ? 0 : listeners.size();
|
||||||
@@ -222,7 +225,7 @@ public class RenderNodeAnimator extends Animator {
|
|||||||
if (mState != STATE_PREPARE && mState != STATE_FINISHED) {
|
if (mState != STATE_PREPARE && mState != STATE_FINISHED) {
|
||||||
if (mState == STATE_DELAYED) {
|
if (mState == STATE_DELAYED) {
|
||||||
getHelper().removeDelayedAnimation(this);
|
getHelper().removeDelayedAnimation(this);
|
||||||
notifyStartListeners();
|
moveToRunningState();
|
||||||
}
|
}
|
||||||
nEnd(mNativePtr.get());
|
nEnd(mNativePtr.get());
|
||||||
|
|
||||||
@@ -242,7 +245,15 @@ public class RenderNodeAnimator extends Animator {
|
|||||||
@Override
|
@Override
|
||||||
public void end() {
|
public void end() {
|
||||||
if (mState != STATE_FINISHED) {
|
if (mState != STATE_FINISHED) {
|
||||||
|
if (mState < STATE_RUNNING) {
|
||||||
|
getHelper().removeDelayedAnimation(this);
|
||||||
|
doStart();
|
||||||
|
}
|
||||||
nEnd(mNativePtr.get());
|
nEnd(mNativePtr.get());
|
||||||
|
if (mViewTarget != null) {
|
||||||
|
// Kick off a frame to flush the state change
|
||||||
|
mViewTarget.invalidateViewProperty(true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,15 @@ static JNIEnv* getEnv(JavaVM* vm) {
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AnimationListenerLifecycleChecker : public AnimationListener {
|
||||||
|
public:
|
||||||
|
virtual void onAnimationFinished(BaseRenderNodeAnimator* animator) {
|
||||||
|
LOG_ALWAYS_FATAL("Lifecycle failure, nStart(%p) wasn't called", animator);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static AnimationListenerLifecycleChecker sLifecycleChecker;
|
||||||
|
|
||||||
class AnimationListenerBridge : public AnimationListener {
|
class AnimationListenerBridge : public AnimationListener {
|
||||||
public:
|
public:
|
||||||
// This holds a strong reference to a Java WeakReference<T> object. This avoids
|
// This holds a strong reference to a Java WeakReference<T> object. This avoids
|
||||||
@@ -100,6 +109,7 @@ static jlong createAnimator(JNIEnv* env, jobject clazz,
|
|||||||
jint propertyRaw, jfloat finalValue) {
|
jint propertyRaw, jfloat finalValue) {
|
||||||
RenderPropertyAnimator::RenderProperty property = toRenderProperty(propertyRaw);
|
RenderPropertyAnimator::RenderProperty property = toRenderProperty(propertyRaw);
|
||||||
BaseRenderNodeAnimator* animator = new RenderPropertyAnimator(property, finalValue);
|
BaseRenderNodeAnimator* animator = new RenderPropertyAnimator(property, finalValue);
|
||||||
|
animator->setListener(&sLifecycleChecker);
|
||||||
return reinterpret_cast<jlong>( animator );
|
return reinterpret_cast<jlong>( animator );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +117,7 @@ static jlong createCanvasPropertyFloatAnimator(JNIEnv* env, jobject clazz,
|
|||||||
jlong canvasPropertyPtr, jfloat finalValue) {
|
jlong canvasPropertyPtr, jfloat finalValue) {
|
||||||
CanvasPropertyPrimitive* canvasProperty = reinterpret_cast<CanvasPropertyPrimitive*>(canvasPropertyPtr);
|
CanvasPropertyPrimitive* canvasProperty = reinterpret_cast<CanvasPropertyPrimitive*>(canvasPropertyPtr);
|
||||||
BaseRenderNodeAnimator* animator = new CanvasPropertyPrimitiveAnimator(canvasProperty, finalValue);
|
BaseRenderNodeAnimator* animator = new CanvasPropertyPrimitiveAnimator(canvasProperty, finalValue);
|
||||||
|
animator->setListener(&sLifecycleChecker);
|
||||||
return reinterpret_cast<jlong>( animator );
|
return reinterpret_cast<jlong>( animator );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,12 +128,14 @@ static jlong createCanvasPropertyPaintAnimator(JNIEnv* env, jobject clazz,
|
|||||||
CanvasPropertyPaintAnimator::PaintField paintField = toPaintField(paintFieldRaw);
|
CanvasPropertyPaintAnimator::PaintField paintField = toPaintField(paintFieldRaw);
|
||||||
BaseRenderNodeAnimator* animator = new CanvasPropertyPaintAnimator(
|
BaseRenderNodeAnimator* animator = new CanvasPropertyPaintAnimator(
|
||||||
canvasProperty, paintField, finalValue);
|
canvasProperty, paintField, finalValue);
|
||||||
|
animator->setListener(&sLifecycleChecker);
|
||||||
return reinterpret_cast<jlong>( animator );
|
return reinterpret_cast<jlong>( animator );
|
||||||
}
|
}
|
||||||
|
|
||||||
static jlong createRevealAnimator(JNIEnv* env, jobject clazz,
|
static jlong createRevealAnimator(JNIEnv* env, jobject clazz,
|
||||||
jint centerX, jint centerY, jfloat startRadius, jfloat endRadius) {
|
jint centerX, jint centerY, jfloat startRadius, jfloat endRadius) {
|
||||||
BaseRenderNodeAnimator* animator = new RevealAnimator(centerX, centerY, startRadius, endRadius);
|
BaseRenderNodeAnimator* animator = new RevealAnimator(centerX, centerY, startRadius, endRadius);
|
||||||
|
animator->setListener(&sLifecycleChecker);
|
||||||
return reinterpret_cast<jlong>( animator );
|
return reinterpret_cast<jlong>( animator );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,9 +179,7 @@ static void setAllowRunningAsync(JNIEnv* env, jobject clazz, jlong animatorPtr,
|
|||||||
|
|
||||||
static void start(JNIEnv* env, jobject clazz, jlong animatorPtr, jobject finishListener) {
|
static void start(JNIEnv* env, jobject clazz, jlong animatorPtr, jobject finishListener) {
|
||||||
BaseRenderNodeAnimator* animator = reinterpret_cast<BaseRenderNodeAnimator*>(animatorPtr);
|
BaseRenderNodeAnimator* animator = reinterpret_cast<BaseRenderNodeAnimator*>(animatorPtr);
|
||||||
if (finishListener) {
|
animator->setListener(new AnimationListenerBridge(env, finishListener));
|
||||||
animator->setListener(new AnimationListenerBridge(env, finishListener));
|
|
||||||
}
|
|
||||||
animator->start();
|
animator->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +222,9 @@ static JNINativeMethod gMethods[] = {
|
|||||||
LOG_FATAL_IF(! var, "Unable to find method " methodName);
|
LOG_FATAL_IF(! var, "Unable to find method " methodName);
|
||||||
|
|
||||||
int register_android_view_RenderNodeAnimator(JNIEnv* env) {
|
int register_android_view_RenderNodeAnimator(JNIEnv* env) {
|
||||||
|
#ifdef USE_OPENGL_RENDERER
|
||||||
|
sLifecycleChecker.incStrong(0);
|
||||||
|
#endif
|
||||||
FIND_CLASS(gRenderNodeAnimatorClassInfo.clazz, kClassPathName);
|
FIND_CLASS(gRenderNodeAnimatorClassInfo.clazz, kClassPathName);
|
||||||
gRenderNodeAnimatorClassInfo.clazz = jclass(env->NewGlobalRef(gRenderNodeAnimatorClassInfo.clazz));
|
gRenderNodeAnimatorClassInfo.clazz = jclass(env->NewGlobalRef(gRenderNodeAnimatorClassInfo.clazz));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user