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
17e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#include "Animator.h"
18e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
1968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck#include <inttypes.h>
20e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#include <set>
21e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
22119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck#include "AnimationContext.h"
232dc236b2bae13b9a0ed9b3f7320502aecd7983b3Tom Hudson#include "Interpolator.h"
2452244fff29042926e21fa897ef5ab11148e35299John Reck#include "RenderNode.h"
25e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck#include "RenderProperties.h"
26e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
27e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Recknamespace android {
28e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Recknamespace uirenderer {
29e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
30e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck/************************************************************
31ff941dcd815021bb20d6504eb486acb1e50592c3John Reck *  BaseRenderNodeAnimator
32e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck ************************************************************/
33e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
34ff941dcd815021bb20d6504eb486acb1e50592c3John ReckBaseRenderNodeAnimator::BaseRenderNodeAnimator(float finalValue)
35d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik        : mTarget(nullptr)
368b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        , mStagingTarget(nullptr)
378d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck        , mFinalValue(finalValue)
38ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        , mDeltaValue(0)
39ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        , mFromValue(0)
40b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        , mStagingPlayState(PlayState::NotStarted)
41b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        , mPlayState(PlayState::NotStarted)
4268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        , mHasStartValue(false)
43e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck        , mStartTime(0)
44ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette        , mDuration(300)
45572d9acd598517c20c7bf2feb189357e925fa879Chris Craik        , mStartDelay(0)
46c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        , mMayRunAsync(true)
47c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        , mPlayTime(0) {
48e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck}
49e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
50ff941dcd815021bb20d6504eb486acb1e50592c3John ReckBaseRenderNodeAnimator::~BaseRenderNodeAnimator() {
5168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck}
5268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck
5368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckvoid BaseRenderNodeAnimator::checkMutable() {
5468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    // Should be impossible to hit as the Java-side also has guards for this
55b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    LOG_ALWAYS_FATAL_IF(mStagingPlayState != PlayState::NotStarted,
5668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck            "Animator has already been started!");
57e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck}
58e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
59ff941dcd815021bb20d6504eb486acb1e50592c3John Reckvoid BaseRenderNodeAnimator::setInterpolator(Interpolator* interpolator) {
6068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    checkMutable();
6151d6a3db97bdd5315f1a17a4b447d10a92217b98Chris Craik    mInterpolator.reset(interpolator);
62e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck}
63e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
64ff941dcd815021bb20d6504eb486acb1e50592c3John Reckvoid BaseRenderNodeAnimator::setStartValue(float value) {
6568bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    checkMutable();
6668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    doSetStartValue(value);
67ff941dcd815021bb20d6504eb486acb1e50592c3John Reck}
68ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
6968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reckvoid BaseRenderNodeAnimator::doSetStartValue(float value) {
7068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    mFromValue = value;
7168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    mDeltaValue = (mFinalValue - mFromValue);
7268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    mHasStartValue = true;
73ff941dcd815021bb20d6504eb486acb1e50592c3John Reck}
74ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
75ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverettevoid BaseRenderNodeAnimator::setDuration(nsecs_t duration) {
7668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    checkMutable();
77ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    mDuration = duration;
78ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette}
79ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette
80ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverettevoid BaseRenderNodeAnimator::setStartDelay(nsecs_t startDelay) {
8168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    checkMutable();
82ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    mStartDelay = startDelay;
83ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette}
84ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette
858d8af3c1b768d590754d657a7d1242dcb462454bJohn Reckvoid BaseRenderNodeAnimator::attach(RenderNode* target) {
868b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    mStagingTarget = target;
878d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    onAttached();
888d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck}
898d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck
90c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liuvoid BaseRenderNodeAnimator::start() {
91c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingPlayState = PlayState::Running;
92c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingRequests.push_back(Request::Start);
93c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    onStagingPlayStateChanged();
94c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
95c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
96c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liuvoid BaseRenderNodeAnimator::cancel() {
97c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingPlayState = PlayState::Finished;
98c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingRequests.push_back(Request::Cancel);
99c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    onStagingPlayStateChanged();
100c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
101c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
102c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liuvoid BaseRenderNodeAnimator::reset() {
103c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingPlayState = PlayState::Finished;
104c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingRequests.push_back(Request::Reset);
105c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    onStagingPlayStateChanged();
106c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
107c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
108c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liuvoid BaseRenderNodeAnimator::reverse() {
109c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingPlayState = PlayState::Reversing;
110c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingRequests.push_back(Request::Reverse);
111c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    onStagingPlayStateChanged();
112c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
113c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
114c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liuvoid BaseRenderNodeAnimator::end() {
115c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingPlayState = PlayState::Finished;
116c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mStagingRequests.push_back(Request::End);
117c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    onStagingPlayStateChanged();
118c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
119c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
120c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liuvoid BaseRenderNodeAnimator::resolveStagingRequest(Request request) {
121c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    switch (request) {
122c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    case Request::Start:
123c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ?
124c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        mPlayTime : 0;
125c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayState = PlayState::Running;
126c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        break;
127c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    case Request::Reverse:
128c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayTime = (mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) ?
129c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        mPlayTime : mDuration;
130c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayState = PlayState::Reversing;
131c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        break;
132c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    case Request::Reset:
133c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayTime = 0;
134c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayState = PlayState::Finished;
135c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        break;
136c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    case Request::Cancel:
137c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayState = PlayState::Finished;
138c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        break;
139c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    case Request::End:
140c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayTime = mPlayState == PlayState::Reversing ? 0 : mDuration;
141c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayState = PlayState::Finished;
142c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        break;
143c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    default:
144c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        LOG_ALWAYS_FATAL("Invalid staging request: %d", static_cast<int>(request));
145c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    };
146c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
147c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
148119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckvoid BaseRenderNodeAnimator::pushStaging(AnimationContext& context) {
1498b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    if (mStagingTarget) {
1508b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        RenderNode* oldTarget = mTarget;
1518b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        mTarget = mStagingTarget;
1528b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        mStagingTarget = nullptr;
1538b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        if (oldTarget && oldTarget != mTarget) {
1548b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu            oldTarget->onAnimatorTargetChanged(this);
1558b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        }
1568b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    }
1578b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu
15868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    if (!mHasStartValue) {
1598d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck        doSetStartValue(getValue(mTarget));
160ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    }
161c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
162c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    if (!mStagingRequests.empty()) {
163148f57fc267b3b0121ff66e4ec4f1798f5b67d52Doris Liu        // No interpolator was set, use the default
164148f57fc267b3b0121ff66e4ec4f1798f5b67d52Doris Liu        if (mPlayState == PlayState::NotStarted && !mInterpolator) {
165148f57fc267b3b0121ff66e4ec4f1798f5b67d52Doris Liu            mInterpolator.reset(Interpolator::createDefaultInterpolator());
166148f57fc267b3b0121ff66e4ec4f1798f5b67d52Doris Liu        }
167c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        // Keep track of the play state and play time before they are changed when
168c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        // staging requests are resolved.
169c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        nsecs_t currentPlayTime = mPlayTime;
170c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        PlayState prevFramePlayState = mPlayState;
171c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
172c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        // Resolve staging requests one by one.
173c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        for (Request request : mStagingRequests) {
174c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            resolveStagingRequest(request);
175766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu        }
176c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mStagingRequests.clear();
177c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu
178c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        if (mStagingPlayState == PlayState::Finished) {
179c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            // Set the staging play time and end the animation
180c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            updatePlayTime(mPlayTime);
1814d2c47206a8e1706e5f89ef73c0e50e7321bf862John Reck            callOnFinishedListener(context);
182c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        } else if (mStagingPlayState == PlayState::Running
183c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                || mStagingPlayState == PlayState::Reversing) {
184c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            bool changed = currentPlayTime != mPlayTime || prevFramePlayState != mStagingPlayState;
185c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            if (prevFramePlayState != mStagingPlayState) {
186c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                transitionToRunning(context);
187c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            }
188c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            if (changed) {
189c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                // Now we need to seek to the stagingPlayTime (i.e. the animation progress that was
190c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                // requested from UI thread). It is achieved by modifying mStartTime, such that
191c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                // current time - mStartTime = stagingPlayTime (or mDuration -stagingPlayTime in the
192c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                // case of reversing)
193c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                nsecs_t currentFrameTime = context.frameTimeMs();
194c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                if (mPlayState == PlayState::Reversing) {
195c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    // Reverse is not supported for animations with a start delay, so here we
196c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    // assume no start delay.
197c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    mStartTime = currentFrameTime  - (mDuration - mPlayTime);
198c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                } else {
199c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    // Animation should play forward
200c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    if (mPlayTime == 0) {
201c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        // If the request is to start from the beginning, include start delay.
202c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        mStartTime = currentFrameTime + mStartDelay;
203c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    } else {
204c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        // If the request is to seek to a non-zero play time, then we skip start
205c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        // delay.
206c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                        mStartTime = currentFrameTime - mPlayTime;
207c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                    }
208c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu                }
209c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu            }
21068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        }
21168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    }
2128b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    onPushStaging();
21368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck}
214ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette
215119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckvoid BaseRenderNodeAnimator::transitionToRunning(AnimationContext& context) {
216119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    nsecs_t frameTimeMs = context.frameTimeMs();
217119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    LOG_ALWAYS_FATAL_IF(frameTimeMs <= 0, "%" PRId64 " isn't a real frame time!", frameTimeMs);
21868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    if (mStartDelay < 0 || mStartDelay > 50000) {
21968bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        ALOGW("Your start delay is strange and confusing: %" PRId64, mStartDelay);
22068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    }
221119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    mStartTime = frameTimeMs + mStartDelay;
22268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    if (mStartTime < 0) {
22368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        ALOGW("Ended up with a really weird start time of %" PRId64
22468bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck                " with frame time %" PRId64 " and start delay %" PRId64,
225119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck                mStartTime, frameTimeMs, mStartDelay);
22668bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        // Set to 0 so that the animate() basically instantly finishes
22768bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        mStartTime = 0;
22868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    }
229952670d9cf533ed3529b7960f6c88399a400a147Doris Liu    if (mDuration < 0) {
23068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        ALOGW("Your duration is strange and confusing: %" PRId64, mDuration);
23168bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    }
23268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck}
23368bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck
234119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckbool BaseRenderNodeAnimator::animate(AnimationContext& context) {
235b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    if (mPlayState < PlayState::Running) {
236ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette        return false;
237ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette    }
238b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    if (mPlayState == PlayState::Finished) {
23932fb6307de7c3ee9399a39dc6734f1c82ffd1dcbJohn Reck        return true;
24032fb6307de7c3ee9399a39dc6734f1c82ffd1dcbJohn Reck    }
241ad2f8e334f3ef22d3e412b0660a2e1f996f94116Alan Viverette
242766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // This should be set before setValue() so animators can query this time when setValue
243766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu    // is called.
244c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    nsecs_t currentPlayTime = context.frameTimeMs() - mStartTime;
245c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    bool finished = updatePlayTime(currentPlayTime);
246c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    if (finished && mPlayState != PlayState::Finished) {
247c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        mPlayState = PlayState::Finished;
248c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        callOnFinishedListener(context);
249c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    }
250c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    return finished;
251c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu}
252766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu
253c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liubool BaseRenderNodeAnimator::updatePlayTime(nsecs_t playTime) {
254c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    mPlayTime = mPlayState == PlayState::Reversing ? mDuration - playTime : playTime;
255c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    onPlayTimeChanged(mPlayTime);
2568d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    // If BaseRenderNodeAnimator is handling the delay (not typical), then
2578d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    // because the staging properties reflect the final value, we always need
2588d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    // to call setValue even if the animation isn't yet running or is still
2598d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    // being delayed as we need to override the staging value
260c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    if (playTime < 0) {
2618d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck        setValue(mTarget, mFromValue);
26268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck        return false;
263e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    }
264e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
265e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    float fraction = 1.0f;
266c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    if ((mPlayState == PlayState::Running || mPlayState == PlayState::Reversing) && mDuration > 0) {
267c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu        fraction = mPlayTime / (float) mDuration;
26868bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    }
269c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    fraction = MathUtils::clamp(fraction, 0.0f, 1.0f);
27068bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck
271e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    fraction = mInterpolator->interpolate(fraction);
2728d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    setValue(mTarget, mFromValue + (mDeltaValue * fraction));
273e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
274c4bb185d41cfb960ed9a3178a4f8974c351abdb0Doris Liu    return playTime >= mDuration;
275e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck}
276e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
277e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reckvoid BaseRenderNodeAnimator::forceEndNow(AnimationContext& context) {
278b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    if (mPlayState < PlayState::Finished) {
279b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik        mPlayState = PlayState::Finished;
280e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck        callOnFinishedListener(context);
281e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck    }
282e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck}
283e2478d45ccbe5b6abb360ac9d44771b5f4a50bdeJohn Reck
284119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckvoid BaseRenderNodeAnimator::callOnFinishedListener(AnimationContext& context) {
28552244fff29042926e21fa897ef5ab11148e35299John Reck    if (mListener.get()) {
286119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck        context.callOnFinished(this, mListener.get());
28752244fff29042926e21fa897ef5ab11148e35299John Reck    }
28852244fff29042926e21fa897ef5ab11148e35299John Reck}
28952244fff29042926e21fa897ef5ab11148e35299John Reck
290e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck/************************************************************
29152244fff29042926e21fa897ef5ab11148e35299John Reck *  RenderPropertyAnimator
29252244fff29042926e21fa897ef5ab11148e35299John Reck ************************************************************/
29352244fff29042926e21fa897ef5ab11148e35299John Reck
294ff941dcd815021bb20d6504eb486acb1e50592c3John Reckstruct RenderPropertyAnimator::PropertyAccessors {
295ff941dcd815021bb20d6504eb486acb1e50592c3John Reck   RenderNode::DirtyPropertyMask dirtyMask;
296ff941dcd815021bb20d6504eb486acb1e50592c3John Reck   GetFloatProperty getter;
297ff941dcd815021bb20d6504eb486acb1e50592c3John Reck   SetFloatProperty setter;
298ff941dcd815021bb20d6504eb486acb1e50592c3John Reck};
299ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
30052244fff29042926e21fa897ef5ab11148e35299John Reck// Maps RenderProperty enum to accessors
30152244fff29042926e21fa897ef5ab11148e35299John Reckconst RenderPropertyAnimator::PropertyAccessors RenderPropertyAnimator::PROPERTY_ACCESSOR_LUT[] = {
302ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationX, &RenderProperties::setTranslationX },
303ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::TRANSLATION_Y, &RenderProperties::getTranslationY, &RenderProperties::setTranslationY },
304ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationZ, &RenderProperties::setTranslationZ },
305ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::SCALE_X, &RenderProperties::getScaleX, &RenderProperties::setScaleX },
306ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::SCALE_Y, &RenderProperties::getScaleY, &RenderProperties::setScaleY },
307ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::ROTATION, &RenderProperties::getRotation, &RenderProperties::setRotation },
308ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::ROTATION_X, &RenderProperties::getRotationX, &RenderProperties::setRotationX },
309ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::ROTATION_Y, &RenderProperties::getRotationY, &RenderProperties::setRotationY },
310ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::X, &RenderProperties::getX, &RenderProperties::setX },
311ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::Y, &RenderProperties::getY, &RenderProperties::setY },
312ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::Z, &RenderProperties::getZ, &RenderProperties::setZ },
313ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    {RenderNode::ALPHA, &RenderProperties::getAlpha, &RenderProperties::setAlpha },
31452244fff29042926e21fa897ef5ab11148e35299John Reck};
31552244fff29042926e21fa897ef5ab11148e35299John Reck
316ff941dcd815021bb20d6504eb486acb1e50592c3John ReckRenderPropertyAnimator::RenderPropertyAnimator(RenderProperty property, float finalValue)
317ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        : BaseRenderNodeAnimator(finalValue)
318ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        , mPropertyAccess(&(PROPERTY_ACCESSOR_LUT[property])) {
319ff941dcd815021bb20d6504eb486acb1e50592c3John Reck}
320ff941dcd815021bb20d6504eb486acb1e50592c3John Reck
3218d8af3c1b768d590754d657a7d1242dcb462454bJohn Reckvoid RenderPropertyAnimator::onAttached() {
32268bfe0a37a0dcef52abd81688d8520c5d16e1a85John Reck    if (!mHasStartValue
3238b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu            && mStagingTarget->isPropertyFieldDirty(mPropertyAccess->dirtyMask)) {
3248b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        setStartValue((mStagingTarget->stagingProperties().*mPropertyAccess->getter)());
3258d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck    }
3268d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck}
3278d8af3c1b768d590754d657a7d1242dcb462454bJohn Reck
3288d8af3c1b768d590754d657a7d1242dcb462454bJohn Reckvoid RenderPropertyAnimator::onStagingPlayStateChanged() {
329b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    if (mStagingPlayState == PlayState::Running) {
3308b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        if (mStagingTarget) {
3318b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu            (mStagingTarget->mutateStagingProperties().*mPropertyAccess->setter)(finalValue());
3328b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        } else {
3338b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu            // In the case of start delay where stagingTarget has been sync'ed over and null'ed
3348b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu            // we delay the properties update to push staging.
3358b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu            mShouldUpdateStagingProperties = true;
3368b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        }
337b9ce116dac378b4cf4490f265dcbd5704a1dd43cChris Craik    } else if (mStagingPlayState == PlayState::Finished) {
33832fb6307de7c3ee9399a39dc6734f1c82ffd1dcbJohn Reck        // We're being canceled, so make sure that whatever values the UI thread
33932fb6307de7c3ee9399a39dc6734f1c82ffd1dcbJohn Reck        // is observing for us is pushed over
3408b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        mShouldSyncPropertyFields = true;
3418b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    }
3428b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu}
3438b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu
3448b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liuvoid RenderPropertyAnimator::onPushStaging() {
3458b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    if (mShouldUpdateStagingProperties) {
3468b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        (mTarget->mutateStagingProperties().*mPropertyAccess->setter)(finalValue());
3478b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        mShouldUpdateStagingProperties = false;
3488b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    }
3498b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu
3508b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu    if (mShouldSyncPropertyFields) {
35132fb6307de7c3ee9399a39dc6734f1c82ffd1dcbJohn Reck        mTarget->setPropertyFieldsDirty(dirtyMask());
3528b083206aef627b6445a8c6be8bf5bb1d778a7f8Doris Liu        mShouldSyncPropertyFields = false;
353ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    }
35452244fff29042926e21fa897ef5ab11148e35299John Reck}
35552244fff29042926e21fa897ef5ab11148e35299John Reck
3562218472d23483f09341bf655d55db21dcbabc1b6John Reckuint32_t RenderPropertyAnimator::dirtyMask() {
3572218472d23483f09341bf655d55db21dcbabc1b6John Reck    return mPropertyAccess->dirtyMask;
3582218472d23483f09341bf655d55db21dcbabc1b6John Reck}
3592218472d23483f09341bf655d55db21dcbabc1b6John Reck
360ff941dcd815021bb20d6504eb486acb1e50592c3John Reckfloat RenderPropertyAnimator::getValue(RenderNode* target) const {
361ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    return (target->properties().*mPropertyAccess->getter)();
36252244fff29042926e21fa897ef5ab11148e35299John Reck}
36352244fff29042926e21fa897ef5ab11148e35299John Reck
364ff941dcd815021bb20d6504eb486acb1e50592c3John Reckvoid RenderPropertyAnimator::setValue(RenderNode* target, float value) {
365ff941dcd815021bb20d6504eb486acb1e50592c3John Reck    (target->animatorProperties().*mPropertyAccess->setter)(value);
36652244fff29042926e21fa897ef5ab11148e35299John Reck}
36752244fff29042926e21fa897ef5ab11148e35299John Reck
36852244fff29042926e21fa897ef5ab11148e35299John Reck/************************************************************
36952244fff29042926e21fa897ef5ab11148e35299John Reck *  CanvasPropertyPrimitiveAnimator
37052244fff29042926e21fa897ef5ab11148e35299John Reck ************************************************************/
37152244fff29042926e21fa897ef5ab11148e35299John Reck
37252244fff29042926e21fa897ef5ab11148e35299John ReckCanvasPropertyPrimitiveAnimator::CanvasPropertyPrimitiveAnimator(
373ff941dcd815021bb20d6504eb486acb1e50592c3John Reck                CanvasPropertyPrimitive* property, float finalValue)
374ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        : BaseRenderNodeAnimator(finalValue)
37552244fff29042926e21fa897ef5ab11148e35299John Reck        , mProperty(property) {
37652244fff29042926e21fa897ef5ab11148e35299John Reck}
37752244fff29042926e21fa897ef5ab11148e35299John Reck
37864bb413a664001c95c8439cf097dc3033f4ed733Andreas Gampefloat CanvasPropertyPrimitiveAnimator::getValue(RenderNode* target) const {
37952244fff29042926e21fa897ef5ab11148e35299John Reck    return mProperty->value;
38052244fff29042926e21fa897ef5ab11148e35299John Reck}
38152244fff29042926e21fa897ef5ab11148e35299John Reck
38264bb413a664001c95c8439cf097dc3033f4ed733Andreas Gampevoid CanvasPropertyPrimitiveAnimator::setValue(RenderNode* target, float value) {
38352244fff29042926e21fa897ef5ab11148e35299John Reck    mProperty->value = value;
38452244fff29042926e21fa897ef5ab11148e35299John Reck}
38552244fff29042926e21fa897ef5ab11148e35299John Reck
386a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reckuint32_t CanvasPropertyPrimitiveAnimator::dirtyMask() {
387a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    return RenderNode::DISPLAY_LIST;
388a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck}
389a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
39052244fff29042926e21fa897ef5ab11148e35299John Reck/************************************************************
39152244fff29042926e21fa897ef5ab11148e35299John Reck *  CanvasPropertySkPaintAnimator
39252244fff29042926e21fa897ef5ab11148e35299John Reck ************************************************************/
39352244fff29042926e21fa897ef5ab11148e35299John Reck
39452244fff29042926e21fa897ef5ab11148e35299John ReckCanvasPropertyPaintAnimator::CanvasPropertyPaintAnimator(
395ff941dcd815021bb20d6504eb486acb1e50592c3John Reck                CanvasPropertyPaint* property, PaintField field, float finalValue)
396ff941dcd815021bb20d6504eb486acb1e50592c3John Reck        : BaseRenderNodeAnimator(finalValue)
39752244fff29042926e21fa897ef5ab11148e35299John Reck        , mProperty(property)
39852244fff29042926e21fa897ef5ab11148e35299John Reck        , mField(field) {
39952244fff29042926e21fa897ef5ab11148e35299John Reck}
40052244fff29042926e21fa897ef5ab11148e35299John Reck
40164bb413a664001c95c8439cf097dc3033f4ed733Andreas Gampefloat CanvasPropertyPaintAnimator::getValue(RenderNode* target) const {
40252244fff29042926e21fa897ef5ab11148e35299John Reck    switch (mField) {
40352244fff29042926e21fa897ef5ab11148e35299John Reck    case STROKE_WIDTH:
40452244fff29042926e21fa897ef5ab11148e35299John Reck        return mProperty->value.getStrokeWidth();
40552244fff29042926e21fa897ef5ab11148e35299John Reck    case ALPHA:
40652244fff29042926e21fa897ef5ab11148e35299John Reck        return mProperty->value.getAlpha();
40752244fff29042926e21fa897ef5ab11148e35299John Reck    }
40852244fff29042926e21fa897ef5ab11148e35299John Reck    LOG_ALWAYS_FATAL("Unknown field %d", (int) mField);
40952244fff29042926e21fa897ef5ab11148e35299John Reck    return -1;
41052244fff29042926e21fa897ef5ab11148e35299John Reck}
41152244fff29042926e21fa897ef5ab11148e35299John Reck
412531ee701ddca2d1604fcce8e5d6d8837a3f651acJohn Reckstatic uint8_t to_uint8(float value) {
413531ee701ddca2d1604fcce8e5d6d8837a3f651acJohn Reck    int c = (int) (value + .5f);
414531ee701ddca2d1604fcce8e5d6d8837a3f651acJohn Reck    return static_cast<uint8_t>( c < 0 ? 0 : c > 255 ? 255 : c );
415531ee701ddca2d1604fcce8e5d6d8837a3f651acJohn Reck}
416531ee701ddca2d1604fcce8e5d6d8837a3f651acJohn Reck
41764bb413a664001c95c8439cf097dc3033f4ed733Andreas Gampevoid CanvasPropertyPaintAnimator::setValue(RenderNode* target, float value) {
41852244fff29042926e21fa897ef5ab11148e35299John Reck    switch (mField) {
41952244fff29042926e21fa897ef5ab11148e35299John Reck    case STROKE_WIDTH:
42052244fff29042926e21fa897ef5ab11148e35299John Reck        mProperty->value.setStrokeWidth(value);
42152244fff29042926e21fa897ef5ab11148e35299John Reck        return;
42252244fff29042926e21fa897ef5ab11148e35299John Reck    case ALPHA:
423531ee701ddca2d1604fcce8e5d6d8837a3f651acJohn Reck        mProperty->value.setAlpha(to_uint8(value));
42452244fff29042926e21fa897ef5ab11148e35299John Reck        return;
42552244fff29042926e21fa897ef5ab11148e35299John Reck    }
42652244fff29042926e21fa897ef5ab11148e35299John Reck    LOG_ALWAYS_FATAL("Unknown field %d", (int) mField);
427e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck}
428e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
429a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reckuint32_t CanvasPropertyPaintAnimator::dirtyMask() {
430a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    return RenderNode::DISPLAY_LIST;
431a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck}
432a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
433af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris CraikRevealAnimator::RevealAnimator(int centerX, int centerY,
434d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck        float startValue, float finalValue)
435d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck        : BaseRenderNodeAnimator(finalValue)
436d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck        , mCenterX(centerX)
437af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris Craik        , mCenterY(centerY) {
438d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck    setStartValue(startValue);
439d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck}
440d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck
441d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reckfloat RevealAnimator::getValue(RenderNode* target) const {
442af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris Craik    return target->properties().getRevealClip().getRadius();
443d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck}
444d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck
445d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reckvoid RevealAnimator::setValue(RenderNode* target, float value) {
446af4d04cab6d48ae0d6a5e79bd30f679af87abaadChris Craik    target->animatorProperties().mutableRevealClip().set(true,
447d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck            mCenterX, mCenterY, value);
448d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck}
449d3de42cae84fadfa1befd082a2cf1bf72f9ad82aJohn Reck
450a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reckuint32_t RevealAnimator::dirtyMask() {
451a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck    return RenderNode::GENERIC;
452a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck}
453a7c2ea20c43ab797bef5801530687e22e83def8fJohn Reck
454e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck} /* namespace uirenderer */
455e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck} /* namespace android */
456