diff options
author | 2016-08-04 13:20:17 -0700 | |
---|---|---|
committer | 2016-08-04 22:43:07 +0000 | |
commit | 6725d581eb3c13591a4ff276413dbfa0fc13e739 (patch) | |
tree | ce97c8ce9603ec7398683532e8e7e042e2c627dc | |
parent | 6bcf0cdf37cb13aebfaf17b757401d025a4a35e1 (diff) |
Remove animation value change from push staging
This CL ensures that animation values are only updated during
animation pulses.
This CL also includes the revert of
https://googleplex-android-review.git.corp.google.com/#/c/1285913/
BUG: 30659748
Change-Id: Iadc84462dc61157efd3c18a23767bba9faf00f6e
-rw-r--r-- | libs/hwui/Animator.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/Animator.h | 13 | ||||
-rw-r--r-- | libs/hwui/AnimatorManager.cpp | 7 |
3 files changed, 28 insertions, 8 deletions
diff --git a/libs/hwui/Animator.cpp b/libs/hwui/Animator.cpp index dc180188100b..74aa3033ee12 100644 --- a/libs/hwui/Animator.cpp +++ b/libs/hwui/Animator.cpp @@ -123,22 +123,27 @@ void BaseRenderNodeAnimator::resolveStagingRequest(Request request) { mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ? mPlayTime : 0; mPlayState = PlayState::Running; + mPendingActionUponFinish = Action::None; break; case Request::Reverse: mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ? mPlayTime : mDuration; mPlayState = PlayState::Reversing; + mPendingActionUponFinish = Action::None; break; case Request::Reset: mPlayTime = 0; mPlayState = PlayState::Finished; + mPendingActionUponFinish = Action::Reset; break; case Request::Cancel: mPlayState = PlayState::Finished; + mPendingActionUponFinish = Action::None; break; case Request::End: mPlayTime = mPlayState == PlayState::Reversing ? 0 : mDuration; mPlayState = PlayState::Finished; + mPendingActionUponFinish = Action::End; break; default: LOG_ALWAYS_FATAL("Invalid staging request: %d", static_cast<int>(request)); @@ -176,8 +181,6 @@ void BaseRenderNodeAnimator::pushStaging(AnimationContext& context) { mStagingRequests.clear(); if (mStagingPlayState == PlayState::Finished) { - // Set the staging play time and end the animation - updatePlayTime(mPlayTime); callOnFinishedListener(context); } else if (mStagingPlayState == PlayState::Running || mStagingPlayState == PlayState::Reversing) { @@ -236,6 +239,15 @@ bool BaseRenderNodeAnimator::animate(AnimationContext& context) { return false; } if (mPlayState == PlayState::Finished) { + if (mPendingActionUponFinish == Action::Reset) { + // Skip to start. + updatePlayTime(0); + } else if (mPendingActionUponFinish == Action::End) { + // Skip to end. + updatePlayTime(mDuration); + } + // Reset pending action. + mPendingActionUponFinish = Action ::None; return true; } diff --git a/libs/hwui/Animator.h b/libs/hwui/Animator.h index 9476750afd52..ef9658250bf0 100644 --- a/libs/hwui/Animator.h +++ b/libs/hwui/Animator.h @@ -159,6 +159,17 @@ private: Cancel, End }; + + // Defines different actions upon finish. + enum class Action { + // For animations that got canceled or finished normally. no more action needs to be done. + None, + // For animations that get reset, the reset will happen in the next animation pulse. + Reset, + // For animations being ended, in the next animation pulse the animation will skip to end. + End + }; + inline void checkMutable(); virtual void transitionToRunning(AnimationContext& context); void doSetStartValue(float value); @@ -166,7 +177,7 @@ private: void resolveStagingRequest(Request request); std::vector<Request> mStagingRequests; - + Action mPendingActionUponFinish = Action::None; }; class RenderPropertyAnimator : public BaseRenderNodeAnimator { diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp index 8d5f1a83e211..f170e9cda8af 100644 --- a/libs/hwui/AnimatorManager.cpp +++ b/libs/hwui/AnimatorManager.cpp @@ -83,11 +83,8 @@ void AnimatorManager::pushStaging() { } mNewAnimators.clear(); } - if (mAnimators.size()) { - for (auto& animator : mAnimators) { - animator->pushStaging(mAnimationHandle->context()); - } - mParent.mProperties.updateMatrix(); + for (auto& animator : mAnimators) { + animator->pushStaging(mAnimationHandle->context()); } } |