John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 17 | #include "Animator.h" |
| 18 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 19 | #include <inttypes.h> |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 20 | #include <set> |
| 21 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 22 | #include "AnimationContext.h" |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 23 | #include "RenderNode.h" |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 24 | #include "RenderProperties.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace uirenderer { |
| 28 | |
| 29 | /************************************************************ |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 30 | * BaseRenderNodeAnimator |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 31 | ************************************************************/ |
| 32 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 33 | BaseRenderNodeAnimator::BaseRenderNodeAnimator(float finalValue) |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 34 | : mTarget(NULL) |
| 35 | , mFinalValue(finalValue) |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 36 | , mDeltaValue(0) |
| 37 | , mFromValue(0) |
| 38 | , mInterpolator(0) |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 39 | , mStagingPlayState(NOT_STARTED) |
| 40 | , mPlayState(NOT_STARTED) |
| 41 | , mHasStartValue(false) |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 42 | , mStartTime(0) |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 43 | , mDuration(300) |
| 44 | , mStartDelay(0) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 45 | } |
| 46 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 47 | BaseRenderNodeAnimator::~BaseRenderNodeAnimator() { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 48 | delete mInterpolator; |
| 49 | } |
| 50 | |
| 51 | void BaseRenderNodeAnimator::checkMutable() { |
| 52 | // Should be impossible to hit as the Java-side also has guards for this |
| 53 | LOG_ALWAYS_FATAL_IF(mStagingPlayState != NOT_STARTED, |
| 54 | "Animator has already been started!"); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 55 | } |
| 56 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 57 | void BaseRenderNodeAnimator::setInterpolator(Interpolator* interpolator) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 58 | checkMutable(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 59 | delete mInterpolator; |
| 60 | mInterpolator = interpolator; |
| 61 | } |
| 62 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 63 | void BaseRenderNodeAnimator::setStartValue(float value) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 64 | checkMutable(); |
| 65 | doSetStartValue(value); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 66 | } |
| 67 | |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 68 | void BaseRenderNodeAnimator::doSetStartValue(float value) { |
| 69 | mFromValue = value; |
| 70 | mDeltaValue = (mFinalValue - mFromValue); |
| 71 | mHasStartValue = true; |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 74 | void BaseRenderNodeAnimator::setDuration(nsecs_t duration) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 75 | checkMutable(); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 76 | mDuration = duration; |
| 77 | } |
| 78 | |
| 79 | void BaseRenderNodeAnimator::setStartDelay(nsecs_t startDelay) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 80 | checkMutable(); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 81 | mStartDelay = startDelay; |
| 82 | } |
| 83 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 84 | void BaseRenderNodeAnimator::attach(RenderNode* target) { |
| 85 | mTarget = target; |
| 86 | onAttached(); |
| 87 | } |
| 88 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 89 | void BaseRenderNodeAnimator::pushStaging(AnimationContext& context) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 90 | if (!mHasStartValue) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 91 | doSetStartValue(getValue(mTarget)); |
Alan Viverette | ad2f8e3 | 2014-05-16 13:28:33 -0700 | [diff] [blame] | 92 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 93 | if (mStagingPlayState > mPlayState) { |
| 94 | mPlayState = mStagingPlayState; |
| 95 | // Oh boy, we're starting! Man the battle stations! |
| 96 | if (mPlayState == RUNNING) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 97 | transitionToRunning(context); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 98 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 99 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 100 | } |
| 101 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 102 | void BaseRenderNodeAnimator::transitionToRunning(AnimationContext& context) { |
| 103 | nsecs_t frameTimeMs = context.frameTimeMs(); |
| 104 | LOG_ALWAYS_FATAL_IF(frameTimeMs <= 0, "%" PRId64 " isn't a real frame time!", frameTimeMs); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 105 | if (mStartDelay < 0 || mStartDelay > 50000) { |
| 106 | ALOGW("Your start delay is strange and confusing: %" PRId64, mStartDelay); |
| 107 | } |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 108 | mStartTime = frameTimeMs + mStartDelay; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 109 | if (mStartTime < 0) { |
| 110 | ALOGW("Ended up with a really weird start time of %" PRId64 |
| 111 | " with frame time %" PRId64 " and start delay %" PRId64, |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 112 | mStartTime, frameTimeMs, mStartDelay); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 113 | // Set to 0 so that the animate() basically instantly finishes |
| 114 | mStartTime = 0; |
| 115 | } |
| 116 | // No interpolator was set, use the default |
| 117 | if (!mInterpolator) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 118 | mInterpolator = Interpolator::createDefaultInterpolator(); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 119 | } |
| 120 | if (mDuration < 0 || mDuration > 50000) { |
| 121 | ALOGW("Your duration is strange and confusing: %" PRId64, mDuration); |
| 122 | } |
| 123 | } |
| 124 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 125 | bool BaseRenderNodeAnimator::animate(AnimationContext& context) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 126 | if (mPlayState < RUNNING) { |
| 127 | return false; |
| 128 | } |
John Reck | 32fb630 | 2014-07-07 09:50:32 -0700 | [diff] [blame] | 129 | if (mPlayState == FINISHED) { |
| 130 | return true; |
| 131 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 132 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 133 | // If BaseRenderNodeAnimator is handling the delay (not typical), then |
| 134 | // because the staging properties reflect the final value, we always need |
| 135 | // to call setValue even if the animation isn't yet running or is still |
| 136 | // being delayed as we need to override the staging value |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 137 | if (mStartTime > context.frameTimeMs()) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 138 | setValue(mTarget, mFromValue); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 139 | return false; |
| 140 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 141 | |
| 142 | float fraction = 1.0f; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 143 | if (mPlayState == RUNNING && mDuration > 0) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 144 | fraction = (float)(context.frameTimeMs() - mStartTime) / mDuration; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 145 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 146 | if (fraction >= 1.0f) { |
| 147 | fraction = 1.0f; |
| 148 | mPlayState = FINISHED; |
| 149 | } |
| 150 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 151 | fraction = mInterpolator->interpolate(fraction); |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 152 | setValue(mTarget, mFromValue + (mDeltaValue * fraction)); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 153 | |
| 154 | if (mPlayState == FINISHED) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 155 | callOnFinishedListener(context); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 156 | return true; |
| 157 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 158 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 159 | return false; |
| 160 | } |
| 161 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 162 | void BaseRenderNodeAnimator::callOnFinishedListener(AnimationContext& context) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 163 | if (mListener.get()) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 164 | context.callOnFinished(this, mListener.get()); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | |
| 168 | /************************************************************ |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 169 | * RenderPropertyAnimator |
| 170 | ************************************************************/ |
| 171 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 172 | struct RenderPropertyAnimator::PropertyAccessors { |
| 173 | RenderNode::DirtyPropertyMask dirtyMask; |
| 174 | GetFloatProperty getter; |
| 175 | SetFloatProperty setter; |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 176 | }; |
| 177 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 178 | // Maps RenderProperty enum to accessors |
| 179 | const RenderPropertyAnimator::PropertyAccessors RenderPropertyAnimator::PROPERTY_ACCESSOR_LUT[] = { |
| 180 | {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationX, &RenderProperties::setTranslationX }, |
| 181 | {RenderNode::TRANSLATION_Y, &RenderProperties::getTranslationY, &RenderProperties::setTranslationY }, |
| 182 | {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationZ, &RenderProperties::setTranslationZ }, |
| 183 | {RenderNode::SCALE_X, &RenderProperties::getScaleX, &RenderProperties::setScaleX }, |
| 184 | {RenderNode::SCALE_Y, &RenderProperties::getScaleY, &RenderProperties::setScaleY }, |
| 185 | {RenderNode::ROTATION, &RenderProperties::getRotation, &RenderProperties::setRotation }, |
| 186 | {RenderNode::ROTATION_X, &RenderProperties::getRotationX, &RenderProperties::setRotationX }, |
| 187 | {RenderNode::ROTATION_Y, &RenderProperties::getRotationY, &RenderProperties::setRotationY }, |
| 188 | {RenderNode::X, &RenderProperties::getX, &RenderProperties::setX }, |
| 189 | {RenderNode::Y, &RenderProperties::getY, &RenderProperties::setY }, |
| 190 | {RenderNode::Z, &RenderProperties::getZ, &RenderProperties::setZ }, |
| 191 | {RenderNode::ALPHA, &RenderProperties::getAlpha, &RenderProperties::setAlpha }, |
| 192 | }; |
| 193 | |
| 194 | RenderPropertyAnimator::RenderPropertyAnimator(RenderProperty property, float finalValue) |
| 195 | : BaseRenderNodeAnimator(finalValue) |
| 196 | , mPropertyAccess(&(PROPERTY_ACCESSOR_LUT[property])) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 197 | } |
| 198 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 199 | void RenderPropertyAnimator::onAttached() { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 200 | if (!mHasStartValue |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 201 | && mTarget->isPropertyFieldDirty(mPropertyAccess->dirtyMask)) { |
| 202 | setStartValue((mTarget->stagingProperties().*mPropertyAccess->getter)()); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 203 | } |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | void RenderPropertyAnimator::onStagingPlayStateChanged() { |
| 207 | if (mStagingPlayState == RUNNING) { |
| 208 | (mTarget->mutateStagingProperties().*mPropertyAccess->setter)(finalValue()); |
John Reck | 32fb630 | 2014-07-07 09:50:32 -0700 | [diff] [blame] | 209 | } else if (mStagingPlayState == FINISHED) { |
| 210 | // We're being canceled, so make sure that whatever values the UI thread |
| 211 | // is observing for us is pushed over |
| 212 | mTarget->setPropertyFieldsDirty(dirtyMask()); |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 213 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 214 | } |
| 215 | |
John Reck | 2218472 | 2014-06-20 07:19:30 -0700 | [diff] [blame] | 216 | uint32_t RenderPropertyAnimator::dirtyMask() { |
| 217 | return mPropertyAccess->dirtyMask; |
| 218 | } |
| 219 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 220 | float RenderPropertyAnimator::getValue(RenderNode* target) const { |
| 221 | return (target->properties().*mPropertyAccess->getter)(); |
| 222 | } |
| 223 | |
| 224 | void RenderPropertyAnimator::setValue(RenderNode* target, float value) { |
| 225 | (target->animatorProperties().*mPropertyAccess->setter)(value); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 226 | } |
| 227 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 228 | /************************************************************ |
| 229 | * CanvasPropertyPrimitiveAnimator |
| 230 | ************************************************************/ |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 231 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 232 | CanvasPropertyPrimitiveAnimator::CanvasPropertyPrimitiveAnimator( |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 233 | CanvasPropertyPrimitive* property, float finalValue) |
| 234 | : BaseRenderNodeAnimator(finalValue) |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 235 | , mProperty(property) { |
| 236 | } |
| 237 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 238 | float CanvasPropertyPrimitiveAnimator::getValue(RenderNode* target) const { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 239 | return mProperty->value; |
| 240 | } |
| 241 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 242 | void CanvasPropertyPrimitiveAnimator::setValue(RenderNode* target, float value) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 243 | mProperty->value = value; |
| 244 | } |
| 245 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 246 | uint32_t CanvasPropertyPrimitiveAnimator::dirtyMask() { |
| 247 | return RenderNode::DISPLAY_LIST; |
| 248 | } |
| 249 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 250 | /************************************************************ |
| 251 | * CanvasPropertySkPaintAnimator |
| 252 | ************************************************************/ |
| 253 | |
| 254 | CanvasPropertyPaintAnimator::CanvasPropertyPaintAnimator( |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 255 | CanvasPropertyPaint* property, PaintField field, float finalValue) |
| 256 | : BaseRenderNodeAnimator(finalValue) |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 257 | , mProperty(property) |
| 258 | , mField(field) { |
| 259 | } |
| 260 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 261 | float CanvasPropertyPaintAnimator::getValue(RenderNode* target) const { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 262 | switch (mField) { |
| 263 | case STROKE_WIDTH: |
| 264 | return mProperty->value.getStrokeWidth(); |
| 265 | case ALPHA: |
| 266 | return mProperty->value.getAlpha(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 267 | } |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 268 | LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); |
| 269 | return -1; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 270 | } |
| 271 | |
John Reck | 531ee70 | 2014-05-13 10:06:08 -0700 | [diff] [blame] | 272 | static uint8_t to_uint8(float value) { |
| 273 | int c = (int) (value + .5f); |
| 274 | return static_cast<uint8_t>( c < 0 ? 0 : c > 255 ? 255 : c ); |
| 275 | } |
| 276 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 277 | void CanvasPropertyPaintAnimator::setValue(RenderNode* target, float value) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 278 | switch (mField) { |
| 279 | case STROKE_WIDTH: |
| 280 | mProperty->value.setStrokeWidth(value); |
| 281 | return; |
| 282 | case ALPHA: |
John Reck | 531ee70 | 2014-05-13 10:06:08 -0700 | [diff] [blame] | 283 | mProperty->value.setAlpha(to_uint8(value)); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 284 | return; |
| 285 | } |
| 286 | LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 287 | } |
| 288 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 289 | uint32_t CanvasPropertyPaintAnimator::dirtyMask() { |
| 290 | return RenderNode::DISPLAY_LIST; |
| 291 | } |
| 292 | |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 293 | RevealAnimator::RevealAnimator(int centerX, int centerY, |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 294 | float startValue, float finalValue) |
| 295 | : BaseRenderNodeAnimator(finalValue) |
| 296 | , mCenterX(centerX) |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 297 | , mCenterY(centerY) { |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 298 | setStartValue(startValue); |
| 299 | } |
| 300 | |
| 301 | float RevealAnimator::getValue(RenderNode* target) const { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 302 | return target->properties().getRevealClip().getRadius(); |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | void RevealAnimator::setValue(RenderNode* target, float value) { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 306 | target->animatorProperties().mutableRevealClip().set(true, |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 307 | mCenterX, mCenterY, value); |
| 308 | } |
| 309 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 310 | uint32_t RevealAnimator::dirtyMask() { |
| 311 | return RenderNode::GENERIC; |
| 312 | } |
| 313 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 314 | } /* namespace uirenderer */ |
| 315 | } /* namespace android */ |