bool SkAnimatorScript::NaN(const char* token, size_t len, void* user, SkScriptValue* value) {
    if (SK_LITERAL_STR_EQUAL("NaN", token, len) == false)
        return false;
    value->fType = SkType_Float;
    value->fOperand.fScalar = SK_ScalarNaN;
    return true;
}
bool SkAnimatorScript::EvalID(const char* token, size_t len, void* user, SkScriptValue* value) {
    SkAnimatorScript* engine = (SkAnimatorScript*) user;
    SkTDict<SkDisplayable*>* ids = &engine->fMaker.fIDs;
    SkDisplayable* displayable;
    bool success = ids->find(token, len, &displayable);
    if (success == false) {
        displayable = engine->fWorking;
        if (SK_LITERAL_STR_EQUAL("parent", token, len)) {
            SkDisplayable* parent = displayable->getParent();
            if (parent == false)
                parent = engine->fParent;
            if (parent) {
                value->fOperand.fDisplayable = parent;
                value->fType = SkType_Displayable;
                return true;
            }
        }
        if (displayable && EvalMember(token, len, displayable, engine, value))
            return true;
        value->fOperand.fString = NULL;
        value->fType = SkType_String;
    } else {
        SkDisplayable* working = engine->fWorking;
        value->fOperand.fDisplayable = displayable;
        value->fType = SkType_Displayable;
        if (displayable->canContainDependents() && working && working->isAnimate()) {
            SkAnimateBase* animator = (SkAnimateBase*) working;
            if (animator->isDynamic()) {
                SkDisplayDepend* depend = (SkDisplayDepend* ) displayable;
                depend->addDependent(working);
            }
        }
    }
    return true;
}
Esempio n. 3
0
 static bool GetUnitValue(const char* token, size_t len, void* unitPtr, SkScriptValue* value) {
     if (SK_LITERAL_STR_EQUAL("unit", token, len)) {
         value->fOperand.fScalar = *(SkScalar*) unitPtr;
         value->fType = SkType_Float;
         return true;
     }
     return false;
 }
Esempio n. 4
0
bool SkAnimateMaker::GetStep(const char* token, size_t len, void* stepPtr, SkScriptValue* value) {
    if (SK_LITERAL_STR_EQUAL("step", token, len)) {
        value->fOperand.fS32 = *(int32_t*) stepPtr;
        value->fType = SkType_Int;
        return true;
    }
    return false;
}
 virtual SkDisplayTypes getType(const char name[], size_t len ) {
     SkDisplayTypes* type = nullptr;
     if (SK_LITERAL_STR_EQUAL(kDrawShape1DPathEffectName, name, len))
         type = &skDrawShape1DPathEffectType;
     else if (SK_LITERAL_STR_EQUAL(kDrawShape2DPathEffectName, name, len))
         type = &skDrawShape2DPathEffectType;
     else if (SK_LITERAL_STR_EQUAL(kDrawComposePathEffectName, name, len))
         type = &skDrawComposePathEffectType;
     else if (SK_LITERAL_STR_EQUAL(kDrawCornerPathEffectName, name, len))
         type = &skDrawCornerPathEffectType;
     if (type) {
         if (*type == SkType_Unknown)
             *type = SkDisplayType::RegisterNewType();
         return *type;
     }
     return SkType_Unknown;
 }
 static bool GetDistance(const char* token, size_t len, void* dist, SkScriptValue* value) {
     if (SK_LITERAL_STR_EQUAL("distance", token, len)) {
         value->fOperand.fScalar = *(SkScalar*) dist;
         value->fType = SkType_Float;
         return true;
     }
     return false;
 }
 static bool GetContourLength(const char* token, size_t len, void* clen, SkScriptValue* value) {
     if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) {
         value->fOperand.fScalar = *(SkScalar*) clen;
         value->fType = SkType_Float;
         return true;
     }
     return false;
 }
bool SkAnimatorScript::IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* eng, SkScriptValue* value) {
    if (SK_LITERAL_STR_EQUAL("isNaN", function, len) == false)
        return false;
    if (params.count() != 1)
        return false;
    SkScriptValue* scriptValue = params.begin();
    value->fType = SkType_Int;
    value->fOperand.fS32 = scriptValue->fType == SkType_Float ? SkScalarIsNaN(scriptValue->fOperand.fScalar) : 0;
    return true;
}
bool SkAnimatorScript::IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* eng, SkScriptValue* value) {
    if (SK_LITERAL_STR_EQUAL(function, "isFinite", len) == false)
        return false;
    if (params.count() != 1)
        return false;
    SkScriptValue* scriptValue = params.begin();
    SkDisplayTypes type = scriptValue->fType;
    SkScalar scalar = scriptValue->fOperand.fScalar;
    value->fType = SkType_Int;
    value->fOperand.fS32 = type == SkType_Float ? SkScalarIsNaN(scalar) == false &&
        SkScalarAbs(scalar) != SK_ScalarInfinity    : type == SkType_Int;
    return true;
}
bool SkAnimatorScript::Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* eng, SkScriptValue* value) {
    if (SK_LITERAL_STR_EQUAL("eval", function, len) == false)
        return false;
    if (params.count() != 1)
        return false;
    SkAnimatorScript* host = (SkAnimatorScript*) eng;
    SkAnimatorScript engine(host->fMaker, host->fWorking, SkScriptEngine::ToDisplayType(host->fReturnType));
    SkScriptValue* scriptValue = params.begin();
    bool success = true;
    if (scriptValue->fType == SkType_String) {
        const char* script = scriptValue->fOperand.fString->c_str();
        success = engine.evaluateScript(&script, value);
    } else
        *value = *scriptValue;
    return success;
}
bool SkAnimatorScript::EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* eng, SkScriptValue* value) {
    if (SK_LITERAL_STR_EQUAL("rgb", function, len) == false)
        return false;
    if (params.count() != 3)
        return false;
    SkScriptEngine* engine = (SkScriptEngine*) eng;
    unsigned result = 0xFF000000;
    int shift = 16;
    for (SkScriptValue* valuePtr = params.begin(); valuePtr < params.end(); valuePtr++) {
        engine->convertTo(SkType_Int, valuePtr);
        result |= SkClampMax(valuePtr->fOperand.fS32, 255) << shift;
        shift -= 8;
    }
    value->fOperand.fS32 = result;
    value->fType = SkType_Int;
    return true;
}
Esempio n. 12
0
 virtual bool getIndex(const char* name, int len, size_t* result) {
     if (SK_LITERAL_STR_EQUAL("eval", name, len) != 0)
         return false;
     *result = 0;
     return true;
 }