gfx/skia/trunk/src/animator/SkAnimateActive.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #include "SkAnimateActive.h"
michael@0 11 #include "SkAnimateBase.h"
michael@0 12 #include "SkAnimateMaker.h"
michael@0 13 #include "SkAnimateSet.h"
michael@0 14 #include "SkDrawGroup.h"
michael@0 15 #ifdef SK_DEBUG
michael@0 16 #include "SkTime.h"
michael@0 17 #endif
michael@0 18
michael@0 19 // SkActive holds array of interpolators
michael@0 20
michael@0 21 SkActive::SkActive(SkApply& apply, SkAnimateMaker& maker) : fApply(apply),
michael@0 22 fMaxTime(0), fMaker(maker), fDrawIndex(0), fDrawMax(0) {
michael@0 23 }
michael@0 24
michael@0 25 void SkActive::init()
michael@0 26 {
michael@0 27 fAnimators = fApply.fAnimators;
michael@0 28 int animators = fAnimators.count();
michael@0 29 fInterpolators.setCount(animators);
michael@0 30 memset(fInterpolators.begin(), 0, animators * sizeof(SkOperandInterpolator*));
michael@0 31 fState.setCount(animators);
michael@0 32 int index;
michael@0 33 for (index = 0; index < animators; index++)
michael@0 34 fInterpolators[index] = SkNEW(SkOperandInterpolator);
michael@0 35 initState(&fApply, 0);
michael@0 36 // for (index = 0; index < animators; index++)
michael@0 37 // fState[index].bumpSave();
michael@0 38 SkASSERT(fInterpolators.count() == fAnimators.count());
michael@0 39 }
michael@0 40
michael@0 41 SkActive::~SkActive() {
michael@0 42 int index;
michael@0 43 for (index = 0; index < fSaveRestore.count(); index++)
michael@0 44 delete[] fSaveRestore[index];
michael@0 45 for (index = 0; index < fSaveInterpolators.count(); index++)
michael@0 46 delete[] fSaveInterpolators[index];
michael@0 47 for (index = 0; index < fInterpolators.count(); index++)
michael@0 48 delete fInterpolators[index];
michael@0 49 }
michael@0 50
michael@0 51 void SkActive::advance() {
michael@0 52 if (fDrawMax < fDrawIndex)
michael@0 53 fDrawMax = fDrawIndex;
michael@0 54 fDrawIndex += fAnimators.count();
michael@0 55 }
michael@0 56
michael@0 57 void SkActive::append(SkApply* apply) {
michael@0 58 int oldCount = fAnimators.count();
michael@0 59 SkTDAnimateArray& animates = apply->fAnimators;
michael@0 60 int newCount = animates.count();
michael@0 61 int index;
michael@0 62 int total = oldCount + newCount;
michael@0 63 if (total == 0)
michael@0 64 return;
michael@0 65 fInterpolators.setCount(total);
michael@0 66 memset(&fInterpolators.begin()[oldCount], 0, newCount * sizeof(SkOperandInterpolator*));
michael@0 67 for (index = oldCount; index < total; index++)
michael@0 68 fInterpolators[index] = SkNEW(SkOperandInterpolator);
michael@0 69 fAnimators.setCount(total);
michael@0 70 memcpy(&fAnimators[oldCount], animates.begin(), sizeof(fAnimators[0]) *
michael@0 71 newCount);
michael@0 72 fState.setCount(total);
michael@0 73 initState(apply, oldCount);
michael@0 74 SkASSERT(fApply.scope == apply->scope);
michael@0 75 for (index = 0; index < newCount; index++) {
michael@0 76 SkAnimateBase* test = animates[index];
michael@0 77 // SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget));
michael@0 78 SkActive::SkState& testState = fState[oldCount + index];
michael@0 79 for (int inner = 0; inner < oldCount; inner++) {
michael@0 80 SkAnimateBase* oldGuard = fAnimators[inner];
michael@0 81 SkActive::SkState& oldState = fState[inner];
michael@0 82 if (oldGuard->fTarget == test->fTarget && oldGuard->fFieldInfo == test->fFieldInfo &&
michael@0 83 testState.fBegin == oldState.fBegin) {
michael@0 84 delete fInterpolators[inner];
michael@0 85 fInterpolators.remove(inner);
michael@0 86 fAnimators.remove(inner);
michael@0 87 testState.fSave = oldState.fSave;
michael@0 88 if (oldState.fUnpostedEndEvent) {
michael@0 89 // SkDEBUGF(("%8x %8x active append: post on end\n", this, oldGuard));
michael@0 90 fMaker.postOnEnd(oldGuard, oldState.fBegin + oldState.fDuration);
michael@0 91 }
michael@0 92 fState.remove(inner);
michael@0 93 if (fApply.restore) {
michael@0 94 int saveIndex = fSaveRestore.count();
michael@0 95 SkASSERT(fSaveInterpolators.count() == saveIndex);
michael@0 96 saveIndex += inner;
michael@0 97 do {
michael@0 98 saveIndex -= oldCount;
michael@0 99 delete[] fSaveRestore[saveIndex];
michael@0 100 fSaveRestore.remove(saveIndex);
michael@0 101 delete[] fSaveInterpolators[saveIndex];
michael@0 102 fSaveInterpolators.remove(saveIndex);
michael@0 103 } while (saveIndex > 0);
michael@0 104 }
michael@0 105 oldCount--;
michael@0 106 break;
michael@0 107 }
michael@0 108 }
michael@0 109 }
michael@0 110 // total = oldCount + newCount;
michael@0 111 // for (index = oldCount; index < total; index++)
michael@0 112 // fState[index].bumpSave();
michael@0 113 SkASSERT(fInterpolators.count() == fAnimators.count());
michael@0 114 }
michael@0 115
michael@0 116 void SkActive::appendSave(int oldCount) {
michael@0 117 SkASSERT(fDrawMax == 0); // if true, we can optimize below quite a bit
michael@0 118 int newCount = fAnimators.count();
michael@0 119 int saveIndex = fSaveRestore.count();
michael@0 120 SkASSERT(fSaveInterpolators.count() == saveIndex);
michael@0 121 int records = saveIndex / oldCount;
michael@0 122 int newTotal = records * newCount;
michael@0 123 fSaveRestore.setCount(newTotal);
michael@0 124 do {
michael@0 125 saveIndex -= oldCount;
michael@0 126 newTotal -= newCount;
michael@0 127 SkASSERT(saveIndex >= 0);
michael@0 128 SkASSERT(newTotal >= 0);
michael@0 129 memmove(&fSaveRestore[newTotal], &fSaveRestore[saveIndex], oldCount);
michael@0 130 memset(&fSaveRestore[newTotal + oldCount], 0,
michael@0 131 sizeof(fSaveRestore[0]) * (newCount - oldCount));
michael@0 132 memmove(&fSaveInterpolators[newTotal],
michael@0 133 &fSaveInterpolators[saveIndex], oldCount);
michael@0 134 memset(&fSaveInterpolators[newTotal + oldCount], 0,
michael@0 135 sizeof(fSaveRestore[0]) * (newCount - oldCount));
michael@0 136 } while (saveIndex > 0);
michael@0 137 SkASSERT(newTotal == 0);
michael@0 138 }
michael@0 139
michael@0 140 void SkActive::calcDurations(int index)
michael@0 141 {
michael@0 142 SkAnimateBase* animate = fAnimators[index];
michael@0 143 SkMSec duration = animate->dur;
michael@0 144 SkState& state = fState[index];
michael@0 145 switch (state.fMode) {
michael@0 146 case SkApply::kMode_immediate:
michael@0 147 case SkApply::kMode_create:
michael@0 148 duration = state.fSteps ? state.fSteps * SK_MSec1 : 1;
michael@0 149 break;
michael@0 150 // case SkApply::kMode_hold: {
michael@0 151 // int entries = animate->entries();
michael@0 152 // SkScriptValue value;
michael@0 153 // value.fOperand = animate->getValues()[entries - 1];
michael@0 154 // value.fType = animate->getValuesType();
michael@0 155 // bool result = SkScriptEngine::ConvertTo(NULL, SkType_Int, &value);
michael@0 156 // SkASSERT(result);
michael@0 157 // duration = value.fOperand.fS32 * SK_MSec1;
michael@0 158 // break;
michael@0 159 // }
michael@0 160 }
michael@0 161 state.fDuration = duration;
michael@0 162 SkMSec maxTime = state.fBegin + duration;
michael@0 163 if (fMaxTime < maxTime)
michael@0 164 fMaxTime = maxTime;
michael@0 165 }
michael@0 166
michael@0 167 void SkActive::create(SkDrawable* drawable, SkMSec time) {
michael@0 168 fApply.fLastTime = time;
michael@0 169 fApply.refresh(fMaker);
michael@0 170 for (int index = 0; index < fAnimators.count(); index++) {
michael@0 171 SkAnimateBase* animate = fAnimators[index];
michael@0 172 SkOperandInterpolator& interpolator = *fInterpolators[index];
michael@0 173 int count = animate->components();
michael@0 174 if (animate->formula.size() > 0) {
michael@0 175 SkTDOperandArray values;
michael@0 176 values.setCount(count);
michael@0 177 SkDEBUGCODE(bool success = ) animate->fFieldInfo->setValue(fMaker, &values, 0, 0, NULL,
michael@0 178 animate->getValuesType(), animate->formula);
michael@0 179 SkASSERT(success);
michael@0 180 fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time);
michael@0 181 } else {
michael@0 182 SkAutoSTMalloc<16, SkOperand> values(count);
michael@0 183 interpolator.timeToValues(time, values.get());
michael@0 184 fApply.applyValues(index, values.get(), count, animate->getValuesType(), time);
michael@0 185 }
michael@0 186 }
michael@0 187 drawable->enable(fMaker);
michael@0 188 SkASSERT(fAnimators.count() == fInterpolators.count());
michael@0 189 }
michael@0 190
michael@0 191 bool SkActive::immediate(bool enable) {
michael@0 192 SkMSec time = 0;
michael@0 193 bool result = false;
michael@0 194 SkDrawable* drawable = fApply.scope;
michael@0 195 SkMSec final = fMaxTime;
michael@0 196 do {
michael@0 197 bool applied = fAnimators.count() == 0;
michael@0 198 fApply.fLastTime = time;
michael@0 199 fApply.refresh(fMaker);
michael@0 200 for (int index = 0; index < fAnimators.count(); index++) {
michael@0 201 SkAnimateBase* animate = fAnimators[index];
michael@0 202 SkState& state = fState[index];
michael@0 203 if (state.fMode != SkApply::kMode_immediate)
michael@0 204 continue;
michael@0 205 if (state.fBegin > time)
michael@0 206 continue;
michael@0 207 if (time > state.fBegin + state.fDuration)
michael@0 208 continue;
michael@0 209 applied = true;
michael@0 210 SkOperandInterpolator& interpolator = *fInterpolators[index];
michael@0 211 int count = animate->components();
michael@0 212 if (animate->formula.size() > 0) {
michael@0 213 SkTDOperandArray values;
michael@0 214 values.setCount(count);
michael@0 215 SkDEBUGCODE(bool success = ) animate->fFieldInfo->setValue(fMaker, &values, 0, 0, NULL,
michael@0 216 animate->getValuesType(), animate->formula);
michael@0 217 SkASSERT(success);
michael@0 218 fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time);
michael@0 219 } else {
michael@0 220 SkAutoSTMalloc<16, SkOperand> values(count);
michael@0 221 interpolator.timeToValues(time, values.get());
michael@0 222 fApply.applyValues(index, values.get(), count, animate->getValuesType(), time);
michael@0 223 }
michael@0 224 }
michael@0 225 if (enable)
michael@0 226 drawable->enable(fMaker);
michael@0 227 else if (applied)
michael@0 228 result |= drawable->draw(fMaker);
michael@0 229 time += SK_MSec1;
michael@0 230 } while (time <= final);
michael@0 231 return result;
michael@0 232 }
michael@0 233
michael@0 234 void SkActive::fixInterpolator(SkBool save) {
michael@0 235 int animators = fAnimators.count();
michael@0 236 for (int index = 0; index < animators; index++) {
michael@0 237 SkAnimateBase* animate = fAnimators[index];
michael@0 238 if (save) { // saved slots increased
michael@0 239 animate->refresh(fMaker);
michael@0 240 SkOperand* values = animate->getValues();
michael@0 241 setInterpolator(index, values);
michael@0 242 saveInterpolatorValues(index);
michael@0 243 } else
michael@0 244 restoreInterpolatorValues(index);
michael@0 245 }
michael@0 246 }
michael@0 247
michael@0 248 SkMSec SkActive::getTime(SkMSec inTime, int animatorIndex) {
michael@0 249 fState[animatorIndex].fTicks = inTime;
michael@0 250 return inTime - fState[animatorIndex].fStartTime;
michael@0 251 }
michael@0 252
michael@0 253 bool SkActive::initializeSave() {
michael@0 254 int animators = fAnimators.count();
michael@0 255 int activeTotal = fDrawIndex + animators;
michael@0 256 int oldCount = fSaveRestore.count();
michael@0 257 if (oldCount < activeTotal) {
michael@0 258 fSaveRestore.setCount(activeTotal);
michael@0 259 memset(&fSaveRestore[oldCount], 0, sizeof(fSaveRestore[0]) * (activeTotal - oldCount));
michael@0 260 SkASSERT(fSaveInterpolators.count() == oldCount);
michael@0 261 fSaveInterpolators.setCount(activeTotal);
michael@0 262 memset(&fSaveInterpolators[oldCount], 0,
michael@0 263 sizeof(fSaveInterpolators[0]) * (activeTotal - oldCount));
michael@0 264 return true;
michael@0 265 }
michael@0 266 return false;
michael@0 267 }
michael@0 268
michael@0 269 void SkActive::initState(SkApply* apply, int offset) {
michael@0 270 int count = fState.count();
michael@0 271 for (int index = offset; index < count; index++) {
michael@0 272 SkState& state = fState[index];
michael@0 273 SkAnimateBase* animate = fAnimators[index];
michael@0 274 #if 0 // def SK_DEBUG
michael@0 275 if (animate->fHasEndEvent)
michael@0 276 SkDebugf("%8x %8x active initState:\n", this, animate);
michael@0 277 #endif
michael@0 278 SkOperand* from = animate->getValues();
michael@0 279 state.fStartTime = state.fBegin = apply->begin + animate->begin;
michael@0 280 state.fMode = apply->mode;
michael@0 281 state.fTransition = apply->transition;
michael@0 282 #if 0
michael@0 283 state.fPickup = (SkBool8) apply->pickup;
michael@0 284 #endif
michael@0 285 state.fRestore = (SkBool8) apply->restore;
michael@0 286 state.fSave = apply->begin;
michael@0 287 state.fStarted = false;
michael@0 288 state.fSteps = apply->steps;
michael@0 289 state.fTicks = 0;
michael@0 290 state.fUnpostedEndEvent = (SkBool8) animate->fHasEndEvent;
michael@0 291 calcDurations(index);
michael@0 292 setInterpolator(index, from);
michael@0 293 }
michael@0 294 if (count == 0 && (apply->mode == SkApply::kMode_immediate || apply->mode == SkApply::kMode_create))
michael@0 295 fMaxTime = apply->begin + apply->steps * SK_MSec1;
michael@0 296 }
michael@0 297
michael@0 298 void SkActive::pickUp(SkActive* existing) {
michael@0 299 SkTDOperandArray existingValues;
michael@0 300 for (int index = 0; index < fAnimators.count(); index++) {
michael@0 301 SkAnimateBase* animate = fAnimators[index];
michael@0 302 SkASSERT(animate->getValuesType() == SkType_Float);
michael@0 303 int components = animate->components();
michael@0 304 SkOperand* from = animate->getValues();
michael@0 305 SkOperand* to = &from[animate->components()];
michael@0 306 existingValues.setCount(components);
michael@0 307 existing->fInterpolators[index]->timeToValues(
michael@0 308 existing->fState[index].fTicks - existing->fState[index].fStartTime, existingValues.begin());
michael@0 309 SkScalar originalSum = 0;
michael@0 310 SkScalar workingSum = 0;
michael@0 311 for (int cIndex = 0; cIndex < components; cIndex++) {
michael@0 312 SkScalar delta = to[cIndex].fScalar - from[cIndex].fScalar;
michael@0 313 originalSum += SkScalarMul(delta, delta);
michael@0 314 delta = to[cIndex].fScalar - existingValues[cIndex].fScalar;
michael@0 315 workingSum += SkScalarMul(delta, delta);
michael@0 316 }
michael@0 317 if (workingSum < originalSum) {
michael@0 318 SkScalar originalDistance = SkScalarSqrt(originalSum);
michael@0 319 SkScalar workingDistance = SkScalarSqrt(workingSum);
michael@0 320 existing->fState[index].fDuration = (SkMSec) SkScalarMulDiv(fState[index].fDuration,
michael@0 321 workingDistance, originalDistance);
michael@0 322 }
michael@0 323 fInterpolators[index]->reset(components, 2, SkType_Float);
michael@0 324 fInterpolators[index]->setKeyFrame(0, 0, existingValues.begin(), animate->blend[0]);
michael@0 325 fInterpolators[index]->setKeyFrame(1, fState[index].fDuration, to, animate->blend[0]);
michael@0 326 }
michael@0 327 }
michael@0 328
michael@0 329 void SkActive::resetInterpolators() {
michael@0 330 int animators = fAnimators.count();
michael@0 331 for (int index = 0; index < animators; index++) {
michael@0 332 SkAnimateBase* animate = fAnimators[index];
michael@0 333 SkOperand* values = animate->getValues();
michael@0 334 setInterpolator(index, values);
michael@0 335 }
michael@0 336 }
michael@0 337
michael@0 338 void SkActive::resetState() {
michael@0 339 fDrawIndex = 0;
michael@0 340 int count = fState.count();
michael@0 341 for (int index = 0; index < count; index++) {
michael@0 342 SkState& state = fState[index];
michael@0 343 SkAnimateBase* animate = fAnimators[index];
michael@0 344 #if 0 // def SK_DEBUG
michael@0 345 if (animate->fHasEndEvent)
michael@0 346 SkDebugf("%8x %8x active resetState: has end event\n", this, animate);
michael@0 347 #endif
michael@0 348 state.fStartTime = state.fBegin = fApply.begin + animate->begin;
michael@0 349 state.fStarted = false;
michael@0 350 state.fTicks = 0;
michael@0 351 }
michael@0 352 }
michael@0 353
michael@0 354 void SkActive::restoreInterpolatorValues(int index) {
michael@0 355 SkOperandInterpolator& interpolator = *fInterpolators[index];
michael@0 356 index += fDrawIndex ;
michael@0 357 int count = interpolator.getValuesCount();
michael@0 358 memcpy(interpolator.getValues(), fSaveInterpolators[index], count * sizeof(SkOperand));
michael@0 359 }
michael@0 360
michael@0 361 void SkActive::saveInterpolatorValues(int index) {
michael@0 362 SkOperandInterpolator& interpolator = *fInterpolators[index];
michael@0 363 index += fDrawIndex ;
michael@0 364 int count = interpolator.getValuesCount();
michael@0 365 SkOperand* cache = new SkOperand[count]; // this should use sk_malloc/sk_free since SkOperand does not have a constructor/destructor
michael@0 366 fSaveInterpolators[index] = cache;
michael@0 367 memcpy(cache, interpolator.getValues(), count * sizeof(SkOperand));
michael@0 368 }
michael@0 369
michael@0 370 void SkActive::setInterpolator(int index, SkOperand* from) {
michael@0 371 if (from == NULL) // legitimate for set string
michael@0 372 return;
michael@0 373 SkAnimateBase* animate = fAnimators[index];
michael@0 374 int entries = animate->entries();
michael@0 375 SkASSERT(entries > 0);
michael@0 376 SkMSec duration = fState[index].fDuration;
michael@0 377 int components = animate->components();
michael@0 378 SkOperandInterpolator& interpolator = *fInterpolators[index];
michael@0 379 interpolator.reset(components, entries == 1 ? 2 : entries, animate->getValuesType());
michael@0 380 interpolator.setMirror(SkToBool(animate->fMirror));
michael@0 381 interpolator.setReset(SkToBool(animate->fReset));
michael@0 382 interpolator.setRepeatCount(animate->repeat);
michael@0 383 if (entries == 1) {
michael@0 384 interpolator.setKeyFrame(0, 0, from, animate->blend[0]);
michael@0 385 interpolator.setKeyFrame(1, duration, from, animate->blend[0]);
michael@0 386 return;
michael@0 387 }
michael@0 388 for (int entry = 0; entry < entries; entry++) {
michael@0 389 int blendIndex = SkMin32(animate->blend.count() - 1, entry);
michael@0 390 interpolator.setKeyFrame(entry, entry * duration / (entries - 1), from,
michael@0 391 animate->blend[blendIndex]);
michael@0 392 from += components;
michael@0 393 }
michael@0 394 }
michael@0 395
michael@0 396 void SkActive::setSteps(int steps) {
michael@0 397 int count = fState.count();
michael@0 398 fMaxTime = 0;
michael@0 399 for (int index = 0; index < count; index++) {
michael@0 400 SkState& state = fState[index];
michael@0 401 state.fSteps = steps;
michael@0 402 calcDurations(index);
michael@0 403 }
michael@0 404 }
michael@0 405
michael@0 406 void SkActive::start() {
michael@0 407 int count = fState.count();
michael@0 408 SkASSERT(count == fAnimators.count());
michael@0 409 SkASSERT(count == fInterpolators.count());
michael@0 410 for (int index = 0; index < count; index++) {
michael@0 411 SkState& state = fState[index];
michael@0 412 if (state.fStarted)
michael@0 413 continue;
michael@0 414 state.fStarted = true;
michael@0 415 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
michael@0 416 SkString debugOut;
michael@0 417 SkMSec time = fMaker.getAppTime();
michael@0 418 debugOut.appendS32(time - fMaker.fDebugTimeBase);
michael@0 419 debugOut.append(" active start adjust delay id=");
michael@0 420 debugOut.append(fApply._id);
michael@0 421 debugOut.append("; ");
michael@0 422 debugOut.append(fAnimators[index]->_id);
michael@0 423 debugOut.append("=");
michael@0 424 debugOut.appendS32(fAnimators[index]->fStart - fMaker.fDebugTimeBase);
michael@0 425 debugOut.append(":");
michael@0 426 debugOut.appendS32(state.fStartTime);
michael@0 427 #endif
michael@0 428 if (state.fStartTime > 0) {
michael@0 429 SkMSec future = fAnimators[index]->fStart + state.fStartTime;
michael@0 430 if (future > fMaker.fEnableTime)
michael@0 431 fMaker.notifyInvalTime(future);
michael@0 432 else
michael@0 433 fMaker.notifyInval();
michael@0 434 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
michael@0 435 debugOut.append(":");
michael@0 436 debugOut.appendS32(future - fMaker.fDebugTimeBase);
michael@0 437 #endif
michael@0 438 }
michael@0 439 if (state.fStartTime >= fMaker.fAdjustedStart) {
michael@0 440 state.fStartTime -= fMaker.fAdjustedStart;
michael@0 441 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
michael@0 442 debugOut.append(" (less adjust = ");
michael@0 443 debugOut.appendS32(fMaker.fAdjustedStart);
michael@0 444 #endif
michael@0 445 }
michael@0 446 state.fStartTime += fAnimators[index]->fStart;
michael@0 447 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
michael@0 448 debugOut.append(") new start = ");
michael@0 449 debugOut.appendS32(state.fStartTime - fMaker.fDebugTimeBase);
michael@0 450 SkDebugf("%s\n", debugOut.c_str());
michael@0 451 // SkASSERT((int) (state.fStartTime - fMaker.fDebugTimeBase) >= 0);
michael@0 452 #endif
michael@0 453 }
michael@0 454 SkASSERT(fAnimators.count() == fInterpolators.count());
michael@0 455 }
michael@0 456
michael@0 457 #ifdef SK_DEBUG
michael@0 458 void SkActive::validate() {
michael@0 459 int count = fState.count();
michael@0 460 SkASSERT(count == fAnimators.count());
michael@0 461 SkASSERT(count == fInterpolators.count());
michael@0 462 for (int index = 0; index < count; index++) {
michael@0 463 SkASSERT(fAnimators[index]);
michael@0 464 SkASSERT(fInterpolators[index]);
michael@0 465 // SkAnimateBase* test = fAnimators[index];
michael@0 466 // SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget));
michael@0 467 }
michael@0 468 }
michael@0 469 #endif
michael@0 470
michael@0 471 // think about this
michael@0 472 // there should only be one animate object, not two, to go up and down
michael@0 473 // when the apply with reverse came into play, it needs to pick up the value
michael@0 474 // of the existing animate object then remove it from the list
michael@0 475 // the code below should only be bumping fSave, and there shouldn't be anything
michael@0 476 // it needs to be synchronized with
michael@0 477
michael@0 478 // however, if there are two animates both operating on the same field, then
michael@0 479 // when one replaces the other, it may make sense to pick up the old value as a starting
michael@0 480 // value for the new one somehow.
michael@0 481
michael@0 482 //void SkActive::SkState::bumpSave() {
michael@0 483 // if (fMode != SkApply::kMode_hold)
michael@0 484 // return;
michael@0 485 // if (fTransition == SkApply::kTransition_reverse) {
michael@0 486 // if (fSave > 0)
michael@0 487 // fSave -= SK_MSec1;
michael@0 488 // } else if (fSave < fDuration)
michael@0 489 // fSave += SK_MSec1;
michael@0 490 //}
michael@0 491
michael@0 492 SkMSec SkActive::SkState::getRelativeTime(SkMSec time) {
michael@0 493 SkMSec result = time;
michael@0 494 // if (fMode == SkApply::kMode_hold)
michael@0 495 // result = fSave;
michael@0 496 // else
michael@0 497 if (fTransition == SkApply::kTransition_reverse) {
michael@0 498 if (SkMSec_LT(fDuration, time))
michael@0 499 result = 0;
michael@0 500 else
michael@0 501 result = fDuration - time;
michael@0 502 }
michael@0 503 return result;
michael@0 504 }

mercurial