JSBool SkJSDisplayable::Draw(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { SkJSDisplayable *p = (SkJSDisplayable*) JS_GetPrivate(cx, obj); SkASSERT(p->fDisplayable->isDrawable()); SkDrawable* drawable = (SkDrawable*) p->fDisplayable; SkAnimateMaker maker(NULL, gCanvas, gPaint); drawable->draw(maker); return JS_TRUE; }
bool SkGroup::draw(SkAnimateMaker& maker) { bool conditionTrue = ifCondition(maker, this, condition); bool result = false; for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) { SkDrawable* drawable = *ptr; if (drawable->isDrawable() == false) continue; if (conditionTrue == false) { if (drawable->isApply()) ((SkApply*) drawable)->disable(); continue; } maker.validate(); result |= drawable->draw(maker); maker.validate(); } return result; }
bool SkActive::immediate(bool enable) { SkMSec time = 0; bool result = false; SkDrawable* drawable = fApply.scope; SkMSec final = fMaxTime; do { bool applied = fAnimators.count() == 0; fApply.fLastTime = time; fApply.refresh(fMaker); for (int index = 0; index < fAnimators.count(); index++) { SkAnimateBase* animate = fAnimators[index]; SkState& state = fState[index]; if (state.fMode != SkApply::kMode_immediate) continue; if (state.fBegin > time) continue; if (time > state.fBegin + state.fDuration) continue; applied = true; SkOperandInterpolator& interpolator = *fInterpolators[index]; int count = animate->components(); if (animate->formula.size() > 0) { SkTDOperandArray values; values.setCount(count); bool success = animate->fFieldInfo->setValue(fMaker, &values, 0, 0, NULL, animate->getValuesType(), animate->formula); SkASSERT(success); fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time); } else { SkAutoSTMalloc<16, SkOperand> values(count); interpolator.timeToValues(time, values.get()); fApply.applyValues(index, values.get(), count, animate->getValuesType(), time); } } if (enable) drawable->enable(fMaker); else if (applied) result |= drawable->draw(fMaker); time += SK_MSec1; } while (time <= final); return result; }
bool SkDisplayList::draw(SkAnimateMaker& maker, SkMSec inTime) { validate(); fInTime = inTime; bool result = false; fInvalBounds.setEmpty(); if (fDrawList.count()) { for (SkActive** activePtr = fActiveList.begin(); activePtr < fActiveList.end(); activePtr++) { SkActive* active = *activePtr; active->reset(); } for (int index = 0; index < fDrawList.count(); index++) { SkDrawable* draw = fDrawList[index]; draw->initialize(); // allow matrices to reset themselves SkASSERT(draw->isDrawable()); validate(); result |= draw->draw(maker); } } validate(); return result; }