am 16c66174: am 2b21f462: Merge "Actually end animators on tree destruction" into lmp-dev
* commit '16c661747022d0861d98a1d3145780912f5b809c': Actually end animators on tree destruction
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user