1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/animator/SkAnimateActive.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,504 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "SkAnimateActive.h" 1.14 +#include "SkAnimateBase.h" 1.15 +#include "SkAnimateMaker.h" 1.16 +#include "SkAnimateSet.h" 1.17 +#include "SkDrawGroup.h" 1.18 +#ifdef SK_DEBUG 1.19 +#include "SkTime.h" 1.20 +#endif 1.21 + 1.22 +// SkActive holds array of interpolators 1.23 + 1.24 +SkActive::SkActive(SkApply& apply, SkAnimateMaker& maker) : fApply(apply), 1.25 + fMaxTime(0), fMaker(maker), fDrawIndex(0), fDrawMax(0) { 1.26 +} 1.27 + 1.28 +void SkActive::init() 1.29 +{ 1.30 + fAnimators = fApply.fAnimators; 1.31 + int animators = fAnimators.count(); 1.32 + fInterpolators.setCount(animators); 1.33 + memset(fInterpolators.begin(), 0, animators * sizeof(SkOperandInterpolator*)); 1.34 + fState.setCount(animators); 1.35 + int index; 1.36 + for (index = 0; index < animators; index++) 1.37 + fInterpolators[index] = SkNEW(SkOperandInterpolator); 1.38 + initState(&fApply, 0); 1.39 +// for (index = 0; index < animators; index++) 1.40 +// fState[index].bumpSave(); 1.41 + SkASSERT(fInterpolators.count() == fAnimators.count()); 1.42 +} 1.43 + 1.44 +SkActive::~SkActive() { 1.45 + int index; 1.46 + for (index = 0; index < fSaveRestore.count(); index++) 1.47 + delete[] fSaveRestore[index]; 1.48 + for (index = 0; index < fSaveInterpolators.count(); index++) 1.49 + delete[] fSaveInterpolators[index]; 1.50 + for (index = 0; index < fInterpolators.count(); index++) 1.51 + delete fInterpolators[index]; 1.52 +} 1.53 + 1.54 +void SkActive::advance() { 1.55 + if (fDrawMax < fDrawIndex) 1.56 + fDrawMax = fDrawIndex; 1.57 + fDrawIndex += fAnimators.count(); 1.58 +} 1.59 + 1.60 +void SkActive::append(SkApply* apply) { 1.61 + int oldCount = fAnimators.count(); 1.62 + SkTDAnimateArray& animates = apply->fAnimators; 1.63 + int newCount = animates.count(); 1.64 + int index; 1.65 + int total = oldCount + newCount; 1.66 + if (total == 0) 1.67 + return; 1.68 + fInterpolators.setCount(total); 1.69 + memset(&fInterpolators.begin()[oldCount], 0, newCount * sizeof(SkOperandInterpolator*)); 1.70 + for (index = oldCount; index < total; index++) 1.71 + fInterpolators[index] = SkNEW(SkOperandInterpolator); 1.72 + fAnimators.setCount(total); 1.73 + memcpy(&fAnimators[oldCount], animates.begin(), sizeof(fAnimators[0]) * 1.74 + newCount); 1.75 + fState.setCount(total); 1.76 + initState(apply, oldCount); 1.77 + SkASSERT(fApply.scope == apply->scope); 1.78 + for (index = 0; index < newCount; index++) { 1.79 + SkAnimateBase* test = animates[index]; 1.80 +// SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget)); 1.81 + SkActive::SkState& testState = fState[oldCount + index]; 1.82 + for (int inner = 0; inner < oldCount; inner++) { 1.83 + SkAnimateBase* oldGuard = fAnimators[inner]; 1.84 + SkActive::SkState& oldState = fState[inner]; 1.85 + if (oldGuard->fTarget == test->fTarget && oldGuard->fFieldInfo == test->fFieldInfo && 1.86 + testState.fBegin == oldState.fBegin) { 1.87 + delete fInterpolators[inner]; 1.88 + fInterpolators.remove(inner); 1.89 + fAnimators.remove(inner); 1.90 + testState.fSave = oldState.fSave; 1.91 + if (oldState.fUnpostedEndEvent) { 1.92 +// SkDEBUGF(("%8x %8x active append: post on end\n", this, oldGuard)); 1.93 + fMaker.postOnEnd(oldGuard, oldState.fBegin + oldState.fDuration); 1.94 + } 1.95 + fState.remove(inner); 1.96 + if (fApply.restore) { 1.97 + int saveIndex = fSaveRestore.count(); 1.98 + SkASSERT(fSaveInterpolators.count() == saveIndex); 1.99 + saveIndex += inner; 1.100 + do { 1.101 + saveIndex -= oldCount; 1.102 + delete[] fSaveRestore[saveIndex]; 1.103 + fSaveRestore.remove(saveIndex); 1.104 + delete[] fSaveInterpolators[saveIndex]; 1.105 + fSaveInterpolators.remove(saveIndex); 1.106 + } while (saveIndex > 0); 1.107 + } 1.108 + oldCount--; 1.109 + break; 1.110 + } 1.111 + } 1.112 + } 1.113 +// total = oldCount + newCount; 1.114 +// for (index = oldCount; index < total; index++) 1.115 +// fState[index].bumpSave(); 1.116 + SkASSERT(fInterpolators.count() == fAnimators.count()); 1.117 +} 1.118 + 1.119 +void SkActive::appendSave(int oldCount) { 1.120 + SkASSERT(fDrawMax == 0); // if true, we can optimize below quite a bit 1.121 + int newCount = fAnimators.count(); 1.122 + int saveIndex = fSaveRestore.count(); 1.123 + SkASSERT(fSaveInterpolators.count() == saveIndex); 1.124 + int records = saveIndex / oldCount; 1.125 + int newTotal = records * newCount; 1.126 + fSaveRestore.setCount(newTotal); 1.127 + do { 1.128 + saveIndex -= oldCount; 1.129 + newTotal -= newCount; 1.130 + SkASSERT(saveIndex >= 0); 1.131 + SkASSERT(newTotal >= 0); 1.132 + memmove(&fSaveRestore[newTotal], &fSaveRestore[saveIndex], oldCount); 1.133 + memset(&fSaveRestore[newTotal + oldCount], 0, 1.134 + sizeof(fSaveRestore[0]) * (newCount - oldCount)); 1.135 + memmove(&fSaveInterpolators[newTotal], 1.136 + &fSaveInterpolators[saveIndex], oldCount); 1.137 + memset(&fSaveInterpolators[newTotal + oldCount], 0, 1.138 + sizeof(fSaveRestore[0]) * (newCount - oldCount)); 1.139 + } while (saveIndex > 0); 1.140 + SkASSERT(newTotal == 0); 1.141 +} 1.142 + 1.143 +void SkActive::calcDurations(int index) 1.144 +{ 1.145 + SkAnimateBase* animate = fAnimators[index]; 1.146 + SkMSec duration = animate->dur; 1.147 + SkState& state = fState[index]; 1.148 + switch (state.fMode) { 1.149 + case SkApply::kMode_immediate: 1.150 + case SkApply::kMode_create: 1.151 + duration = state.fSteps ? state.fSteps * SK_MSec1 : 1; 1.152 + break; 1.153 +// case SkApply::kMode_hold: { 1.154 +// int entries = animate->entries(); 1.155 +// SkScriptValue value; 1.156 +// value.fOperand = animate->getValues()[entries - 1]; 1.157 +// value.fType = animate->getValuesType(); 1.158 +// bool result = SkScriptEngine::ConvertTo(NULL, SkType_Int, &value); 1.159 +// SkASSERT(result); 1.160 +// duration = value.fOperand.fS32 * SK_MSec1; 1.161 +// break; 1.162 +// } 1.163 + } 1.164 + state.fDuration = duration; 1.165 + SkMSec maxTime = state.fBegin + duration; 1.166 + if (fMaxTime < maxTime) 1.167 + fMaxTime = maxTime; 1.168 +} 1.169 + 1.170 +void SkActive::create(SkDrawable* drawable, SkMSec time) { 1.171 + fApply.fLastTime = time; 1.172 + fApply.refresh(fMaker); 1.173 + for (int index = 0; index < fAnimators.count(); index++) { 1.174 + SkAnimateBase* animate = fAnimators[index]; 1.175 + SkOperandInterpolator& interpolator = *fInterpolators[index]; 1.176 + int count = animate->components(); 1.177 + if (animate->formula.size() > 0) { 1.178 + SkTDOperandArray values; 1.179 + values.setCount(count); 1.180 + SkDEBUGCODE(bool success = ) animate->fFieldInfo->setValue(fMaker, &values, 0, 0, NULL, 1.181 + animate->getValuesType(), animate->formula); 1.182 + SkASSERT(success); 1.183 + fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time); 1.184 + } else { 1.185 + SkAutoSTMalloc<16, SkOperand> values(count); 1.186 + interpolator.timeToValues(time, values.get()); 1.187 + fApply.applyValues(index, values.get(), count, animate->getValuesType(), time); 1.188 + } 1.189 + } 1.190 + drawable->enable(fMaker); 1.191 + SkASSERT(fAnimators.count() == fInterpolators.count()); 1.192 +} 1.193 + 1.194 +bool SkActive::immediate(bool enable) { 1.195 + SkMSec time = 0; 1.196 + bool result = false; 1.197 + SkDrawable* drawable = fApply.scope; 1.198 + SkMSec final = fMaxTime; 1.199 + do { 1.200 + bool applied = fAnimators.count() == 0; 1.201 + fApply.fLastTime = time; 1.202 + fApply.refresh(fMaker); 1.203 + for (int index = 0; index < fAnimators.count(); index++) { 1.204 + SkAnimateBase* animate = fAnimators[index]; 1.205 + SkState& state = fState[index]; 1.206 + if (state.fMode != SkApply::kMode_immediate) 1.207 + continue; 1.208 + if (state.fBegin > time) 1.209 + continue; 1.210 + if (time > state.fBegin + state.fDuration) 1.211 + continue; 1.212 + applied = true; 1.213 + SkOperandInterpolator& interpolator = *fInterpolators[index]; 1.214 + int count = animate->components(); 1.215 + if (animate->formula.size() > 0) { 1.216 + SkTDOperandArray values; 1.217 + values.setCount(count); 1.218 + SkDEBUGCODE(bool success = ) animate->fFieldInfo->setValue(fMaker, &values, 0, 0, NULL, 1.219 + animate->getValuesType(), animate->formula); 1.220 + SkASSERT(success); 1.221 + fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time); 1.222 + } else { 1.223 + SkAutoSTMalloc<16, SkOperand> values(count); 1.224 + interpolator.timeToValues(time, values.get()); 1.225 + fApply.applyValues(index, values.get(), count, animate->getValuesType(), time); 1.226 + } 1.227 + } 1.228 + if (enable) 1.229 + drawable->enable(fMaker); 1.230 + else if (applied) 1.231 + result |= drawable->draw(fMaker); 1.232 + time += SK_MSec1; 1.233 + } while (time <= final); 1.234 + return result; 1.235 +} 1.236 + 1.237 +void SkActive::fixInterpolator(SkBool save) { 1.238 + int animators = fAnimators.count(); 1.239 + for (int index = 0; index < animators; index++) { 1.240 + SkAnimateBase* animate = fAnimators[index]; 1.241 + if (save) { // saved slots increased 1.242 + animate->refresh(fMaker); 1.243 + SkOperand* values = animate->getValues(); 1.244 + setInterpolator(index, values); 1.245 + saveInterpolatorValues(index); 1.246 + } else 1.247 + restoreInterpolatorValues(index); 1.248 + } 1.249 +} 1.250 + 1.251 +SkMSec SkActive::getTime(SkMSec inTime, int animatorIndex) { 1.252 + fState[animatorIndex].fTicks = inTime; 1.253 + return inTime - fState[animatorIndex].fStartTime; 1.254 +} 1.255 + 1.256 +bool SkActive::initializeSave() { 1.257 + int animators = fAnimators.count(); 1.258 + int activeTotal = fDrawIndex + animators; 1.259 + int oldCount = fSaveRestore.count(); 1.260 + if (oldCount < activeTotal) { 1.261 + fSaveRestore.setCount(activeTotal); 1.262 + memset(&fSaveRestore[oldCount], 0, sizeof(fSaveRestore[0]) * (activeTotal - oldCount)); 1.263 + SkASSERT(fSaveInterpolators.count() == oldCount); 1.264 + fSaveInterpolators.setCount(activeTotal); 1.265 + memset(&fSaveInterpolators[oldCount], 0, 1.266 + sizeof(fSaveInterpolators[0]) * (activeTotal - oldCount)); 1.267 + return true; 1.268 + } 1.269 + return false; 1.270 +} 1.271 + 1.272 +void SkActive::initState(SkApply* apply, int offset) { 1.273 + int count = fState.count(); 1.274 + for (int index = offset; index < count; index++) { 1.275 + SkState& state = fState[index]; 1.276 + SkAnimateBase* animate = fAnimators[index]; 1.277 +#if 0 // def SK_DEBUG 1.278 + if (animate->fHasEndEvent) 1.279 + SkDebugf("%8x %8x active initState:\n", this, animate); 1.280 +#endif 1.281 + SkOperand* from = animate->getValues(); 1.282 + state.fStartTime = state.fBegin = apply->begin + animate->begin; 1.283 + state.fMode = apply->mode; 1.284 + state.fTransition = apply->transition; 1.285 +#if 0 1.286 + state.fPickup = (SkBool8) apply->pickup; 1.287 +#endif 1.288 + state.fRestore = (SkBool8) apply->restore; 1.289 + state.fSave = apply->begin; 1.290 + state.fStarted = false; 1.291 + state.fSteps = apply->steps; 1.292 + state.fTicks = 0; 1.293 + state.fUnpostedEndEvent = (SkBool8) animate->fHasEndEvent; 1.294 + calcDurations(index); 1.295 + setInterpolator(index, from); 1.296 + } 1.297 + if (count == 0 && (apply->mode == SkApply::kMode_immediate || apply->mode == SkApply::kMode_create)) 1.298 + fMaxTime = apply->begin + apply->steps * SK_MSec1; 1.299 +} 1.300 + 1.301 +void SkActive::pickUp(SkActive* existing) { 1.302 + SkTDOperandArray existingValues; 1.303 + for (int index = 0; index < fAnimators.count(); index++) { 1.304 + SkAnimateBase* animate = fAnimators[index]; 1.305 + SkASSERT(animate->getValuesType() == SkType_Float); 1.306 + int components = animate->components(); 1.307 + SkOperand* from = animate->getValues(); 1.308 + SkOperand* to = &from[animate->components()]; 1.309 + existingValues.setCount(components); 1.310 + existing->fInterpolators[index]->timeToValues( 1.311 + existing->fState[index].fTicks - existing->fState[index].fStartTime, existingValues.begin()); 1.312 + SkScalar originalSum = 0; 1.313 + SkScalar workingSum = 0; 1.314 + for (int cIndex = 0; cIndex < components; cIndex++) { 1.315 + SkScalar delta = to[cIndex].fScalar - from[cIndex].fScalar; 1.316 + originalSum += SkScalarMul(delta, delta); 1.317 + delta = to[cIndex].fScalar - existingValues[cIndex].fScalar; 1.318 + workingSum += SkScalarMul(delta, delta); 1.319 + } 1.320 + if (workingSum < originalSum) { 1.321 + SkScalar originalDistance = SkScalarSqrt(originalSum); 1.322 + SkScalar workingDistance = SkScalarSqrt(workingSum); 1.323 + existing->fState[index].fDuration = (SkMSec) SkScalarMulDiv(fState[index].fDuration, 1.324 + workingDistance, originalDistance); 1.325 + } 1.326 + fInterpolators[index]->reset(components, 2, SkType_Float); 1.327 + fInterpolators[index]->setKeyFrame(0, 0, existingValues.begin(), animate->blend[0]); 1.328 + fInterpolators[index]->setKeyFrame(1, fState[index].fDuration, to, animate->blend[0]); 1.329 + } 1.330 +} 1.331 + 1.332 +void SkActive::resetInterpolators() { 1.333 + int animators = fAnimators.count(); 1.334 + for (int index = 0; index < animators; index++) { 1.335 + SkAnimateBase* animate = fAnimators[index]; 1.336 + SkOperand* values = animate->getValues(); 1.337 + setInterpolator(index, values); 1.338 + } 1.339 +} 1.340 + 1.341 +void SkActive::resetState() { 1.342 + fDrawIndex = 0; 1.343 + int count = fState.count(); 1.344 + for (int index = 0; index < count; index++) { 1.345 + SkState& state = fState[index]; 1.346 + SkAnimateBase* animate = fAnimators[index]; 1.347 +#if 0 // def SK_DEBUG 1.348 + if (animate->fHasEndEvent) 1.349 + SkDebugf("%8x %8x active resetState: has end event\n", this, animate); 1.350 +#endif 1.351 + state.fStartTime = state.fBegin = fApply.begin + animate->begin; 1.352 + state.fStarted = false; 1.353 + state.fTicks = 0; 1.354 + } 1.355 +} 1.356 + 1.357 +void SkActive::restoreInterpolatorValues(int index) { 1.358 + SkOperandInterpolator& interpolator = *fInterpolators[index]; 1.359 + index += fDrawIndex ; 1.360 + int count = interpolator.getValuesCount(); 1.361 + memcpy(interpolator.getValues(), fSaveInterpolators[index], count * sizeof(SkOperand)); 1.362 +} 1.363 + 1.364 +void SkActive::saveInterpolatorValues(int index) { 1.365 + SkOperandInterpolator& interpolator = *fInterpolators[index]; 1.366 + index += fDrawIndex ; 1.367 + int count = interpolator.getValuesCount(); 1.368 + SkOperand* cache = new SkOperand[count]; // this should use sk_malloc/sk_free since SkOperand does not have a constructor/destructor 1.369 + fSaveInterpolators[index] = cache; 1.370 + memcpy(cache, interpolator.getValues(), count * sizeof(SkOperand)); 1.371 +} 1.372 + 1.373 +void SkActive::setInterpolator(int index, SkOperand* from) { 1.374 + if (from == NULL) // legitimate for set string 1.375 + return; 1.376 + SkAnimateBase* animate = fAnimators[index]; 1.377 + int entries = animate->entries(); 1.378 + SkASSERT(entries > 0); 1.379 + SkMSec duration = fState[index].fDuration; 1.380 + int components = animate->components(); 1.381 + SkOperandInterpolator& interpolator = *fInterpolators[index]; 1.382 + interpolator.reset(components, entries == 1 ? 2 : entries, animate->getValuesType()); 1.383 + interpolator.setMirror(SkToBool(animate->fMirror)); 1.384 + interpolator.setReset(SkToBool(animate->fReset)); 1.385 + interpolator.setRepeatCount(animate->repeat); 1.386 + if (entries == 1) { 1.387 + interpolator.setKeyFrame(0, 0, from, animate->blend[0]); 1.388 + interpolator.setKeyFrame(1, duration, from, animate->blend[0]); 1.389 + return; 1.390 + } 1.391 + for (int entry = 0; entry < entries; entry++) { 1.392 + int blendIndex = SkMin32(animate->blend.count() - 1, entry); 1.393 + interpolator.setKeyFrame(entry, entry * duration / (entries - 1), from, 1.394 + animate->blend[blendIndex]); 1.395 + from += components; 1.396 + } 1.397 +} 1.398 + 1.399 +void SkActive::setSteps(int steps) { 1.400 + int count = fState.count(); 1.401 + fMaxTime = 0; 1.402 + for (int index = 0; index < count; index++) { 1.403 + SkState& state = fState[index]; 1.404 + state.fSteps = steps; 1.405 + calcDurations(index); 1.406 + } 1.407 +} 1.408 + 1.409 +void SkActive::start() { 1.410 + int count = fState.count(); 1.411 + SkASSERT(count == fAnimators.count()); 1.412 + SkASSERT(count == fInterpolators.count()); 1.413 + for (int index = 0; index < count; index++) { 1.414 + SkState& state = fState[index]; 1.415 + if (state.fStarted) 1.416 + continue; 1.417 + state.fStarted = true; 1.418 +#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING 1.419 + SkString debugOut; 1.420 + SkMSec time = fMaker.getAppTime(); 1.421 + debugOut.appendS32(time - fMaker.fDebugTimeBase); 1.422 + debugOut.append(" active start adjust delay id="); 1.423 + debugOut.append(fApply._id); 1.424 + debugOut.append("; "); 1.425 + debugOut.append(fAnimators[index]->_id); 1.426 + debugOut.append("="); 1.427 + debugOut.appendS32(fAnimators[index]->fStart - fMaker.fDebugTimeBase); 1.428 + debugOut.append(":"); 1.429 + debugOut.appendS32(state.fStartTime); 1.430 +#endif 1.431 + if (state.fStartTime > 0) { 1.432 + SkMSec future = fAnimators[index]->fStart + state.fStartTime; 1.433 + if (future > fMaker.fEnableTime) 1.434 + fMaker.notifyInvalTime(future); 1.435 + else 1.436 + fMaker.notifyInval(); 1.437 +#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING 1.438 + debugOut.append(":"); 1.439 + debugOut.appendS32(future - fMaker.fDebugTimeBase); 1.440 +#endif 1.441 + } 1.442 + if (state.fStartTime >= fMaker.fAdjustedStart) { 1.443 + state.fStartTime -= fMaker.fAdjustedStart; 1.444 +#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING 1.445 + debugOut.append(" (less adjust = "); 1.446 + debugOut.appendS32(fMaker.fAdjustedStart); 1.447 +#endif 1.448 + } 1.449 + state.fStartTime += fAnimators[index]->fStart; 1.450 +#if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING 1.451 + debugOut.append(") new start = "); 1.452 + debugOut.appendS32(state.fStartTime - fMaker.fDebugTimeBase); 1.453 + SkDebugf("%s\n", debugOut.c_str()); 1.454 +// SkASSERT((int) (state.fStartTime - fMaker.fDebugTimeBase) >= 0); 1.455 +#endif 1.456 + } 1.457 + SkASSERT(fAnimators.count() == fInterpolators.count()); 1.458 +} 1.459 + 1.460 +#ifdef SK_DEBUG 1.461 +void SkActive::validate() { 1.462 + int count = fState.count(); 1.463 + SkASSERT(count == fAnimators.count()); 1.464 + SkASSERT(count == fInterpolators.count()); 1.465 + for (int index = 0; index < count; index++) { 1.466 + SkASSERT(fAnimators[index]); 1.467 + SkASSERT(fInterpolators[index]); 1.468 +// SkAnimateBase* test = fAnimators[index]; 1.469 +// SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget)); 1.470 + } 1.471 +} 1.472 +#endif 1.473 + 1.474 +// think about this 1.475 +// there should only be one animate object, not two, to go up and down 1.476 +// when the apply with reverse came into play, it needs to pick up the value 1.477 +// of the existing animate object then remove it from the list 1.478 +// the code below should only be bumping fSave, and there shouldn't be anything 1.479 +// it needs to be synchronized with 1.480 + 1.481 +// however, if there are two animates both operating on the same field, then 1.482 +// when one replaces the other, it may make sense to pick up the old value as a starting 1.483 +// value for the new one somehow. 1.484 + 1.485 +//void SkActive::SkState::bumpSave() { 1.486 +// if (fMode != SkApply::kMode_hold) 1.487 +// return; 1.488 +// if (fTransition == SkApply::kTransition_reverse) { 1.489 +// if (fSave > 0) 1.490 +// fSave -= SK_MSec1; 1.491 +// } else if (fSave < fDuration) 1.492 +// fSave += SK_MSec1; 1.493 +//} 1.494 + 1.495 +SkMSec SkActive::SkState::getRelativeTime(SkMSec time) { 1.496 + SkMSec result = time; 1.497 +// if (fMode == SkApply::kMode_hold) 1.498 +// result = fSave; 1.499 +// else 1.500 + if (fTransition == SkApply::kTransition_reverse) { 1.501 + if (SkMSec_LT(fDuration, time)) 1.502 + result = 0; 1.503 + else 1.504 + result = fDuration - time; 1.505 + } 1.506 + return result; 1.507 +}