summaryrefslogtreecommitdiff
path: root/libs/hwui/Animator.h
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2016-02-11 20:30:48 +0000
committerDoris Liu <tianliu@google.com>2016-02-12 19:49:29 -0800
commit0d20a275a5baf8579c8b9111cf2ce6615874a6b6 (patch)
tree4391aee82c9128353237465ef6ca9d1e0071d0f8 /libs/hwui/Animator.h
parent477243b058bbc303bea6ba3aab445fd82a9f9155 (diff)
Revert "Revert "VectorDrawable native rendering - Step 5 of MANY""
This reverts commit e03ef25a3e44ef5d495e366c30b9b5b69fc58194. Change-Id: I9c2e1c891667451a3ee668e414bf337ad67279ab
Diffstat (limited to 'libs/hwui/Animator.h')
-rw-r--r--libs/hwui/Animator.h59
1 files changed, 40 insertions, 19 deletions
diff --git a/libs/hwui/Animator.h b/libs/hwui/Animator.h
index 2c9c9c3fe0f9..fcbc11b0306c 100644
--- a/libs/hwui/Animator.h
+++ b/libs/hwui/Animator.h
@@ -24,6 +24,8 @@
#include "utils/Macros.h"
+#include <vector>
+
namespace android {
namespace uirenderer {
@@ -59,14 +61,14 @@ public:
mMayRunAsync = mayRunAsync;
}
bool mayRunAsync() { return mMayRunAsync; }
- ANDROID_API void start() {
- if (mStagingPlayState == PlayState::NotStarted) {
- mStagingPlayState = PlayState::Running;
- } else {
- mStagingPlayState = PlayState::Restarted;
- }
- onStagingPlayStateChanged(); }
- ANDROID_API void end() { mStagingPlayState = PlayState::Finished; onStagingPlayStateChanged(); }
+ ANDROID_API void start();
+ ANDROID_API void reset();
+ ANDROID_API void reverse();
+ // Terminates the animation at its current progress.
+ ANDROID_API void cancel();
+
+ // Terminates the animation and skip to the end of the animation.
+ ANDROID_API void end();
void attach(RenderNode* target);
virtual void onAttached() {}
@@ -74,36 +76,41 @@ public:
void pushStaging(AnimationContext& context);
bool animate(AnimationContext& context);
- bool isRunning() { return mPlayState == PlayState::Running; }
+ bool isRunning() { return mPlayState == PlayState::Running
+ || mPlayState == PlayState::Reversing; }
bool isFinished() { return mPlayState == PlayState::Finished; }
float finalValue() { return mFinalValue; }
ANDROID_API virtual uint32_t dirtyMask() = 0;
void forceEndNow(AnimationContext& context);
+ RenderNode* target() { return mTarget; }
protected:
// PlayState is used by mStagingPlayState and mPlayState to track the state initiated from UI
// thread and Render Thread animation state, respectively.
// From the UI thread, mStagingPlayState transition looks like
- // NotStarted -> Running -> Finished
- // ^ |
- // | |
- // Restarted <------
+ // NotStarted -> Running/Reversing -> Finished
+ // ^ |
+ // | |
+ // ----------------------
// Note: For mStagingState, the Finished state (optional) is only set when the animation is
// terminated by user.
//
// On Render Thread, mPlayState transition:
- // NotStart -> Running -> Finished
- // ^ |
- // | |
- // -------------
+ // NotStart -> Running/Reversing-> Finished
+ // ^ |
+ // | |
+ // ------------------
+ // Note that if the animation is in Running/Reversing state, calling start or reverse again
+ // would do nothing if the animation has the same play direction as the request; otherwise,
+ // the animation would start from where it is and change direction (i.e. Reversing <-> Running)
enum class PlayState {
NotStarted,
Running,
+ Reversing,
Finished,
- Restarted,
};
BaseRenderNodeAnimator(float finalValue);
@@ -111,7 +118,6 @@ protected:
virtual float getValue(RenderNode* target) const = 0;
virtual void setValue(RenderNode* target, float value) = 0;
- RenderNode* target() { return mTarget; }
void callOnFinishedListener(AnimationContext& context);
@@ -132,13 +138,28 @@ protected:
nsecs_t mDuration;
nsecs_t mStartDelay;
bool mMayRunAsync;
+ // Play Time tracks the progress of animation, it should always be [0, mDuration], 0 being
+ // the beginning of the animation, will reach mDuration at the end of an animation.
+ nsecs_t mPlayTime;
sp<AnimationListener> mListener;
private:
+ enum class Request {
+ Start,
+ Reverse,
+ Reset,
+ Cancel,
+ End
+ };
inline void checkMutable();
virtual void transitionToRunning(AnimationContext& context);
void doSetStartValue(float value);
+ bool updatePlayTime(nsecs_t playTime);
+ void resolveStagingRequest(Request request);
+
+ std::vector<Request> mStagingRequests;
+
};
class RenderPropertyAnimator : public BaseRenderNodeAnimator {