1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkAnimatorScript_DEFINED 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkAnimatorScript_DEFINED 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDisplayable.h" 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScript.h" 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTypedArray.h" 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAnimateMaker; 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkMemberInfo; 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkDisplayEnumMap { 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDisplayTypes fType; 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const char* fValues; 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAnimatorScript : public SkScriptEngine { 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type); 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~SkAnimatorScript(); 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type); 30d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com void track(SkDisplayable* displayable) { 31d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com SkASSERT(fTrackDisplayable.find(displayable) < 0); 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *fTrackDisplayable.append() = displayable; } 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const char* script, SkDisplayable** ); 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* script, SkScalar* ); 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* script, int32_t* ); 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* script, SkString* ); 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable* parent, const char* script, SkString* ); 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool MapEnums(const char* ptr, const char* match, size_t len, int* value); 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected: 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool Box(void* user, SkScriptValue* ); 41d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void* callBack, SkScriptValue* ); 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* ); 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvalID(const char* token, size_t len, void* callBack, SkScriptValue* ); 45d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool EvalMember(const char* member, size_t len, void* object, void* eng, 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScriptValue* value); 47d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info, 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDisplayable* displayable, SkScriptValue* value); 49d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool EvalMemberFunction(const char* member, size_t len, void* object, 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkTDArray<SkScriptValue>& params, void* user, SkScriptValue* value); 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool EvalNamedColor(const char* token, size_t len, void* callBack, SkScriptValue* ); 52d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void* callBack, SkScriptValue* ); 54d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type); 558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool Infinity(const char* token, size_t len, void* callBack, SkScriptValue* ); 56d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void* callBack, SkScriptValue* ); 58d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com static bool IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void* callBack, SkScriptValue* ); 608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue* ); 618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static bool Unbox(void* , SkScriptValue* scriptValue); 628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkTDDisplayableArray fTrackDisplayable; 638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkAnimateMaker& fMaker; 648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDisplayable* fParent; 658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDisplayable* fWorking; 668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkDump; 688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend struct SkScriptNAnswer; 698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_SUPPORT_UNITTEST 708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com static void UnitTest(); 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif // SkAnimatorScript_DEFINED 76