1e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck/*
2e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Copyright (C) 2014 The Android Open Source Project
3e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *
4e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Licensed under the Apache License, Version 2.0 (the "License");
5e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * you may not use this file except in compliance with the License.
6e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * You may obtain a copy of the License at
7e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *
8e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *      http://www.apache.org/licenses/LICENSE-2.0
9e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *
10e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Unless required by applicable law or agreed to in writing, software
11e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * distributed under the License is distributed on an "AS IS" BASIS,
12e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * See the License for the specific language governing permissions and
14e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * limitations under the License.
15e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck */
16e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#ifndef ANIMATOR_H
17e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#define ANIMATOR_H
18e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
1951d6a3db97bdd5315f1a17a4b447d10a92217b98Chris Craik#include <memory>
20e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#include <cutils/compiler.h>
219fa4071c4768c63902c6a74a4b480b51a8b95d43John Reck#include <utils/RefBase.h>
2252244fff29042926e21fa897ef5ab11148e35299John Reck#include <utils/StrongPointer.h>
232dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudson#include <utils/Timers.h>
24e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
2552244fff29042926e21fa897ef5ab11148e35299John Reck#include "utils/Macros.h"
26e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
27c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu#include <vector>
28c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
29e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Recknamespace android {
30e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Recknamespace uirenderer {
31e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
32119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckclass AnimationContext;
33119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckclass BaseRenderNodeAnimator;
342dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudsonclass CanvasPropertyPrimitive;
352dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudsonclass CanvasPropertyPaint;
362dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudsonclass Interpolator;
3752244fff29042926e21fa897ef5ab11148e35299John Reckclass RenderNode;
38e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reckclass RenderProperties;
39e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
4052244fff29042926e21fa897ef5ab11148e35299John Reckclass AnimationListener : public VirtualLightRefBase {
4152244fff29042926e21fa897ef5ab11148e35299John Reckpublic:
42ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    ANDROID_API virtual void onAnimationFinished(BaseRenderNodeAnimator*) = 0;
4352244fff29042926e21fa897ef5ab11148e35299John Reckprotected:
4452244fff29042926e21fa897ef5ab11148e35299John Reck    ANDROID_API virtual ~AnimationListener() {}
4552244fff29042926e21fa897ef5ab11148e35299John Reck};
4652244fff29042926e21fa897ef5ab11148e35299John Reck
47f7167e8f286cff91dec01fdf617bf568f1d100e6Doris Liuenum class RepeatMode {
48f7167e8f286cff91dec01fdf617bf568f1d100e6Doris Liu    // These are the same values as the RESTART and REVERSE in ValueAnimator.java.
49f7167e8f286cff91dec01fdf617bf568f1d100e6Doris Liu    Restart = 1,
50f7167e8f286cff91dec01fdf617bf568f1d100e6Doris Liu    Reverse = 2
51f7167e8f286cff91dec01fdf617bf568f1d100e6Doris Liu};
52f7167e8f286cff91dec01fdf617bf568f1d100e6Doris Liu
53ff941dcd815021bb20d6504eb486acb1e50592c3John Reckclass BaseRenderNodeAnimator : public VirtualLightRefBase {
54ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    PREVENT_COPY_AND_ASSIGN(BaseRenderNodeAnimator);
5552244fff29042926e21fa897ef5ab11148e35299John Reckpublic:
56c6b3264e16f1d2b72e7f9508559981ce9970157cJohn Reck    ANDROID_API void setStartValue(float value);
5752244fff29042926e21fa897ef5ab11148e35299John Reck    ANDROID_API void setInterpolator(Interpolator* interpolator);
5852244fff29042926e21fa897ef5ab11148e35299John Reck    ANDROID_API void setDuration(nsecs_t durationInMs);
59315c329544d7c593d1072b071cbb92d9afe74021John Reck    ANDROID_API nsecs_t duration() { return mDuration; }
60ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    ANDROID_API void setStartDelay(nsecs_t startDelayInMs);
61ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    ANDROID_API nsecs_t startDelay() { return mStartDelay; }
6252244fff29042926e21fa897ef5ab11148e35299John Reck    ANDROID_API void setListener(AnimationListener* listener) {
6352244fff29042926e21fa897ef5ab11148e35299John Reck        mListener = listener;
6452244fff29042926e21fa897ef5ab11148e35299John Reck    }
65119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    AnimationListener* listener() { return mListener.get(); }
66f5945a0c8bb868f978d9d0d22043a8b44464a86eJohn Reck    ANDROID_API void setAllowRunningAsync(bool mayRunAsync) {
67f5945a0c8bb868f978d9d0d22043a8b44464a86eJohn Reck        mMayRunAsync = mayRunAsync;
68f5945a0c8bb868f978d9d0d22043a8b44464a86eJohn Reck    }
69f5945a0c8bb868f978d9d0d22043a8b44464a86eJohn Reck    bool mayRunAsync() { return mMayRunAsync; }
70c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    ANDROID_API void start();
71718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    ANDROID_API virtual void reset();
72c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    ANDROID_API void reverse();
73c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // Terminates the animation at its current progress.
74c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    ANDROID_API void cancel();
75c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
76c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // Terminates the animation and skip to the end of the animation.
77718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    ANDROID_API virtual void end();
7852244fff29042926e21fa897ef5ab11148e35299John Reck
798d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    void attach(RenderNode* target);
808d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    virtual void onAttached() {}
81d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    void detach() { mTarget = nullptr; }
82718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    ANDROID_API void pushStaging(AnimationContext& context);
83718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    ANDROID_API bool animate(AnimationContext& context);
84718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu
85718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    // Returns the remaining time in ms for the animation. Note this should only be called during
86718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    // an animation on RenderThread.
87718cd3eb70703c43f29ca37907bbf0e153d8cca0Doris Liu    ANDROID_API nsecs_t getRemainingPlayTime();
88ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
89c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    bool isRunning() { return mPlayState == PlayState::Running
90c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            || mPlayState == PlayState::Reversing; }
91b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    bool isFinished() { return mPlayState == PlayState::Finished; }
92ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    float finalValue() { return mFinalValue; }
9352244fff29042926e21fa897ef5ab11148e35299John Reck
94a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    ANDROID_API virtual uint32_t dirtyMask() = 0;
952218472d23483f09341bf655d55db21dcbabc1b6John Reck
96e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck    void forceEndNow(AnimationContext& context);
97c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    RenderNode* target() { return mTarget; }
988b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    RenderNode* stagingTarget() { return mStagingTarget; }
99e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck
10052244fff29042926e21fa897ef5ab11148e35299John Reckprotected:
101766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // PlayState is used by mStagingPlayState and mPlayState to track the state initiated from UI
102766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // thread and Render Thread animation state, respectively.
103766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // From the UI thread, mStagingPlayState transition looks like
104c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // NotStarted -> Running/Reversing -> Finished
105c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    //                ^                     |
106c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    //                |                     |
107c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    //                ----------------------
108766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // Note: For mStagingState, the Finished state (optional) is only set when the animation is
109766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // terminated by user.
110766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    //
111766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // On Render Thread, mPlayState transition:
112c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // NotStart -> Running/Reversing-> Finished
113c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    //                ^                 |
114c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    //                |                 |
115c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    //                ------------------
116c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // Note that if the animation is in Running/Reversing state, calling start or reverse again
117c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // would do nothing if the animation has the same play direction as the request; otherwise,
118c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // the animation would start from where it is and change direction (i.e. Reversing <-> Running)
119766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu
120b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    enum class PlayState {
121b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        NotStarted,
122b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        Running,
123c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        Reversing,
124b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        Finished,
125b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    };
126b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik
127ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    BaseRenderNodeAnimator(float finalValue);
128ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    virtual ~BaseRenderNodeAnimator();
12952244fff29042926e21fa897ef5ab11148e35299John Reck
130ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    virtual float getValue(RenderNode* target) const = 0;
131ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    virtual void setValue(RenderNode* target, float value) = 0;
13252244fff29042926e21fa897ef5ab11148e35299John Reck
133119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    void callOnFinishedListener(AnimationContext& context);
13452244fff29042926e21fa897ef5ab11148e35299John Reck
1358d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    virtual void onStagingPlayStateChanged() {}
136766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    virtual void onPlayTimeChanged(nsecs_t playTime) {}
1378b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    virtual void onPushStaging() {}
1388d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck
1398d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    RenderNode* mTarget;
1408b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    RenderNode* mStagingTarget;
1418d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck
142ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    float mFinalValue;
143ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    float mDeltaValue;
144ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    float mFromValue;
145ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
14651d6a3db97bdd5315f1a17a4b447d10a92217b98Chris Craik    std::unique_ptr<Interpolator> mInterpolator;
14768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    PlayState mStagingPlayState;
14852244fff29042926e21fa897ef5ab11148e35299John Reck    PlayState mPlayState;
14968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    bool mHasStartValue;
150ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    nsecs_t mStartTime;
151ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    nsecs_t mDuration;
152ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    nsecs_t mStartDelay;
153f5945a0c8bb868f978d9d0d22043a8b44464a86eJohn Reck    bool mMayRunAsync;
154c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // Play Time tracks the progress of animation, it should always be [0, mDuration], 0 being
155c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    // the beginning of the animation, will reach mDuration at the end of an animation.
156c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    nsecs_t mPlayTime;
15752244fff29042926e21fa897ef5ab11148e35299John Reck
158ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    sp<AnimationListener> mListener;
15968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck
16068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckprivate:
161c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    enum class Request {
162c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        Start,
163c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        Reverse,
164c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        Reset,
165c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        Cancel,
166c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        End
167c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    };
1686725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu
1696725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu    // Defines different actions upon finish.
1706725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu    enum class Action {
1716725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu        // For animations that got canceled or finished normally. no more action needs to be done.
1726725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu        None,
1736725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu        // For animations that get reset, the reset will happen in the next animation pulse.
1746725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu        Reset,
1756725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu        // For animations being ended, in the next animation pulse the animation will skip to end.
1766725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu        End
1776725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu    };
1786725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu
17968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    inline void checkMutable();
180119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    virtual void transitionToRunning(AnimationContext& context);
1818d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    void doSetStartValue(float value);
182c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    bool updatePlayTime(nsecs_t playTime);
183c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    void resolveStagingRequest(Request request);
184c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
185c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    std::vector<Request> mStagingRequests;
1866725d581eb3c13591a4ff276413dbfa0fc13e739Doris Liu    Action mPendingActionUponFinish = Action::None;
18752244fff29042926e21fa897ef5ab11148e35299John Reck};
18852244fff29042926e21fa897ef5ab11148e35299John Reck
18952244fff29042926e21fa897ef5ab11148e35299John Reckclass RenderPropertyAnimator : public BaseRenderNodeAnimator {
19052244fff29042926e21fa897ef5ab11148e35299John Reckpublic:
191e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    enum RenderProperty {
192e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        TRANSLATION_X = 0,
193e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        TRANSLATION_Y,
194e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        TRANSLATION_Z,
195e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        SCALE_X,
196e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        SCALE_Y,
197e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        ROTATION,
198e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        ROTATION_X,
199e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        ROTATION_Y,
200e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        X,
201e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        Y,
202e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        Z,
203e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        ALPHA,
204e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    };
205e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
206ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    ANDROID_API RenderPropertyAnimator(RenderProperty property, float finalValue);
207ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
2082218472d23483f09341bf655d55db21dcbabc1b6John Reck    ANDROID_API virtual uint32_t dirtyMask();
2092218472d23483f09341bf655d55db21dcbabc1b6John Reck
21052244fff29042926e21fa897ef5ab11148e35299John Reckprotected:
211d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual float getValue(RenderNode* target) const override;
212d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void setValue(RenderNode* target, float value) override;
213d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void onAttached() override;
214d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void onStagingPlayStateChanged() override;
2158b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    virtual void onPushStaging() override;
21652244fff29042926e21fa897ef5ab11148e35299John Reck
21752244fff29042926e21fa897ef5ab11148e35299John Reckprivate:
21879c7de77a7da9cbcb9428ab6203987feb35a427fJohn Reck    typedef bool (RenderProperties::*SetFloatProperty)(float value);
21952244fff29042926e21fa897ef5ab11148e35299John Reck    typedef float (RenderProperties::*GetFloatProperty)() const;
220e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
221ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    struct PropertyAccessors;
222ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    const PropertyAccessors* mPropertyAccess;
22352244fff29042926e21fa897ef5ab11148e35299John Reck
22452244fff29042926e21fa897ef5ab11148e35299John Reck    static const PropertyAccessors PROPERTY_ACCESSOR_LUT[];
2258b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    bool mShouldSyncPropertyFields = false;
2268b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    bool mShouldUpdateStagingProperties = false;
22752244fff29042926e21fa897ef5ab11148e35299John Reck};
228e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
22952244fff29042926e21fa897ef5ab11148e35299John Reckclass CanvasPropertyPrimitiveAnimator : public BaseRenderNodeAnimator {
23052244fff29042926e21fa897ef5ab11148e35299John Reckpublic:
23152244fff29042926e21fa897ef5ab11148e35299John Reck    ANDROID_API CanvasPropertyPrimitiveAnimator(CanvasPropertyPrimitive* property,
232ff941dcd815021bb20d6504eb486acb1e50592c3John Reck            float finalValue);
233a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
234a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    ANDROID_API virtual uint32_t dirtyMask();
235a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
236e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reckprotected:
237d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual float getValue(RenderNode* target) const override;
238d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void setValue(RenderNode* target, float value) override;
23952244fff29042926e21fa897ef5ab11148e35299John Reckprivate:
24052244fff29042926e21fa897ef5ab11148e35299John Reck    sp<CanvasPropertyPrimitive> mProperty;
24152244fff29042926e21fa897ef5ab11148e35299John Reck};
24252244fff29042926e21fa897ef5ab11148e35299John Reck
24352244fff29042926e21fa897ef5ab11148e35299John Reckclass CanvasPropertyPaintAnimator : public BaseRenderNodeAnimator {
24452244fff29042926e21fa897ef5ab11148e35299John Reckpublic:
24552244fff29042926e21fa897ef5ab11148e35299John Reck    enum PaintField {
24652244fff29042926e21fa897ef5ab11148e35299John Reck        STROKE_WIDTH = 0,
24752244fff29042926e21fa897ef5ab11148e35299John Reck        ALPHA,
24852244fff29042926e21fa897ef5ab11148e35299John Reck    };
249e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
25052244fff29042926e21fa897ef5ab11148e35299John Reck    ANDROID_API CanvasPropertyPaintAnimator(CanvasPropertyPaint* property,
251ff941dcd815021bb20d6504eb486acb1e50592c3John Reck            PaintField field, float finalValue);
252a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
253a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    ANDROID_API virtual uint32_t dirtyMask();
254a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
25552244fff29042926e21fa897ef5ab11148e35299John Reckprotected:
256d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual float getValue(RenderNode* target) const override;
257d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void setValue(RenderNode* target, float value) override;
258e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reckprivate:
25952244fff29042926e21fa897ef5ab11148e35299John Reck    sp<CanvasPropertyPaint> mProperty;
26052244fff29042926e21fa897ef5ab11148e35299John Reck    PaintField mField;
261e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck};
262e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
263d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reckclass RevealAnimator : public BaseRenderNodeAnimator {
264d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reckpublic:
265af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris Craik    ANDROID_API RevealAnimator(int centerX, int centerY,
266d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck            float startValue, float finalValue);
267a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
268a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    ANDROID_API virtual uint32_t dirtyMask();
269a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
270d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reckprotected:
271d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual float getValue(RenderNode* target) const override;
272d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void setValue(RenderNode* target, float value) override;
273d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck
274d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reckprivate:
275d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck    int mCenterX, mCenterY;
276d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck};
277d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck
278e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck} /* namespace uirenderer */
279e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck} /* namespace android */
280e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
281e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#endif /* ANIMATOR_H */
282