1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/animator/SkAnimatorScript.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 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 +#ifndef SkAnimatorScript_DEFINED 1.14 +#define SkAnimatorScript_DEFINED 1.15 + 1.16 +#include "SkDisplayable.h" 1.17 +#include "SkScript.h" 1.18 +#include "SkTypedArray.h" 1.19 + 1.20 +class SkAnimateMaker; 1.21 +struct SkMemberInfo; 1.22 + 1.23 +struct SkDisplayEnumMap { 1.24 + SkDisplayTypes fType; 1.25 + const char* fValues; 1.26 +}; 1.27 + 1.28 +class SkAnimatorScript : public SkScriptEngine { 1.29 +public: 1.30 + SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type); 1.31 + ~SkAnimatorScript(); 1.32 + bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type); 1.33 + void track(SkDisplayable* displayable) { 1.34 + SkASSERT(fTrackDisplayable.find(displayable) < 0); 1.35 + *fTrackDisplayable.append() = displayable; } 1.36 + static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const char* script, SkDisplayable** ); 1.37 + static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* script, SkScalar* ); 1.38 + static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* script, int32_t* ); 1.39 + static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* script, SkString* ); 1.40 + static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable* parent, const char* script, SkString* ); 1.41 + static bool MapEnums(const char* ptr, const char* match, size_t len, int* value); 1.42 +protected: 1.43 + static bool Box(void* user, SkScriptValue* ); 1.44 + static bool Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 1.45 + void* callBack, SkScriptValue* ); 1.46 + static bool EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* ); 1.47 + static bool EvalID(const char* token, size_t len, void* callBack, SkScriptValue* ); 1.48 + static bool EvalMember(const char* member, size_t len, void* object, void* eng, 1.49 + SkScriptValue* value); 1.50 + static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info, 1.51 + SkDisplayable* displayable, SkScriptValue* value); 1.52 + static bool EvalMemberFunction(const char* member, size_t len, void* object, 1.53 + SkTDArray<SkScriptValue>& params, void* user, SkScriptValue* value); 1.54 + static bool EvalNamedColor(const char* token, size_t len, void* callBack, SkScriptValue* ); 1.55 + static bool EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 1.56 + void* callBack, SkScriptValue* ); 1.57 + static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type); 1.58 + static bool Infinity(const char* token, size_t len, void* callBack, SkScriptValue* ); 1.59 + static bool IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 1.60 + void* callBack, SkScriptValue* ); 1.61 + static bool IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 1.62 + void* callBack, SkScriptValue* ); 1.63 + static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue* ); 1.64 + static bool Unbox(void* , SkScriptValue* scriptValue); 1.65 + SkTDDisplayableArray fTrackDisplayable; 1.66 + SkAnimateMaker& fMaker; 1.67 + SkDisplayable* fParent; 1.68 + SkDisplayable* fWorking; 1.69 +private: 1.70 + friend class SkDump; 1.71 + friend struct SkScriptNAnswer; 1.72 +#ifdef SK_SUPPORT_UNITTEST 1.73 +public: 1.74 + static void UnitTest(); 1.75 +#endif 1.76 +}; 1.77 + 1.78 +#endif // SkAnimatorScript_DEFINED