michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkAnimatorScript_DEFINED michael@0: #define SkAnimatorScript_DEFINED michael@0: michael@0: #include "SkDisplayable.h" michael@0: #include "SkScript.h" michael@0: #include "SkTypedArray.h" michael@0: michael@0: class SkAnimateMaker; michael@0: struct SkMemberInfo; michael@0: michael@0: struct SkDisplayEnumMap { michael@0: SkDisplayTypes fType; michael@0: const char* fValues; michael@0: }; michael@0: michael@0: class SkAnimatorScript : public SkScriptEngine { michael@0: public: michael@0: SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type); michael@0: ~SkAnimatorScript(); michael@0: bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type); michael@0: void track(SkDisplayable* displayable) { michael@0: SkASSERT(fTrackDisplayable.find(displayable) < 0); michael@0: *fTrackDisplayable.append() = displayable; } michael@0: static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const char* script, SkDisplayable** ); michael@0: static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* script, SkScalar* ); michael@0: static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* script, int32_t* ); michael@0: static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* script, SkString* ); michael@0: static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable* parent, const char* script, SkString* ); michael@0: static bool MapEnums(const char* ptr, const char* match, size_t len, int* value); michael@0: protected: michael@0: static bool Box(void* user, SkScriptValue* ); michael@0: static bool Eval(const char* function, size_t len, SkTDArray& params, michael@0: void* callBack, SkScriptValue* ); michael@0: static bool EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* ); michael@0: static bool EvalID(const char* token, size_t len, void* callBack, SkScriptValue* ); michael@0: static bool EvalMember(const char* member, size_t len, void* object, void* eng, michael@0: SkScriptValue* value); michael@0: static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info, michael@0: SkDisplayable* displayable, SkScriptValue* value); michael@0: static bool EvalMemberFunction(const char* member, size_t len, void* object, michael@0: SkTDArray& params, void* user, SkScriptValue* value); michael@0: static bool EvalNamedColor(const char* token, size_t len, void* callBack, SkScriptValue* ); michael@0: static bool EvalRGB(const char* function, size_t len, SkTDArray& params, michael@0: void* callBack, SkScriptValue* ); michael@0: static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type); michael@0: static bool Infinity(const char* token, size_t len, void* callBack, SkScriptValue* ); michael@0: static bool IsFinite(const char* function, size_t len, SkTDArray& params, michael@0: void* callBack, SkScriptValue* ); michael@0: static bool IsNaN(const char* function, size_t len, SkTDArray& params, michael@0: void* callBack, SkScriptValue* ); michael@0: static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue* ); michael@0: static bool Unbox(void* , SkScriptValue* scriptValue); michael@0: SkTDDisplayableArray fTrackDisplayable; michael@0: SkAnimateMaker& fMaker; michael@0: SkDisplayable* fParent; michael@0: SkDisplayable* fWorking; michael@0: private: michael@0: friend class SkDump; michael@0: friend struct SkScriptNAnswer; michael@0: #ifdef SK_SUPPORT_UNITTEST michael@0: public: michael@0: static void UnitTest(); michael@0: #endif michael@0: }; michael@0: michael@0: #endif // SkAnimatorScript_DEFINED