• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libs/graphics/animator/SkDisplayType.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 SkDisplayType_DEFINED
19 #define SkDisplayType_DEFINED
20 
21 #include "SkMath.h"
22 #include "SkScalar.h"
23 
24 #ifdef SK_DEBUG
25     #ifdef SK_CAN_USE_FLOAT
26         #define SK_DUMP_ENABLED
27     #endif
28     #ifdef SK_BUILD_FOR_MAC
29         #define SK_FIND_LEAKS
30     #endif
31 #endif
32 
33 #define SK_LITERAL_STR_EQUAL(str, token, len) (sizeof(str) - 1 == len \
34     && strncmp(str, token, sizeof(str) - 1) == 0)
35 
36 class SkAnimateMaker;
37 class SkDisplayable;
38 struct SkMemberInfo;
39 
40 enum SkDisplayTypes {
41     SkType_Unknown,
42     SkType_Math, // for ecmascript compatible Math functions and constants
43     SkType_Number,  // for for ecmascript compatible Number functions and constants
44     SkType_Add,
45     SkType_AddCircle,
46     SkType_AddGeom,
47     SkType_AddMode,
48     SkType_AddOval,
49     SkType_AddPath,
50     SkType_AddRect, // path part
51     SkType_AddRoundRect,
52     SkType_Align,
53     SkType_Animate,
54     SkType_AnimateBase, // base type for animate, set
55     SkType_Apply,
56     SkType_ApplyMode,
57     SkType_ApplyTransition,
58     SkType_Array,
59     SkType_ARGB,
60     SkType_Base64,
61     SkType_BaseBitmap,
62     SkType_BaseClassInfo,
63     SkType_Bitmap,
64     SkType_BitmapEncoding,
65     SkType_BitmapFormat,
66     SkType_BitmapShader,
67     SkType_Blur,
68     SkType_Boolean, // can have values -1 (uninitialized), 0, 1
69     SkType_Boundable,
70     SkType_Bounds,
71     SkType_Cap,
72     SkType_Clear,
73     SkType_Clip,
74     SkType_Close,
75     SkType_Color,
76     SkType_CubicTo,
77     SkType_Dash,
78     SkType_Data,
79     SkType_Discrete,
80     SkType_Displayable,
81     SkType_Drawable,
82     SkType_DrawTo,
83     SkType_Dump,
84     SkType_DynamicString,   // evaluate at draw time
85     SkType_Emboss,
86     SkType_Event,
87     SkType_EventCode,
88     SkType_EventKind,
89     SkType_EventMode,
90     SkType_FillType,
91     SkType_FilterType,
92     SkType_Float,
93     SkType_FontStyle,
94     SkType_FromPath,
95     SkType_FromPathMode,
96     SkType_Full,
97     SkType_Gradient,
98     SkType_Group,
99     SkType_HitClear,
100     SkType_HitTest,
101     SkType_Image,
102     SkType_Include,
103     SkType_Input,
104     SkType_Int,
105     SkType_Join,
106     SkType_Line, // simple line primitive
107     SkType_LineTo, // used as part of path construction
108     SkType_LinearGradient,
109     SkType_MaskFilter,
110     SkType_MaskFilterBlurStyle,
111     SkType_MaskFilterLight,
112     SkType_Matrix,
113     SkType_MemberFunction,
114     SkType_MemberProperty,
115     SkType_Move,
116     SkType_MoveTo,
117     SkType_Movie,
118     SkType_MSec,
119     SkType_Oval,
120     SkType_Paint,
121     SkType_Path,
122     SkType_PathDirection,
123     SkType_PathEffect,
124     SkType_Point,   // used inside other structures, no vtable
125     SkType_DrawPoint, // used to draw points, has a vtable
126     SkType_PolyToPoly,
127     SkType_Polygon,
128     SkType_Polyline,
129     SkType_Post,
130     SkType_QuadTo,
131     SkType_RCubicTo,
132     SkType_RLineTo,
133     SkType_RMoveTo,
134     SkType_RQuadTo,
135     SkType_RadialGradient,
136     SkType_Random,
137     SkType_Rect,
138     SkType_RectToRect,
139     SkType_Remove,
140     SkType_Replace,
141     SkType_Rotate,
142     SkType_RoundRect,
143     SkType_Save,
144     SkType_SaveLayer,
145     SkType_Scale,
146     SkType_Screenplay,
147     SkType_Set,
148     SkType_Shader,
149     SkType_Skew,
150     SkType_3D_Camera,
151     SkType_3D_Patch,
152     SkType_3D_Point,
153     SkType_Snapshot,
154     SkType_String,  // pointer to SkString
155     SkType_Style,
156     SkType_Text,
157     SkType_TextBox,
158     SkType_TextBoxAlign,
159     SkType_TextBoxMode,
160     SkType_TextOnPath,
161     SkType_TextToPath,
162     SkType_TileMode,
163     SkType_Translate,
164     SkType_TransparentShader,
165     SkType_Typeface,
166     SkType_Xfermode,
167     kNumberOfTypes
168 };
169 
170 struct TypeNames {
171     const char* fName;
172     SkDisplayTypes fType;
173 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
174     bool fDrawPrefix;
175     bool fDisplayPrefix;
176 #endif
177 };
178 
179 #ifdef SK_DEBUG
180 typedef SkDisplayTypes SkFunctionParamType;
181 #else
182 typedef unsigned char SkFunctionParamType;
183 #endif
184 
185 extern const TypeNames gTypeNames[];
186 extern const int kTypeNamesSize;
187 
188 class SkDisplayType {
189 public:
190     static SkDisplayTypes Find(SkAnimateMaker* , const SkMemberInfo* );
191     static const SkMemberInfo* GetMember(SkAnimateMaker* , SkDisplayTypes , const char** );
192     static const SkMemberInfo* GetMembers(SkAnimateMaker* , SkDisplayTypes , int* infoCountPtr);
193     static SkDisplayTypes GetParent(SkAnimateMaker* , SkDisplayTypes );
194     static bool IsDisplayable(SkAnimateMaker* , SkDisplayTypes );
195     static bool IsEnum(SkAnimateMaker* , SkDisplayTypes );
196     static bool IsStruct(SkAnimateMaker* , SkDisplayTypes );
197     static SkDisplayTypes RegisterNewType();
198     static SkDisplayTypes Resolve(const char[] , const SkMemberInfo** );
199 #ifdef SK_DEBUG
IsAnimate(SkDisplayTypes type)200     static bool IsAnimate(SkDisplayTypes type ) { return type == SkType_Animate ||
201         type == SkType_Set; }
202     static const char* GetName(SkAnimateMaker* , SkDisplayTypes );
203 #endif
204 #ifdef SK_SUPPORT_UNITTEST
205     static void UnitTest();
206 #endif
207 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
208     static void BuildCondensedInfo(SkAnimateMaker* );
209 #endif
210     static SkDisplayTypes GetType(SkAnimateMaker* , const char[] , size_t len);
211     static SkDisplayable* CreateInstance(SkAnimateMaker* , SkDisplayTypes );
212 private:
213     static SkDisplayTypes gNewTypes;
214 };
215 
216 #endif // SkDisplayType_DEFINED
217