aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkAnimatorScript.h
blob: 8589388e113e8ba8aa1ecc7e62e87f3305062163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#ifndef SkAnimatorScript_DEFINED
#define SkAnimatorScript_DEFINED

#include "SkDisplayable.h"
#include "SkScript.h"
#include "SkTypedArray.h"

class SkAnimateMaker;
struct SkMemberInfo;

struct SkDisplayEnumMap {
    SkDisplayTypes fType;
    const char* fValues;
};

class SkAnimatorScript : public SkScriptEngine {
public:
    SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type);
    ~SkAnimatorScript();
    bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type);
    void track(SkDisplayable* displayable) {
        SkASSERT(fTrackDisplayable.find(displayable) < 0);
        *fTrackDisplayable.append() = displayable; }
    static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const char* script, SkDisplayable** );
    static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* script, SkScalar* );
    static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* script, int32_t* );
    static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* script, SkString* );
    static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable* parent, const char* script, SkString* );
    static bool MapEnums(const char* ptr, const char* match, size_t len, int* value);
protected:
    static bool Box(void* user, SkScriptValue* );
    static bool Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* callBack, SkScriptValue* );
    static bool EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* );
    static bool EvalID(const char* token, size_t len, void* callBack, SkScriptValue* );
    static bool EvalMember(const char* member, size_t len, void* object, void* eng,
        SkScriptValue* value);
    static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info,
        SkDisplayable* displayable, SkScriptValue* value);
    static bool EvalMemberFunction(const char* member, size_t len, void* object,
        SkTDArray<SkScriptValue>& params, void* user, SkScriptValue* value);
    static bool EvalNamedColor(const char* token, size_t len, void* callBack, SkScriptValue* );
    static bool EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* callBack, SkScriptValue* );
    static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type);
    static bool Infinity(const char* token, size_t len, void* callBack, SkScriptValue* );
    static bool IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* callBack, SkScriptValue* );
    static bool IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params,
        void* callBack, SkScriptValue* );
    static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue* );
    static bool Unbox(void* , SkScriptValue* scriptValue);
    SkTDDisplayableArray fTrackDisplayable;
    SkAnimateMaker& fMaker;
    SkDisplayable* fParent;
    SkDisplayable* fWorking;
private:
    friend class SkDump;
    friend struct SkScriptNAnswer;
#ifdef SK_SUPPORT_UNITTEST
public:
    static void UnitTest();
#endif
};

#endif // SkAnimatorScript_DEFINED