summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-08-28 16:48:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-28 16:48:04 +0000
commite9a204f04465c26a32a15c237b985def8c2b4a90 (patch)
treeb109dcb9c6d589f3c79be852c9dc9d573dc01ff7
parent06c34e7cbed0640ec537f725a8a6652d929e322d (diff)
parentd0cd9db31639b246587fe494ec15d32d9fdb3dc7 (diff)
downloadframeworks_base-e9a204f04465c26a32a15c237b985def8c2b4a90.zip
frameworks_base-e9a204f04465c26a32a15c237b985def8c2b4a90.tar.gz
frameworks_base-e9a204f04465c26a32a15c237b985def8c2b4a90.tar.bz2
Merge "Actually end animators on tree destruction" into lmp-dev
-rw-r--r--libs/hwui/AnimationContext.cpp19
-rw-r--r--libs/hwui/AnimationContext.h7
-rw-r--r--libs/hwui/AnimatorManager.cpp4
3 files changed, 27 insertions, 3 deletions
diff --git a/libs/hwui/AnimationContext.cpp b/libs/hwui/AnimationContext.cpp
index ec44de3..732f4f1 100644
--- a/libs/hwui/AnimationContext.cpp
+++ b/libs/hwui/AnimationContext.cpp
@@ -31,6 +31,14 @@ AnimationContext::AnimationContext(renderthread::TimeLord& clock)
}
AnimationContext::~AnimationContext() {
+ startFrame();
+ while (mCurrentFrameAnimations.mNextHandle) {
+ AnimationHandle* current = mCurrentFrameAnimations.mNextHandle;
+ AnimatorManager& animators = current->mRenderNode->animators();
+ animators.endAllAnimators();
+ LOG_ALWAYS_FATAL_IF(mCurrentFrameAnimations.mNextHandle == current,
+ "Animate failed to remove from current frame list!");
+ }
}
void AnimationContext::addAnimatingRenderNode(RenderNode& node) {
@@ -96,11 +104,18 @@ void AnimationHandle::notifyAnimationsRan() {
if (mRenderNode->animators().hasAnimators()) {
mContext.addAnimationHandle(this);
} else {
- mRenderNode->animators().setAnimationHandle(NULL);
- delete this;
+ release();
}
}
+void AnimationHandle::release() {
+ LOG_ALWAYS_FATAL_IF(mRenderNode->animators().hasAnimators(),
+ "Releasing the handle for an RenderNode with outstanding animators!");
+ removeFromList();
+ mRenderNode->animators().setAnimationHandle(NULL);
+ delete this;
+}
+
void AnimationHandle::insertAfter(AnimationHandle* prev) {
removeFromList();
mNextHandle = prev->mNextHandle;
diff --git a/libs/hwui/AnimationContext.h b/libs/hwui/AnimationContext.h
index e32c33d..900d953 100644
--- a/libs/hwui/AnimationContext.h
+++ b/libs/hwui/AnimationContext.h
@@ -46,8 +46,15 @@ class AnimationHandle {
public:
AnimationContext& context() { return mContext; }
+ // Called by the RenderNode when it has internally pulsed its own animations
+ // this frame and does not need to be run again this frame.
void notifyAnimationsRan();
+ // Stops tracking the RenderNode and destroys the handle. The node must be
+ // re-attached to the AnimationContext to receive managed animation
+ // pulses.
+ void release();
+
private:
friend class AnimationContext;
AnimationHandle(AnimationContext& context);
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index 3832d42..678b1ee 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -160,13 +160,15 @@ void AnimatorManager::endAllAnimators() {
if (mAnimationHandle) {
EndAnimatorsFunctor functor(mAnimationHandle->context());
for_each(mAnimators.begin(), mAnimators.end(), functor);
+ mAnimators.clear();
+ mAnimationHandle->release();
} else {
// We have no context, so bust out the sledgehammer
// This works because this state can only happen on the UI thread,
// which means we're already on the right thread to invoke listeners
for_each(mAnimators.begin(), mAnimators.end(), endAnimatorsHard);
+ mAnimators.clear();
}
- mAnimators.clear();
}
} /* namespace uirenderer */