Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9a204f0 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Actually end animators on tree destruction" into lmp-dev

parents 06c34e7c d0cd9db3
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -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,10 +104,17 @@ void AnimationHandle::notifyAnimationsRan() {
    if (mRenderNode->animators().hasAnimators()) {
        mContext.addAnimationHandle(this);
    } else {
        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();
+7 −0
Original line number Diff line number Diff line
@@ -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);
+3 −1
Original line number Diff line number Diff line
@@ -160,14 +160,16 @@ 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();
    }
}

} /* namespace uirenderer */
} /* namespace android */