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