aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkDisplayType.h
blob: 474a65e8e6001b0eb10bee80e7e088b3d0b5ab91 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

/*
 * 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 SkDisplayType_DEFINED
#define SkDisplayType_DEFINED

#include "SkMath.h"
#include "SkScalar.h"

#ifdef SK_DEBUG
    #define SK_DUMP_ENABLED
    #ifdef SK_BUILD_FOR_MAC
        #define SK_FIND_LEAKS
    #endif
#endif

#define SK_LITERAL_STR_EQUAL(str, token, len) (sizeof(str) - 1 == len \
    && strncmp(str, token, sizeof(str) - 1) == 0)

class SkAnimateMaker;
class SkDisplayable;
struct SkMemberInfo;

enum SkDisplayTypes {
    SkType_Unknown,
    SkType_Math, // for ecmascript compatible Math functions and constants
    SkType_Number,  // for for ecmascript compatible Number functions and constants
    SkType_Add,
    SkType_AddCircle,
    SkType_AddGeom,
    SkType_AddMode,
    SkType_AddOval,
    SkType_AddPath,
    SkType_AddRect, // path part
    SkType_AddRoundRect,
    SkType_Align,
    SkType_Animate,
    SkType_AnimateBase, // base type for animate, set
    SkType_Apply,
    SkType_ApplyMode,
    SkType_ApplyTransition,
    SkType_Array,
    SkType_ARGB,
    SkType_Base64,
    SkType_BaseBitmap,
    SkType_BaseClassInfo,
    SkType_Bitmap,
    SkType_BitmapEncoding,
    SkType_BitmapFormat,
    SkType_BitmapShader,
    SkType_Blur,
    SkType_Boolean, // can have values -1 (uninitialized), 0, 1
    SkType_Boundable,
    SkType_Bounds,
    SkType_Cap,
    SkType_Clear,
    SkType_Clip,
    SkType_Close,
    SkType_Color,
    SkType_CubicTo,
    SkType_Dash,
    SkType_DataInput,
    SkType_Discrete,
    SkType_Displayable,
    SkType_Drawable,
    SkType_DrawTo,
    SkType_Dump,
    SkType_DynamicString,   // evaluate at draw time
    SkType_Emboss,
    SkType_Event,
    SkType_EventCode,
    SkType_EventKind,
    SkType_EventMode,
    SkType_FillType,
    SkType_FilterType,
    SkType_Float,
    SkType_FontStyle,
    SkType_FromPath,
    SkType_FromPathMode,
    SkType_Full,
    SkType_DrawGradient,
    SkType_Group,
    SkType_HitClear,
    SkType_HitTest,
    SkType_ImageBaseBitmap,
    SkType_Include,
    SkType_Input,
    SkType_Int,
    SkType_Join,
    SkType_Line, // simple line primitive
    SkType_LineTo, // used as part of path construction
    SkType_DrawLinearGradient,
    SkType_MaskFilter,
    SkType_MaskFilterBlurStyle,
    SkType_MaskFilterLight,
    SkType_Matrix,
    SkType_MemberFunction,
    SkType_MemberProperty,
    SkType_Move,
    SkType_MoveTo,
    SkType_Movie,
    SkType_MSec,
    SkType_Oval,
    SkType_Paint,
    SkType_Path,
    SkType_PathDirection,
    SkType_PathEffect,
    SkType_Point,   // used inside other structures, no vtable
    SkType_DrawPoint, // used to draw points, has a vtable
    SkType_PolyToPoly,
    SkType_Polygon,
    SkType_Polyline,
    SkType_Post,
    SkType_QuadTo,
    SkType_RCubicTo,
    SkType_RLineTo,
    SkType_RMoveTo,
    SkType_RQuadTo,
    SkType_DrawRadialGradient,
    SkType_Random,
    SkType_Rect,
    SkType_RectToRect,
    SkType_Remove,
    SkType_Replace,
    SkType_Rotate,
    SkType_RoundRect,
    SkType_Save,
    SkType_SaveLayer,
    SkType_Scale,
    SkType_Screenplay,
    SkType_Set,
    SkType_Shader,
    SkType_Skew,
    SkType_3D_Camera,
    SkType_3D_Patch,
    SkType_3D_Point,
    SkType_Snapshot,
    SkType_String,  // pointer to SkString
    SkType_Style,
    SkType_Text,
    SkType_TextBox,
    SkType_TextBoxAlign,
    SkType_TextBoxMode,
    SkType_TextOnPath,
    SkType_TextToPath,
    SkType_TileMode,
    SkType_Translate,
    SkType_TransparentShader,
    SkType_Typeface,
    SkType_Xfermode,
    kNumberOfTypes
};

struct TypeNames {
    const char* fName;
    SkDisplayTypes fType;
#if defined SK_DEBUG || defined SK_BUILD_CONDENSED
    bool fDrawPrefix;
    bool fDisplayPrefix;
#endif
};

#ifdef SK_DEBUG
typedef SkDisplayTypes SkFunctionParamType;
#else
typedef unsigned char SkFunctionParamType;
#endif

extern const TypeNames gTypeNames[];
extern const int kTypeNamesSize;

class SkDisplayType {
public:
    static SkDisplayTypes Find(SkAnimateMaker* , const SkMemberInfo* );
    static const SkMemberInfo* GetMember(SkAnimateMaker* , SkDisplayTypes , const char** );
    static const SkMemberInfo* GetMembers(SkAnimateMaker* , SkDisplayTypes , int* infoCountPtr);
    static SkDisplayTypes GetParent(SkAnimateMaker* , SkDisplayTypes );
    static bool IsDisplayable(SkAnimateMaker* , SkDisplayTypes );
    static bool IsEnum(SkAnimateMaker* , SkDisplayTypes );
    static bool IsStruct(SkAnimateMaker* , SkDisplayTypes );
    static SkDisplayTypes RegisterNewType();
    static SkDisplayTypes Resolve(const char[] , const SkMemberInfo** );
#ifdef SK_DEBUG
    static bool IsAnimate(SkDisplayTypes type ) { return type == SkType_Animate ||
        type == SkType_Set; }
    static const char* GetName(SkAnimateMaker* , SkDisplayTypes );
#endif
#ifdef SK_SUPPORT_UNITTEST
    static void UnitTest();
#endif
#if defined SK_DEBUG || defined SK_BUILD_CONDENSED
    static void BuildCondensedInfo(SkAnimateMaker* );
#endif
    static SkDisplayTypes GetType(SkAnimateMaker* , const char[] , size_t len);
    static SkDisplayable* CreateInstance(SkAnimateMaker* , SkDisplayTypes );
private:
    static SkDisplayTypes gNewTypes;
};

#endif // SkDisplayType_DEFINED