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