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 | 4d2c472 | 2014-08-29 10:40:56 -0700 | [diff] [blame] | 98 | } else if (mPlayState == FINISHED) { |
| 99 | callOnFinishedListener(context); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 100 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 101 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 102 | } |
| 103 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 104 | void BaseRenderNodeAnimator::transitionToRunning(AnimationContext& context) { |
| 105 | nsecs_t frameTimeMs = context.frameTimeMs(); |
| 106 | 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] | 107 | if (mStartDelay < 0 || mStartDelay > 50000) { |
| 108 | ALOGW("Your start delay is strange and confusing: %" PRId64, mStartDelay); |
| 109 | } |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 110 | mStartTime = frameTimeMs + mStartDelay; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 111 | if (mStartTime < 0) { |
| 112 | ALOGW("Ended up with a really weird start time of %" PRId64 |
| 113 | " with frame time %" PRId64 " and start delay %" PRId64, |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 114 | mStartTime, frameTimeMs, mStartDelay); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 115 | // Set to 0 so that the animate() basically instantly finishes |
| 116 | mStartTime = 0; |
| 117 | } |
| 118 | // No interpolator was set, use the default |
| 119 | if (!mInterpolator) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 120 | mInterpolator = Interpolator::createDefaultInterpolator(); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 121 | } |
| 122 | if (mDuration < 0 || mDuration > 50000) { |
| 123 | ALOGW("Your duration is strange and confusing: %" PRId64, mDuration); |
| 124 | } |
| 125 | } |
| 126 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 127 | bool BaseRenderNodeAnimator::animate(AnimationContext& context) { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 128 | if (mPlayState < RUNNING) { |
| 129 | return false; |
| 130 | } |
John Reck | 32fb630 | 2014-07-07 09:50:32 -0700 | [diff] [blame] | 131 | if (mPlayState == FINISHED) { |
| 132 | return true; |
| 133 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 134 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 135 | // If BaseRenderNodeAnimator is handling the delay (not typical), then |
| 136 | // because the staging properties reflect the final value, we always need |
| 137 | // to call setValue even if the animation isn't yet running or is still |
| 138 | // being delayed as we need to override the staging value |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 139 | if (mStartTime > context.frameTimeMs()) { |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 140 | setValue(mTarget, mFromValue); |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 141 | return false; |
| 142 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 143 | |
| 144 | float fraction = 1.0f; |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 145 | if (mPlayState == RUNNING && mDuration > 0) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 146 | fraction = (float)(context.frameTimeMs() - mStartTime) / mDuration; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 147 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 148 | if (fraction >= 1.0f) { |
| 149 | fraction = 1.0f; |
| 150 | mPlayState = FINISHED; |
| 151 | } |
| 152 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 153 | fraction = mInterpolator->interpolate(fraction); |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 154 | setValue(mTarget, mFromValue + (mDeltaValue * fraction)); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 155 | |
| 156 | if (mPlayState == FINISHED) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 157 | callOnFinishedListener(context); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 158 | return true; |
| 159 | } |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 160 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 161 | return false; |
| 162 | } |
| 163 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 164 | void BaseRenderNodeAnimator::callOnFinishedListener(AnimationContext& context) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 165 | if (mListener.get()) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 166 | context.callOnFinished(this, mListener.get()); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | |
| 170 | /************************************************************ |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 171 | * RenderPropertyAnimator |
| 172 | ************************************************************/ |
| 173 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 174 | struct RenderPropertyAnimator::PropertyAccessors { |
| 175 | RenderNode::DirtyPropertyMask dirtyMask; |
| 176 | GetFloatProperty getter; |
| 177 | SetFloatProperty setter; |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 178 | }; |
| 179 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 180 | // Maps RenderProperty enum to accessors |
| 181 | const RenderPropertyAnimator::PropertyAccessors RenderPropertyAnimator::PROPERTY_ACCESSOR_LUT[] = { |
| 182 | {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationX, &RenderProperties::setTranslationX }, |
| 183 | {RenderNode::TRANSLATION_Y, &RenderProperties::getTranslationY, &RenderProperties::setTranslationY }, |
| 184 | {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationZ, &RenderProperties::setTranslationZ }, |
| 185 | {RenderNode::SCALE_X, &RenderProperties::getScaleX, &RenderProperties::setScaleX }, |
| 186 | {RenderNode::SCALE_Y, &RenderProperties::getScaleY, &RenderProperties::setScaleY }, |
| 187 | {RenderNode::ROTATION, &RenderProperties::getRotation, &RenderProperties::setRotation }, |
| 188 | {RenderNode::ROTATION_X, &RenderProperties::getRotationX, &RenderProperties::setRotationX }, |
| 189 | {RenderNode::ROTATION_Y, &RenderProperties::getRotationY, &RenderProperties::setRotationY }, |
| 190 | {RenderNode::X, &RenderProperties::getX, &RenderProperties::setX }, |
| 191 | {RenderNode::Y, &RenderProperties::getY, &RenderProperties::setY }, |
| 192 | {RenderNode::Z, &RenderProperties::getZ, &RenderProperties::setZ }, |
| 193 | {RenderNode::ALPHA, &RenderProperties::getAlpha, &RenderProperties::setAlpha }, |
| 194 | }; |
| 195 | |
| 196 | RenderPropertyAnimator::RenderPropertyAnimator(RenderProperty property, float finalValue) |
| 197 | : BaseRenderNodeAnimator(finalValue) |
| 198 | , mPropertyAccess(&(PROPERTY_ACCESSOR_LUT[property])) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 199 | } |
| 200 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 201 | void RenderPropertyAnimator::onAttached() { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 202 | if (!mHasStartValue |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 203 | && mTarget->isPropertyFieldDirty(mPropertyAccess->dirtyMask)) { |
| 204 | setStartValue((mTarget->stagingProperties().*mPropertyAccess->getter)()); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 205 | } |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | void RenderPropertyAnimator::onStagingPlayStateChanged() { |
| 209 | if (mStagingPlayState == RUNNING) { |
| 210 | (mTarget->mutateStagingProperties().*mPropertyAccess->setter)(finalValue()); |
John Reck | 32fb630 | 2014-07-07 09:50:32 -0700 | [diff] [blame] | 211 | } else if (mStagingPlayState == FINISHED) { |
| 212 | // We're being canceled, so make sure that whatever values the UI thread |
| 213 | // is observing for us is pushed over |
| 214 | mTarget->setPropertyFieldsDirty(dirtyMask()); |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 215 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 216 | } |
| 217 | |
John Reck | 2218472 | 2014-06-20 07:19:30 -0700 | [diff] [blame] | 218 | uint32_t RenderPropertyAnimator::dirtyMask() { |
| 219 | return mPropertyAccess->dirtyMask; |
| 220 | } |
| 221 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 222 | float RenderPropertyAnimator::getValue(RenderNode* target) const { |
| 223 | return (target->properties().*mPropertyAccess->getter)(); |
| 224 | } |
| 225 | |
| 226 | void RenderPropertyAnimator::setValue(RenderNode* target, float value) { |
| 227 | (target->animatorProperties().*mPropertyAccess->setter)(value); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 228 | } |
| 229 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 230 | /************************************************************ |
| 231 | * CanvasPropertyPrimitiveAnimator |
| 232 | ************************************************************/ |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 233 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 234 | CanvasPropertyPrimitiveAnimator::CanvasPropertyPrimitiveAnimator( |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 235 | CanvasPropertyPrimitive* property, float finalValue) |
| 236 | : BaseRenderNodeAnimator(finalValue) |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 237 | , mProperty(property) { |
| 238 | } |
| 239 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 240 | float CanvasPropertyPrimitiveAnimator::getValue(RenderNode* target) const { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 241 | return mProperty->value; |
| 242 | } |
| 243 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 244 | void CanvasPropertyPrimitiveAnimator::setValue(RenderNode* target, float value) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 245 | mProperty->value = value; |
| 246 | } |
| 247 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 248 | uint32_t CanvasPropertyPrimitiveAnimator::dirtyMask() { |
| 249 | return RenderNode::DISPLAY_LIST; |
| 250 | } |
| 251 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 252 | /************************************************************ |
| 253 | * CanvasPropertySkPaintAnimator |
| 254 | ************************************************************/ |
| 255 | |
| 256 | CanvasPropertyPaintAnimator::CanvasPropertyPaintAnimator( |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 257 | CanvasPropertyPaint* property, PaintField field, float finalValue) |
| 258 | : BaseRenderNodeAnimator(finalValue) |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 259 | , mProperty(property) |
| 260 | , mField(field) { |
| 261 | } |
| 262 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 263 | float CanvasPropertyPaintAnimator::getValue(RenderNode* target) const { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 264 | switch (mField) { |
| 265 | case STROKE_WIDTH: |
| 266 | return mProperty->value.getStrokeWidth(); |
| 267 | case ALPHA: |
| 268 | return mProperty->value.getAlpha(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 269 | } |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 270 | LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); |
| 271 | return -1; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 272 | } |
| 273 | |
John Reck | 531ee70 | 2014-05-13 10:06:08 -0700 | [diff] [blame] | 274 | static uint8_t to_uint8(float value) { |
| 275 | int c = (int) (value + .5f); |
| 276 | return static_cast<uint8_t>( c < 0 ? 0 : c > 255 ? 255 : c ); |
| 277 | } |
| 278 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 279 | void CanvasPropertyPaintAnimator::setValue(RenderNode* target, float value) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 280 | switch (mField) { |
| 281 | case STROKE_WIDTH: |
| 282 | mProperty->value.setStrokeWidth(value); |
| 283 | return; |
| 284 | case ALPHA: |
John Reck | 531ee70 | 2014-05-13 10:06:08 -0700 | [diff] [blame] | 285 | mProperty->value.setAlpha(to_uint8(value)); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 286 | return; |
| 287 | } |
| 288 | LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 289 | } |
| 290 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 291 | uint32_t CanvasPropertyPaintAnimator::dirtyMask() { |
| 292 | return RenderNode::DISPLAY_LIST; |
| 293 | } |
| 294 | |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 295 | RevealAnimator::RevealAnimator(int centerX, int centerY, |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 296 | float startValue, float finalValue) |
| 297 | : BaseRenderNodeAnimator(finalValue) |
| 298 | , mCenterX(centerX) |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 299 | , mCenterY(centerY) { |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 300 | setStartValue(startValue); |
| 301 | } |
| 302 | |
| 303 | float RevealAnimator::getValue(RenderNode* target) const { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 304 | return target->properties().getRevealClip().getRadius(); |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | void RevealAnimator::setValue(RenderNode* target, float value) { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 308 | target->animatorProperties().mutableRevealClip().set(true, |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 309 | mCenterX, mCenterY, value); |
| 310 | } |
| 311 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 312 | uint32_t RevealAnimator::dirtyMask() { |
| 313 | return RenderNode::GENERIC; |
| 314 | } |
| 315 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 316 | } /* namespace uirenderer */ |
| 317 | } /* namespace android */ |