summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-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 */