OLD | NEW |
| (Empty) |
1 /* libs/graphics/animator/SkAnimatorScript.h | |
2 ** | |
3 ** Copyright 2006, The Android Open Source Project | |
4 ** | |
5 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
6 ** you may not use this file except in compliance with the License. | |
7 ** You may obtain a copy of the License at | |
8 ** | |
9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
10 ** | |
11 ** Unless required by applicable law or agreed to in writing, software | |
12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 ** See the License for the specific language governing permissions and | |
15 ** limitations under the License. | |
16 */ | |
17 | |
18 #ifndef SkAnimatorScript_DEFINED | |
19 #define SkAnimatorScript_DEFINED | |
20 | |
21 #include "SkDisplayable.h" | |
22 #include "SkScript.h" | |
23 #include "SkTypedArray.h" | |
24 | |
25 class SkAnimateMaker; | |
26 struct SkMemberInfo; | |
27 | |
28 struct SkDisplayEnumMap { | |
29 SkDisplayTypes fType; | |
30 const char* fValues; | |
31 }; | |
32 | |
33 class SkAnimatorScript : public SkScriptEngine { | |
34 public: | |
35 SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type); | |
36 ~SkAnimatorScript(); | |
37 bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type); | |
38 void track(SkDisplayable* displayable) { | |
39 SkASSERT(fTrackDisplayable.find(displayable) < 0); | |
40 *fTrackDisplayable.append() = displayable; } | |
41 static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const cha
r* script, SkDisplayable** ); | |
42 static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* scr
ipt, SkScalar* ); | |
43 static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* scrip
t, int32_t* ); | |
44 static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* sc
ript, SkString* ); | |
45 static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable*
parent, const char* script, SkString* ); | |
46 static bool MapEnums(const char* ptr, const char* match, size_t len, int* va
lue); | |
47 protected: | |
48 static bool Box(void* user, SkScriptValue* ); | |
49 static bool Eval(const char* function, size_t len, SkTDArray<SkScriptValue>&
params, | |
50 void* callBack, SkScriptValue* ); | |
51 static bool EvalEnum(const char* token, size_t len, void* callBack, SkScript
Value* ); | |
52 static bool EvalID(const char* token, size_t len, void* callBack, SkScriptVa
lue* ); | |
53 static bool EvalMember(const char* member, size_t len, void* object, void* e
ng, | |
54 SkScriptValue* value); | |
55 static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info, | |
56 SkDisplayable* displayable, SkScriptValue* value); | |
57 static bool EvalMemberFunction(const char* member, size_t len, void* object,
| |
58 SkTDArray<SkScriptValue>& params, void* user, SkScriptValue* value); | |
59 static bool EvalNamedColor(const char* token, size_t len, void* callBack, Sk
ScriptValue* ); | |
60 static bool EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValu
e>& params, | |
61 void* callBack, SkScriptValue* ); | |
62 static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type); | |
63 static bool Infinity(const char* token, size_t len, void* callBack, SkScript
Value* ); | |
64 static bool IsFinite(const char* function, size_t len, SkTDArray<SkScriptVal
ue>& params, | |
65 void* callBack, SkScriptValue* ); | |
66 static bool IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>
& params, | |
67 void* callBack, SkScriptValue* ); | |
68 static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue
* ); | |
69 static bool Unbox(void* , SkScriptValue* scriptValue); | |
70 SkTDDisplayableArray fTrackDisplayable; | |
71 SkAnimateMaker& fMaker; | |
72 SkDisplayable* fParent; | |
73 SkDisplayable* fWorking; | |
74 private: | |
75 friend class SkDump; | |
76 friend struct SkScriptNAnswer; | |
77 #ifdef SK_SUPPORT_UNITTEST | |
78 public: | |
79 static void UnitTest(); | |
80 #endif | |
81 }; | |
82 | |
83 #endif // SkAnimatorScript_DEFINED | |
84 | |
OLD | NEW |