From ad2f8e334f3ef22d3e412b0660a2e1f996f94116 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Fri, 16 May 2014 13:28:33 -0700 Subject: Update ripple behavior, use render thread animation Change-Id: Ib6bc1e08b05d29606f452961963d58b8fc866746 --- libs/hwui/Animator.cpp | 26 +++++++++++++++++++++----- libs/hwui/Animator.h | 10 +++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'libs') 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 mListener; + sp mListener; }; class RenderPropertyAnimator : public BaseRenderNodeAnimator { -- cgit v1.1