00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SkPostConfig_DEFINED
00018 #define SkPostConfig_DEFINED
00019
00020 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE)
00021 #define SK_BUILD_FOR_WIN
00022 #endif
00023
00024 #if defined(SK_DEBUG) && defined(SK_RELEASE)
00025 #error "cannot define both SK_DEBUG and SK_RELEASE"
00026 #elif !defined(SK_DEBUG) && !defined(SK_RELEASE)
00027 #error "must define either SK_DEBUG or SK_RELEASE"
00028 #endif
00029
00030 #if defined SK_SUPPORT_UNITTEST && !defined(SK_DEBUG)
00031 #error "can't have unittests without debug"
00032 #endif
00033
00034 #if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT)
00035 #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
00036 #elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT)
00037 #ifdef SK_CAN_USE_FLOAT
00038 #define SK_SCALAR_IS_FLOAT
00039 #else
00040 #define SK_SCALAR_IS_FIXED
00041 #endif
00042 #endif
00043
00044 #if defined(SK_SCALAR_IS_FLOAT) && !defined(SK_CAN_USE_FLOAT)
00045 #define SK_CAN_USE_FLOAT
00046
00047 #endif
00048
00049 #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
00050 #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
00051 #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
00052 #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
00053 #endif
00054
00055
00056 #ifdef SK_A32_SHIFT
00057 #if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT)
00058 #error "all or none of the 32bit SHIFT amounts must be defined"
00059 #endif
00060 #else
00061 #if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT)
00062 #error "all or none of the 32bit SHIFT amounts must be defined"
00063 #endif
00064 #endif
00065
00067
00068 #ifndef SkNEW
00069 #define SkNEW(type_name) new type_name
00070 #define SkNEW_ARGS(type_name, args) new type_name args
00071 #define SkNEW_ARRAY(type_name, count) new type_name[count]
00072 #define SkDELETE(obj) delete obj
00073 #define SkDELETE_ARRAY(array) delete[] array
00074 #endif
00075
00076 #ifndef SK_CRASH
00077 #if 1 // set to 0 for infinite loop, which can help connecting gdb
00078 #define SK_CRASH() *(int *)(uintptr_t)0xbbadbeef = 0
00079 #else
00080 #define SK_CRASH() do {} while (true)
00081 #endif
00082 #endif
00083
00085
00086 #if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT)
00087
00088 #ifndef SK_SCALAR_SLOW_COMPARES
00089 #define SK_SCALAR_SLOW_COMPARES
00090 #endif
00091 #ifndef SK_USE_FLOATBITS
00092 #define SK_USE_FLOATBITS
00093 #endif
00094 #endif
00095
00096 #ifdef SK_BUILD_FOR_WIN
00097
00098 #ifndef WIN32_LEAN_AND_MEAN
00099 #define WIN32_LEAN_AND_MEAN
00100 #define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
00101 #endif
00102
00103 #include <windows.h>
00104
00105 #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
00106 #undef WIN32_LEAN_AND_MEAN
00107 #endif
00108
00109 #ifndef SK_DEBUGBREAK
00110 #define SK_DEBUGBREAK(cond) do { if (!(cond)) DebugBreak(); } while (false)
00111 #endif
00112 #elif defined(SK_BUILD_FOR_MAC)
00113 #ifndef SK_DEBUGBREAK
00114 #define SK_DEBUGBREAK(cond) do { if (!(cond)) SK_CRASH(); } while (false)
00115 #endif
00116 #else
00117 #ifdef SK_DEBUG
00118 #include <stdio.h>
00119 #ifndef SK_DEBUGBREAK
00120 #define SK_DEBUGBREAK(cond) do { if (cond) break; \
00121 SkDebugf("%s:%d: failed assertion \"%s\"\n", \
00122 __FILE__, __LINE__, #cond); SK_CRASH(); } while (false)
00123 #endif
00124 #endif
00125 #endif
00126
00127
00128
00129 #if 0
00130 #if !defined(strlen) && defined(SK_DEBUG)
00131 extern size_t sk_strlen(const char*);
00132 #define strlen(s) sk_strlen(s)
00133 #endif
00134 #ifndef sk_strcpy
00135 #define sk_strcpy(dst, src) strcpy(dst, src)
00136 #endif
00137 #ifndef sk_strchr
00138 #define sk_strchr(s, c) strchr(s, c)
00139 #endif
00140 #ifndef sk_strrchr
00141 #define sk_strrchr(s, c) strrchr(s, c)
00142 #endif
00143 #ifndef sk_strcmp
00144 #define sk_strcmp(s, t) strcmp(s, t)
00145 #endif
00146 #ifndef sk_strncmp
00147 #define sk_strncmp(s, t, n) strncmp(s, t, n)
00148 #endif
00149 #ifndef sk_memcpy
00150 #define sk_memcpy(dst, src, n) memcpy(dst, src, n)
00151 #endif
00152 #ifndef memmove
00153 #define memmove(dst, src, n) memmove(dst, src, n)
00154 #endif
00155 #ifndef sk_memset
00156 #define sk_memset(dst, val, n) memset(dst, val, n)
00157 #endif
00158 #ifndef sk_memcmp
00159 #define sk_memcmp(s, t, n) memcmp(s, t, n)
00160 #endif
00161
00162 #define sk_strequal(s, t) (!sk_strcmp(s, t))
00163 #define sk_strnequal(s, t, n) (!sk_strncmp(s, t, n))
00164 #endif
00165
00167
00168 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC)
00169 #ifndef SkLONGLONG
00170 #ifdef SK_BUILD_FOR_WIN32
00171 #define SkLONGLONG __int64
00172 #else
00173 #define SkLONGLONG long long
00174 #endif
00175 #endif
00176 #endif
00177
00179 #ifndef SK_BUILD_FOR_WINCE
00180 #include <string.h>
00181 #include <stdlib.h>
00182 #else
00183 #define _CMNINTRIN_DECLARE_ONLY
00184 #include "cmnintrin.h"
00185 #endif
00186
00187 #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32
00188
00189 #ifdef free
00190 #undef free
00191 #endif
00192 #include <crtdbg.h>
00193 #undef free
00194
00195 #ifdef SK_DEBUGx
00196 #if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
00197 void * operator new(
00198 size_t cb,
00199 int nBlockUse,
00200 const char * szFileName,
00201 int nLine,
00202 int foo
00203 );
00204 void * operator new[](
00205 size_t cb,
00206 int nBlockUse,
00207 const char * szFileName,
00208 int nLine,
00209 int foo
00210 );
00211 void operator delete(
00212 void *pUserData,
00213 int, const char*, int, int
00214 );
00215 void operator delete(
00216 void *pUserData
00217 );
00218 void operator delete[]( void * p );
00219 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
00220 #else
00221 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
00222 #endif
00223 #define new DEBUG_CLIENTBLOCK
00224 #else
00225 #define DEBUG_CLIENTBLOCK
00226 #endif // _DEBUG
00227
00228 #endif
00229
00230 #endif
00231