Remove animation value change from push staging

am: 6725d581eb

Change-Id: I53988f1d269c9691a098693a978e1d6e0b275cd6
This commit is contained in:
Doris Liu
2016-08-06 01:15:48 +00:00
committed by android-build-merger
3 changed files with 28 additions and 8 deletions

View File

@@ -123,22 +123,27 @@ void BaseRenderNodeAnimator::resolveStagingRequest(Request request) {
mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ? mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ?
mPlayTime : 0; mPlayTime : 0;
mPlayState = PlayState::Running; mPlayState = PlayState::Running;
mPendingActionUponFinish = Action::None;
break; break;
case Request::Reverse: case Request::Reverse:
mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ? mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ?
mPlayTime : mDuration; mPlayTime : mDuration;
mPlayState = PlayState::Reversing; mPlayState = PlayState::Reversing;
mPendingActionUponFinish = Action::None;
break; break;
case Request::Reset: case Request::Reset:
mPlayTime = 0; mPlayTime = 0;
mPlayState = PlayState::Finished; mPlayState = PlayState::Finished;
mPendingActionUponFinish = Action::Reset;
break; break;
case Request::Cancel: case Request::Cancel:
mPlayState = PlayState::Finished; mPlayState = PlayState::Finished;
mPendingActionUponFinish = Action::None;
break; break;
case Request::End: case Request::End:
mPlayTime = mPlayState == PlayState::Reversing ? 0 : mDuration; mPlayTime = mPlayState == PlayState::Reversing ? 0 : mDuration;
mPlayState = PlayState::Finished; mPlayState = PlayState::Finished;
mPendingActionUponFinish = Action::End;
break; break;
default: default:
LOG_ALWAYS_FATAL("Invalid staging request: %d", static_cast<int>(request)); LOG_ALWAYS_FATAL("Invalid staging request: %d", static_cast<int>(request));
@@ -176,8 +181,6 @@ void BaseRenderNodeAnimator::pushStaging(AnimationContext& context) {
mStagingRequests.clear(); mStagingRequests.clear();
if (mStagingPlayState == PlayState::Finished) { if (mStagingPlayState == PlayState::Finished) {
// Set the staging play time and end the animation
updatePlayTime(mPlayTime);
callOnFinishedListener(context); callOnFinishedListener(context);
} else if (mStagingPlayState == PlayState::Running } else if (mStagingPlayState == PlayState::Running
|| mStagingPlayState == PlayState::Reversing) { || mStagingPlayState == PlayState::Reversing) {
@@ -236,6 +239,15 @@ bool BaseRenderNodeAnimator::animate(AnimationContext& context) {
return false; return false;
} }
if (mPlayState == PlayState::Finished) { 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; return true;
} }

View File

@@ -165,6 +165,17 @@ private:
Cancel, Cancel,
End 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(); inline void checkMutable();
virtual void transitionToRunning(AnimationContext& context); virtual void transitionToRunning(AnimationContext& context);
void doSetStartValue(float value); void doSetStartValue(float value);
@@ -172,7 +183,7 @@ private:
void resolveStagingRequest(Request request); void resolveStagingRequest(Request request);
std::vector<Request> mStagingRequests; std::vector<Request> mStagingRequests;
Action mPendingActionUponFinish = Action::None;
}; };
class RenderPropertyAnimator : public BaseRenderNodeAnimator { class RenderPropertyAnimator : public BaseRenderNodeAnimator {

View File

@@ -83,12 +83,9 @@ void AnimatorManager::pushStaging() {
} }
mNewAnimators.clear(); mNewAnimators.clear();
} }
if (mAnimators.size()) {
for (auto& animator : mAnimators) { for (auto& animator : mAnimators) {
animator->pushStaging(mAnimationHandle->context()); animator->pushStaging(mAnimationHandle->context());
} }
mParent.mProperties.updateMatrix();
}
} }
void AnimatorManager::onAnimatorTargetChanged(BaseRenderNodeAnimator* animator) { void AnimatorManager::onAnimatorTargetChanged(BaseRenderNodeAnimator* animator) {