diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Animator.cpp | 26 | ||||
-rw-r--r-- | libs/hwui/Animator.h | 10 |
2 files changed, 28 insertions, 8 deletions
diff --git a/libs/hwui/Animator.cpp b/libs/hwui/Animator.cpp index 83eedfb..b80f7e9 100644 --- a/libs/hwui/Animator.cpp +++ b/libs/hwui/Animator.cpp @@ -37,7 +37,10 @@ BaseRenderNodeAnimator::BaseRenderNodeAnimator(float finalValue) , mInterpolator(0) , mPlayState(NEEDS_START) , mStartTime(0) - , mDuration(300){ + , mDelayUntil(0) + , mDuration(300) + , mStartDelay(0) { + } BaseRenderNodeAnimator::~BaseRenderNodeAnimator() { @@ -49,10 +52,6 @@ void BaseRenderNodeAnimator::setInterpolator(Interpolator* interpolator) { mInterpolator = interpolator; } -void BaseRenderNodeAnimator::setDuration(nsecs_t duration) { - mDuration = duration; -} - void BaseRenderNodeAnimator::setStartValue(float value) { LOG_ALWAYS_FATAL_IF(mPlayState != NEEDS_START, "Cannot set the start value after the animator has started!"); @@ -68,7 +67,24 @@ void BaseRenderNodeAnimator::setupStartValueIfNecessary(RenderNode* target, Tree } } +void BaseRenderNodeAnimator::setDuration(nsecs_t duration) { + mDuration = duration; +} + +void BaseRenderNodeAnimator::setStartDelay(nsecs_t startDelay) { + mStartDelay = startDelay; +} + bool BaseRenderNodeAnimator::animate(RenderNode* target, TreeInfo& info) { + if (mPlayState == PENDING && mStartDelay > 0 && mDelayUntil == 0) { + mDelayUntil = info.frameTimeMs + mStartDelay; + return false; + } + + if (mDelayUntil > info.frameTimeMs) { + return false; + } + if (mPlayState == PENDING) { mPlayState = RUNNING; mStartTime = info.frameTimeMs; diff --git a/libs/hwui/Animator.h b/libs/hwui/Animator.h index fe88cbf..7741617 100644 --- a/libs/hwui/Animator.h +++ b/libs/hwui/Animator.h @@ -44,6 +44,8 @@ public: ANDROID_API void setInterpolator(Interpolator* interpolator); ANDROID_API void setDuration(nsecs_t durationInMs); ANDROID_API nsecs_t duration() { return mDuration; } + ANDROID_API void setStartDelay(nsecs_t startDelayInMs); + ANDROID_API nsecs_t startDelay() { return mStartDelay; } ANDROID_API void setListener(AnimationListener* listener) { mListener = listener; } @@ -82,10 +84,12 @@ private: Interpolator* mInterpolator; PlayState mPlayState; - long mStartTime; - long mDuration; + nsecs_t mStartTime; + nsecs_t mDelayUntil; + nsecs_t mDuration; + nsecs_t mStartDelay; - sp<AnimationListener> mListener; + sp<AnimationListener> mListener; }; class RenderPropertyAnimator : public BaseRenderNodeAnimator { |