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 | e2478d4 | 2014-09-03 16:46:05 -0700 | [diff] [blame^] | 164 | void BaseRenderNodeAnimator::forceEndNow(AnimationContext& context) { |
| 165 | if (mPlayState < FINISHED) { |
| 166 | mPlayState = FINISHED; |
| 167 | callOnFinishedListener(context); |
| 168 | } |
| 169 | } |
| 170 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 171 | void BaseRenderNodeAnimator::callOnFinishedListener(AnimationContext& context) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 172 | if (mListener.get()) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 173 | context.callOnFinished(this, mListener.get()); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 174 | } |
| 175 | } |
| 176 | |
| 177 | /************************************************************ |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 178 | * RenderPropertyAnimator |
| 179 | ************************************************************/ |
| 180 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 181 | struct RenderPropertyAnimator::PropertyAccessors { |
| 182 | RenderNode::DirtyPropertyMask dirtyMask; |
| 183 | GetFloatProperty getter; |
| 184 | SetFloatProperty setter; |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 185 | }; |
| 186 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 187 | // Maps RenderProperty enum to accessors |
| 188 | const RenderPropertyAnimator::PropertyAccessors RenderPropertyAnimator::PROPERTY_ACCESSOR_LUT[] = { |
| 189 | {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationX, &RenderProperties::setTranslationX }, |
| 190 | {RenderNode::TRANSLATION_Y, &RenderProperties::getTranslationY, &RenderProperties::setTranslationY }, |
| 191 | {RenderNode::TRANSLATION_X, &RenderProperties::getTranslationZ, &RenderProperties::setTranslationZ }, |
| 192 | {RenderNode::SCALE_X, &RenderProperties::getScaleX, &RenderProperties::setScaleX }, |
| 193 | {RenderNode::SCALE_Y, &RenderProperties::getScaleY, &RenderProperties::setScaleY }, |
| 194 | {RenderNode::ROTATION, &RenderProperties::getRotation, &RenderProperties::setRotation }, |
| 195 | {RenderNode::ROTATION_X, &RenderProperties::getRotationX, &RenderProperties::setRotationX }, |
| 196 | {RenderNode::ROTATION_Y, &RenderProperties::getRotationY, &RenderProperties::setRotationY }, |
| 197 | {RenderNode::X, &RenderProperties::getX, &RenderProperties::setX }, |
| 198 | {RenderNode::Y, &RenderProperties::getY, &RenderProperties::setY }, |
| 199 | {RenderNode::Z, &RenderProperties::getZ, &RenderProperties::setZ }, |
| 200 | {RenderNode::ALPHA, &RenderProperties::getAlpha, &RenderProperties::setAlpha }, |
| 201 | }; |
| 202 | |
| 203 | RenderPropertyAnimator::RenderPropertyAnimator(RenderProperty property, float finalValue) |
| 204 | : BaseRenderNodeAnimator(finalValue) |
| 205 | , mPropertyAccess(&(PROPERTY_ACCESSOR_LUT[property])) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 206 | } |
| 207 | |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 208 | void RenderPropertyAnimator::onAttached() { |
John Reck | 68bfe0a | 2014-06-24 15:34:58 -0700 | [diff] [blame] | 209 | if (!mHasStartValue |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 210 | && mTarget->isPropertyFieldDirty(mPropertyAccess->dirtyMask)) { |
| 211 | setStartValue((mTarget->stagingProperties().*mPropertyAccess->getter)()); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 212 | } |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | void RenderPropertyAnimator::onStagingPlayStateChanged() { |
| 216 | if (mStagingPlayState == RUNNING) { |
| 217 | (mTarget->mutateStagingProperties().*mPropertyAccess->setter)(finalValue()); |
John Reck | 32fb630 | 2014-07-07 09:50:32 -0700 | [diff] [blame] | 218 | } else if (mStagingPlayState == FINISHED) { |
| 219 | // We're being canceled, so make sure that whatever values the UI thread |
| 220 | // is observing for us is pushed over |
| 221 | mTarget->setPropertyFieldsDirty(dirtyMask()); |
John Reck | 8d8af3c | 2014-07-01 15:23:45 -0700 | [diff] [blame] | 222 | } |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 223 | } |
| 224 | |
John Reck | 2218472 | 2014-06-20 07:19:30 -0700 | [diff] [blame] | 225 | uint32_t RenderPropertyAnimator::dirtyMask() { |
| 226 | return mPropertyAccess->dirtyMask; |
| 227 | } |
| 228 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 229 | float RenderPropertyAnimator::getValue(RenderNode* target) const { |
| 230 | return (target->properties().*mPropertyAccess->getter)(); |
| 231 | } |
| 232 | |
| 233 | void RenderPropertyAnimator::setValue(RenderNode* target, float value) { |
| 234 | (target->animatorProperties().*mPropertyAccess->setter)(value); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 235 | } |
| 236 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 237 | /************************************************************ |
| 238 | * CanvasPropertyPrimitiveAnimator |
| 239 | ************************************************************/ |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 240 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 241 | CanvasPropertyPrimitiveAnimator::CanvasPropertyPrimitiveAnimator( |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 242 | CanvasPropertyPrimitive* property, float finalValue) |
| 243 | : BaseRenderNodeAnimator(finalValue) |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 244 | , mProperty(property) { |
| 245 | } |
| 246 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 247 | float CanvasPropertyPrimitiveAnimator::getValue(RenderNode* target) const { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 248 | return mProperty->value; |
| 249 | } |
| 250 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 251 | void CanvasPropertyPrimitiveAnimator::setValue(RenderNode* target, float value) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 252 | mProperty->value = value; |
| 253 | } |
| 254 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 255 | uint32_t CanvasPropertyPrimitiveAnimator::dirtyMask() { |
| 256 | return RenderNode::DISPLAY_LIST; |
| 257 | } |
| 258 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 259 | /************************************************************ |
| 260 | * CanvasPropertySkPaintAnimator |
| 261 | ************************************************************/ |
| 262 | |
| 263 | CanvasPropertyPaintAnimator::CanvasPropertyPaintAnimator( |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 264 | CanvasPropertyPaint* property, PaintField field, float finalValue) |
| 265 | : BaseRenderNodeAnimator(finalValue) |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 266 | , mProperty(property) |
| 267 | , mField(field) { |
| 268 | } |
| 269 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 270 | float CanvasPropertyPaintAnimator::getValue(RenderNode* target) const { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 271 | switch (mField) { |
| 272 | case STROKE_WIDTH: |
| 273 | return mProperty->value.getStrokeWidth(); |
| 274 | case ALPHA: |
| 275 | return mProperty->value.getAlpha(); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 276 | } |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 277 | LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); |
| 278 | return -1; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 279 | } |
| 280 | |
John Reck | 531ee70 | 2014-05-13 10:06:08 -0700 | [diff] [blame] | 281 | static uint8_t to_uint8(float value) { |
| 282 | int c = (int) (value + .5f); |
| 283 | return static_cast<uint8_t>( c < 0 ? 0 : c > 255 ? 255 : c ); |
| 284 | } |
| 285 | |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 286 | void CanvasPropertyPaintAnimator::setValue(RenderNode* target, float value) { |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 287 | switch (mField) { |
| 288 | case STROKE_WIDTH: |
| 289 | mProperty->value.setStrokeWidth(value); |
| 290 | return; |
| 291 | case ALPHA: |
John Reck | 531ee70 | 2014-05-13 10:06:08 -0700 | [diff] [blame] | 292 | mProperty->value.setAlpha(to_uint8(value)); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 293 | return; |
| 294 | } |
| 295 | LOG_ALWAYS_FATAL("Unknown field %d", (int) mField); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 296 | } |
| 297 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 298 | uint32_t CanvasPropertyPaintAnimator::dirtyMask() { |
| 299 | return RenderNode::DISPLAY_LIST; |
| 300 | } |
| 301 | |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 302 | RevealAnimator::RevealAnimator(int centerX, int centerY, |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 303 | float startValue, float finalValue) |
| 304 | : BaseRenderNodeAnimator(finalValue) |
| 305 | , mCenterX(centerX) |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 306 | , mCenterY(centerY) { |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 307 | setStartValue(startValue); |
| 308 | } |
| 309 | |
| 310 | float RevealAnimator::getValue(RenderNode* target) const { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 311 | return target->properties().getRevealClip().getRadius(); |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | void RevealAnimator::setValue(RenderNode* target, float value) { |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 315 | target->animatorProperties().mutableRevealClip().set(true, |
John Reck | d3de42c | 2014-07-15 14:29:33 -0700 | [diff] [blame] | 316 | mCenterX, mCenterY, value); |
| 317 | } |
| 318 | |
John Reck | a7c2ea2 | 2014-08-08 13:21:00 -0700 | [diff] [blame] | 319 | uint32_t RevealAnimator::dirtyMask() { |
| 320 | return RenderNode::GENERIC; |
| 321 | } |
| 322 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 323 | } /* namespace uirenderer */ |
| 324 | } /* namespace android */ |