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