| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 4 * | 3 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 | |
| 10 #ifndef SkPostConfig_DEFINED | 8 #ifndef SkPostConfig_DEFINED |
| 11 #define SkPostConfig_DEFINED | 9 #define SkPostConfig_DEFINED |
| 12 | 10 |
| 13 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE) | 11 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE) |
| 14 #define SK_BUILD_FOR_WIN | 12 # define SK_BUILD_FOR_WIN |
| 15 #endif | 13 #endif |
| 16 | 14 |
| 17 #if defined(SK_DEBUG) && defined(SK_RELEASE) | 15 #if defined(SK_DEBUG) && defined(SK_RELEASE) |
| 18 #error "cannot define both SK_DEBUG and SK_RELEASE" | 16 # error "cannot define both SK_DEBUG and SK_RELEASE" |
| 19 #elif !defined(SK_DEBUG) && !defined(SK_RELEASE) | 17 #elif !defined(SK_DEBUG) && !defined(SK_RELEASE) |
| 20 #error "must define either SK_DEBUG or SK_RELEASE" | 18 # error "must define either SK_DEBUG or SK_RELEASE" |
| 21 #endif | 19 #endif |
| 22 | 20 |
| 23 #if defined SK_SUPPORT_UNITTEST && !defined(SK_DEBUG) | 21 #if defined(SK_SUPPORT_UNITTEST) && !defined(SK_DEBUG) |
| 24 #error "can't have unittests without debug" | 22 # error "can't have unittests without debug" |
| 25 #endif | 23 #endif |
| 26 | 24 |
| 27 #if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT) | 25 #if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT) |
| 28 #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT" | 26 # error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT" |
| 29 #elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT) | 27 #elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT) |
| 30 #define SK_SCALAR_IS_FLOAT | 28 # define SK_SCALAR_IS_FLOAT |
| 31 #endif | 29 #endif |
| 32 | 30 |
| 31 /** |
| 32 * Matrix calculations may be float or double. |
| 33 * The default is double, as that is faster given our impl uses doubles |
| 34 * for intermediate calculations. |
| 35 */ |
| 33 #if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT) | 36 #if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT) |
| 34 #error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT" | 37 # error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT" |
| 35 #elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT) | 38 #elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT) |
| 36 // default is double, as that is faster given our impl uses doubles | 39 # define SK_MSCALAR_IS_DOUBLE |
| 37 // for intermediate calculations. | |
| 38 #define SK_MSCALAR_IS_DOUBLE | |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN) | 42 #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN) |
| 42 #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN" | 43 # error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN" |
| 43 #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) | 44 #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) |
| 44 #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN" | 45 # error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN" |
| 45 #endif | 46 #endif |
| 46 | 47 |
| 47 // ensure the port has defined all of these, or none of them | 48 /** |
| 49 * Ensure the port has defined all of SK_X32_SHIFT, or none of them. |
| 50 */ |
| 48 #ifdef SK_A32_SHIFT | 51 #ifdef SK_A32_SHIFT |
| 49 #if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIF
T) | 52 # if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT) |
| 50 #error "all or none of the 32bit SHIFT amounts must be defined" | 53 # error "all or none of the 32bit SHIFT amounts must be defined" |
| 51 #endif | 54 # endif |
| 52 #else | 55 #else |
| 53 #if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT) | 56 # if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT) |
| 54 #error "all or none of the 32bit SHIFT amounts must be defined" | 57 # error "all or none of the 32bit SHIFT amounts must be defined" |
| 55 #endif | 58 # endif |
| 56 #endif | 59 #endif |
| 57 | 60 |
| 58 #if !defined(SK_HAS_COMPILER_FEATURE) | 61 #if !defined(SK_HAS_COMPILER_FEATURE) |
| 59 #if defined(__has_feature) | 62 # if defined(__has_feature) |
| 60 #define SK_HAS_COMPILER_FEATURE(x) __has_feature(x) | 63 # define SK_HAS_COMPILER_FEATURE(x) __has_feature(x) |
| 61 #else | 64 # else |
| 62 #define SK_HAS_COMPILER_FEATURE(x) 0 | 65 # define SK_HAS_COMPILER_FEATURE(x) 0 |
| 63 #endif | 66 # endif |
| 64 #endif | 67 #endif |
| 65 | 68 |
| 66 #if !defined(SK_ATTRIBUTE) | 69 #if !defined(SK_ATTRIBUTE) |
| 67 #if defined(__clang__) || defined(__GNUC__) | 70 # if defined(__clang__) || defined(__GNUC__) |
| 68 #define SK_ATTRIBUTE(attr) __attribute__((attr)) | 71 # define SK_ATTRIBUTE(attr) __attribute__((attr)) |
| 69 #else | 72 # else |
| 70 #define SK_ATTRIBUTE(attr) | 73 # define SK_ATTRIBUTE(attr) |
| 71 #endif | 74 # endif |
| 72 #endif | 75 #endif |
| 73 | 76 |
| 74 #if !defined(SK_SUPPORT_GPU) | 77 #if !defined(SK_SUPPORT_GPU) |
| 75 #define SK_SUPPORT_GPU 1 | 78 # define SK_SUPPORT_GPU 1 |
| 76 #endif | 79 #endif |
| 77 | 80 |
| 78 /** | 81 /** |
| 79 * The clang static analyzer likes to know that when the program is not | 82 * The clang static analyzer likes to know that when the program is not |
| 80 * expected to continue (crash, assertion failure, etc). It will notice that | 83 * expected to continue (crash, assertion failure, etc). It will notice that |
| 81 * some combination of parameters lead to a function call that does not return. | 84 * some combination of parameters lead to a function call that does not return. |
| 82 * It can then make appropriate assumptions about the parameters in code | 85 * It can then make appropriate assumptions about the parameters in code |
| 83 * executed only if the non-returning function was *not* called. | 86 * executed only if the non-returning function was *not* called. |
| 84 */ | 87 */ |
| 85 #if !defined(SkNO_RETURN_HINT) | 88 #if !defined(SkNO_RETURN_HINT) |
| 86 #if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn) | 89 # if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn) |
| 87 static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn))
; | 90 static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn)); |
| 88 static inline void SkNO_RETURN_HINT() {} | 91 static inline void SkNO_RETURN_HINT() {} |
| 89 #else | 92 # else |
| 90 #define SkNO_RETURN_HINT() do {} while (false) | 93 # define SkNO_RETURN_HINT() do {} while (false) |
| 91 #endif | 94 # endif |
| 92 #endif | 95 #endif |
| 93 | 96 |
| 94 #if defined(SK_ZLIB_INCLUDE) && defined(SK_SYSTEM_ZLIB) | 97 #if defined(SK_ZLIB_INCLUDE) && defined(SK_SYSTEM_ZLIB) |
| 95 #error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB" | 98 # error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB" |
| 96 #elif defined(SK_ZLIB_INCLUDE) || defined(SK_SYSTEM_ZLIB) | 99 #elif defined(SK_ZLIB_INCLUDE) || defined(SK_SYSTEM_ZLIB) |
| 97 #define SK_HAS_ZLIB | 100 # define SK_HAS_ZLIB |
| 98 #endif | 101 #endif |
| 99 | 102 |
| 100 /////////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////////// |
| 101 | 104 |
| 102 #ifndef SkNEW | 105 #ifndef SkNEW |
| 103 #define SkNEW(type_name) (new type_name) | 106 # define SkNEW(type_name) (new type_name) |
| 104 #define SkNEW_ARGS(type_name, args) (new type_name args) | 107 # define SkNEW_ARGS(type_name, args) (new type_name args) |
| 105 #define SkNEW_ARRAY(type_name, count) (new type_name[(count)]) | 108 # define SkNEW_ARRAY(type_name, count) (new type_name[(count)]) |
| 106 #define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name) | 109 # define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name) |
| 107 #define SkNEW_PLACEMENT_ARGS(buf, type_name, args) \ | 110 # define SkNEW_PLACEMENT_ARGS(buf, type_name, args) (new (buf) type_name args) |
| 108 (new (buf) type_name args) | 111 # define SkDELETE(obj) (delete (obj)) |
| 109 #define SkDELETE(obj) (delete (obj)) | 112 # define SkDELETE_ARRAY(array) (delete[] (array)) |
| 110 #define SkDELETE_ARRAY(array) (delete[] (array)) | |
| 111 #endif | 113 #endif |
| 112 | 114 |
| 113 #ifndef SK_CRASH | 115 #ifndef SK_CRASH |
| 114 #if 1 // set to 0 for infinite loop, which can help connecting gdb | 116 # if 1 // set to 0 for infinite loop, which can help connecting gdb |
| 115 #define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef =
0; } while (false) | 117 # define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef =
0; } while (false) |
| 116 #else | 118 # else |
| 117 #define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true) | 119 # define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true) |
| 118 #endif | 120 # endif |
| 119 #endif | 121 #endif |
| 120 | 122 |
| 121 /////////////////////////////////////////////////////////////////////////////// | 123 /////////////////////////////////////////////////////////////////////////////// |
| 122 | 124 |
| 123 // SK_ENABLE_INST_COUNT defaults to 1 in DEBUG and 0 in RELEASE | 125 /** |
| 126 * SK_ENABLE_INST_COUNT controlls printing how many reference counted objects |
| 127 * are still held on exit. |
| 128 * Defaults to 1 in DEBUG and 0 in RELEASE. |
| 129 * FIXME: currently always 0, since it fails if multiple threads run at once |
| 130 * (see skbug.com/1219 ). |
| 131 */ |
| 124 #ifndef SK_ENABLE_INST_COUNT | 132 #ifndef SK_ENABLE_INST_COUNT |
| 125 #ifdef SK_DEBUG | 133 # ifdef SK_DEBUG |
| 126 // FIXME: fails if multiple threads run at once (see skbug.com/1219 ) | 134 # define SK_ENABLE_INST_COUNT 0 |
| 127 #define SK_ENABLE_INST_COUNT 0 | 135 # else |
| 128 #else | 136 # define SK_ENABLE_INST_COUNT 0 |
| 129 #define SK_ENABLE_INST_COUNT 0 | 137 # endif |
| 130 #endif | |
| 131 #endif | 138 #endif |
| 132 | 139 |
| 133 /////////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////////// |
| 134 | 141 |
| 135 #if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT) | 142 #if defined(SK_SOFTWARE_FLOAT) && defined(SK_SCALAR_IS_FLOAT) |
| 136 // if this is defined, we convert floats to 2scompliment ints for compares | 143 // if this is defined, we convert floats to 2s compliment ints for compares. |
| 137 #ifndef SK_SCALAR_SLOW_COMPARES | 144 # ifndef SK_SCALAR_SLOW_COMPARES |
| 138 #define SK_SCALAR_SLOW_COMPARES | 145 # define SK_SCALAR_SLOW_COMPARES |
| 139 #endif | 146 # endif |
| 140 #ifndef SK_USE_FLOATBITS | 147 # ifndef SK_USE_FLOATBITS |
| 141 #define SK_USE_FLOATBITS | 148 # define SK_USE_FLOATBITS |
| 142 #endif | 149 # endif |
| 143 #endif | 150 #endif |
| 144 | 151 |
| 145 #ifdef SK_BUILD_FOR_WIN | 152 #ifdef SK_BUILD_FOR_WIN |
| 146 // we want lean_and_mean when we include windows.h | 153 # ifndef WIN32_LEAN_AND_MEAN |
| 147 #ifndef WIN32_LEAN_AND_MEAN | 154 # define WIN32_LEAN_AND_MEAN |
| 148 #define WIN32_LEAN_AND_MEAN | 155 # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 149 #define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED | 156 # endif |
| 150 #endif | 157 # ifndef NOMINMAX |
| 151 #ifndef NOMINMAX | 158 # define NOMINMAX |
| 152 #define NOMINMAX | 159 # define NOMINMAX_WAS_LOCALLY_DEFINED |
| 153 #define NOMINMAX_WAS_LOCALLY_DEFINED | 160 # endif |
| 154 #endif | 161 # |
| 155 | 162 # include <windows.h> |
| 156 #include <windows.h> | 163 # |
| 157 | 164 # ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 158 #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED | 165 # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 159 #undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED | 166 # undef WIN32_LEAN_AND_MEAN |
| 160 #undef WIN32_LEAN_AND_MEAN | 167 # endif |
| 161 #endif | 168 # ifdef NOMINMAX_WAS_LOCALLY_DEFINED |
| 162 | 169 # undef NOMINMAX_WAS_LOCALLY_DEFINED |
| 163 #ifdef NOMINMAX_WAS_LOCALLY_DEFINED | 170 # undef NOMINMAX |
| 164 #undef NOMINMAX_WAS_LOCALLY_DEFINED | 171 # endif |
| 165 #undef NOMINMAX | 172 # |
| 166 #endif | 173 # ifndef SK_DEBUGBREAK |
| 167 | 174 # define SK_DEBUGBREAK(p) do { if (!(p)) { SkNO_RETURN_HINT(); __debugbreak()
; }} while (false) |
| 168 #ifndef SK_DEBUGBREAK | 175 # endif |
| 169 #define SK_DEBUGBREAK(cond) do { if (!(cond)) { SkNO_RETURN_HINT();
__debugbreak(); }} while (false) | 176 # |
| 170 #endif | 177 # ifndef SK_A32_SHIFT |
| 171 | 178 # define SK_A32_SHIFT 24 |
| 172 #ifndef SK_A32_SHIFT | 179 # define SK_R32_SHIFT 16 |
| 173 #define SK_A32_SHIFT 24 | 180 # define SK_G32_SHIFT 8 |
| 174 #define SK_R32_SHIFT 16 | 181 # define SK_B32_SHIFT 0 |
| 175 #define SK_G32_SHIFT 8 | 182 # endif |
| 176 #define SK_B32_SHIFT 0 | 183 # |
| 177 #endif | |
| 178 | |
| 179 #else | 184 #else |
| 180 #ifdef SK_DEBUG | 185 # ifdef SK_DEBUG |
| 181 #include <stdio.h> | 186 # include <stdio.h> |
| 182 #ifndef SK_DEBUGBREAK | 187 # ifndef SK_DEBUGBREAK |
| 183 #define SK_DEBUGBREAK(cond) do { if (cond) break; \ | 188 # define SK_DEBUGBREAK(cond) do { if (cond) break; \ |
| 184 SkDebugf("%s:%d: failed assertion \"%s\"\n", \ | 189 SkDebugf("%s:%d: failed assertion \"%s\"\n", \ |
| 185 __FILE__, __LINE__, #cond); SK_CRASH(); } while (false) | 190 __FILE__, __LINE__, #cond); SK_CRASH(); } while (false) |
| 186 #endif | 191 # endif |
| 187 #endif | 192 # endif |
| 188 #endif | 193 #endif |
| 189 | 194 |
| 190 /* | 195 /** |
| 191 * We check to see if the SHIFT value has already been defined. | 196 * We check to see if the SHIFT value has already been defined. |
| 192 * if not, we define it ourself to some default values. We default to OpenGL | 197 * if not, we define it ourself to some default values. We default to OpenGL |
| 193 * order (in memory: r,g,b,a) | 198 * order (in memory: r,g,b,a) |
| 194 */ | 199 */ |
| 195 #ifndef SK_A32_SHIFT | 200 #ifndef SK_A32_SHIFT |
| 196 #ifdef SK_CPU_BENDIAN | 201 # ifdef SK_CPU_BENDIAN |
| 197 #define SK_R32_SHIFT 24 | 202 # define SK_R32_SHIFT 24 |
| 198 #define SK_G32_SHIFT 16 | 203 # define SK_G32_SHIFT 16 |
| 199 #define SK_B32_SHIFT 8 | 204 # define SK_B32_SHIFT 8 |
| 200 #define SK_A32_SHIFT 0 | 205 # define SK_A32_SHIFT 0 |
| 201 #else | 206 # else |
| 202 #define SK_R32_SHIFT 0 | 207 # define SK_R32_SHIFT 0 |
| 203 #define SK_G32_SHIFT 8 | 208 # define SK_G32_SHIFT 8 |
| 204 #define SK_B32_SHIFT 16 | 209 # define SK_B32_SHIFT 16 |
| 205 #define SK_A32_SHIFT 24 | 210 # define SK_A32_SHIFT 24 |
| 206 #endif | 211 # endif |
| 207 #endif | 212 #endif |
| 208 | 213 |
| 209 /** | 214 /** |
| 210 * SkColor has well defined shift values, but SkPMColor is configurable. This | 215 * SkColor has well defined shift values, but SkPMColor is configurable. This |
| 211 * macro is a convenience that returns true if the shift values are equal while | 216 * macro is a convenience that returns true if the shift values are equal while |
| 212 * ignoring the machine's endianness. | 217 * ignoring the machine's endianness. |
| 213 */ | 218 */ |
| 214 #define SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER \ | 219 #define SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER \ |
| 215 (SK_A32_SHIFT == 24 && SK_R32_SHIFT == 16 && SK_G32_SHIFT == 8 && SK_B32_SHI
FT == 0) | 220 (SK_A32_SHIFT == 24 && SK_R32_SHIFT == 16 && SK_G32_SHIFT == 8 && SK_B32_SHI
FT == 0) |
| 216 | 221 |
| 217 /** | 222 /** |
| 218 * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at com
pile time. The | 223 * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at com
pile time. The |
| 219 * relationship between the byte order and shift values depends on machine endia
nness. If the shift | 224 * relationship between the byte order and shift values depends on machine endia
nness. If the shift |
| 220 * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R ch
annel on a little | 225 * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R ch
annel on a little |
| 221 * endian machine and the A channel on a big endian machine. Thus, given those s
hifts values, | 226 * endian machine and the A channel on a big endian machine. Thus, given those s
hifts values, |
| 222 * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and | 227 * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and |
| 223 * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine. | 228 * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine. |
| 224 */ | 229 */ |
| 225 #ifdef SK_CPU_BENDIAN | 230 #ifdef SK_CPU_BENDIAN |
| 226 #define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ | 231 # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ |
| 227 (SK_ ## C3 ## 32_SHIFT == 0 && \ | 232 (SK_ ## C3 ## 32_SHIFT == 0 && \ |
| 228 SK_ ## C2 ## 32_SHIFT == 8 && \ | 233 SK_ ## C2 ## 32_SHIFT == 8 && \ |
| 229 SK_ ## C1 ## 32_SHIFT == 16 && \ | 234 SK_ ## C1 ## 32_SHIFT == 16 && \ |
| 230 SK_ ## C0 ## 32_SHIFT == 24) | 235 SK_ ## C0 ## 32_SHIFT == 24) |
| 231 #else | 236 #else |
| 232 #define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ | 237 # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ |
| 233 (SK_ ## C0 ## 32_SHIFT == 0 && \ | 238 (SK_ ## C0 ## 32_SHIFT == 0 && \ |
| 234 SK_ ## C1 ## 32_SHIFT == 8 && \ | 239 SK_ ## C1 ## 32_SHIFT == 8 && \ |
| 235 SK_ ## C2 ## 32_SHIFT == 16 && \ | 240 SK_ ## C2 ## 32_SHIFT == 16 && \ |
| 236 SK_ ## C3 ## 32_SHIFT == 24) | 241 SK_ ## C3 ## 32_SHIFT == 24) |
| 237 #endif | 242 #endif |
| 238 | 243 |
| 239 // stdlib macros | |
| 240 | |
| 241 #if 0 | |
| 242 #if !defined(strlen) && defined(SK_DEBUG) | |
| 243 extern size_t sk_strlen(const char*); | |
| 244 #define strlen(s) sk_strlen(s) | |
| 245 #endif | |
| 246 #ifndef sk_strcpy | |
| 247 #define sk_strcpy(dst, src) strcpy(dst, src) | |
| 248 #endif | |
| 249 #ifndef sk_strchr | |
| 250 #define sk_strchr(s, c) strchr(s, c) | |
| 251 #endif | |
| 252 #ifndef sk_strrchr | |
| 253 #define sk_strrchr(s, c) strrchr(s, c) | |
| 254 #endif | |
| 255 #ifndef sk_strcmp | |
| 256 #define sk_strcmp(s, t) strcmp(s, t) | |
| 257 #endif | |
| 258 #ifndef sk_strncmp | |
| 259 #define sk_strncmp(s, t, n) strncmp(s, t, n) | |
| 260 #endif | |
| 261 #ifndef sk_memcpy | |
| 262 #define sk_memcpy(dst, src, n) memcpy(dst, src, n) | |
| 263 #endif | |
| 264 #ifndef memmove | |
| 265 #define memmove(dst, src, n) memmove(dst, src, n) | |
| 266 #endif | |
| 267 #ifndef sk_memset | |
| 268 #define sk_memset(dst, val, n) memset(dst, val, n) | |
| 269 #endif | |
| 270 #ifndef sk_memcmp | |
| 271 #define sk_memcmp(s, t, n) memcmp(s, t, n) | |
| 272 #endif | |
| 273 | |
| 274 #define sk_strequal(s, t) (!sk_strcmp(s, t)) | |
| 275 #define sk_strnequal(s, t, n) (!sk_strncmp(s, t, n)) | |
| 276 #endif | |
| 277 | |
| 278 ////////////////////////////////////////////////////////////////////// | 244 ////////////////////////////////////////////////////////////////////// |
| 279 | 245 |
| 280 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC) | 246 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC) |
| 281 #ifndef SkLONGLONG | 247 # ifndef SkLONGLONG |
| 282 #ifdef SK_BUILD_FOR_WIN32 | 248 # ifdef SK_BUILD_FOR_WIN32 |
| 283 #define SkLONGLONG __int64 | 249 # define SkLONGLONG __int64 |
| 284 #else | 250 # else |
| 285 #define SkLONGLONG long long | 251 # define SkLONGLONG long long |
| 286 #endif | 252 # endif |
| 287 #endif | 253 # endif |
| 288 #endif | 254 #endif |
| 289 | 255 |
| 290 ////////////////////////////////////////////////////////////////////////////////
////////////// | 256 ////////////////////////////////////////////////////////////////////////////////
////////////// |
| 291 #ifndef SK_BUILD_FOR_WINCE | 257 #ifndef SK_BUILD_FOR_WINCE |
| 292 #include <string.h> | 258 # include <string.h> |
| 293 #include <stdlib.h> | 259 # include <stdlib.h> |
| 294 #else | 260 #else |
| 295 #define _CMNINTRIN_DECLARE_ONLY | 261 # define _CMNINTRIN_DECLARE_ONLY |
| 296 #include "cmnintrin.h" | 262 # include "cmnintrin.h" |
| 297 #endif | 263 #endif |
| 298 | 264 |
| 299 #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32 | 265 #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32 |
| 300 //#define _CRTDBG_MAP_ALLOC | 266 # ifdef free |
| 301 #ifdef free | 267 # undef free |
| 302 #undef free | 268 # endif |
| 303 #endif | 269 # include <crtdbg.h> |
| 304 #include <crtdbg.h> | 270 # undef free |
| 305 #undef free | 271 # |
| 306 | 272 # ifdef SK_DEBUGx |
| 307 #ifdef SK_DEBUGx | 273 # if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus) |
| 308 #if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus) | 274 void * operator new( |
| 309 void * operator new( | 275 size_t cb, |
| 310 size_t cb, | 276 int nBlockUse, |
| 311 int nBlockUse, | 277 const char * szFileName, |
| 312 const char * szFileName, | 278 int nLine, |
| 313 int nLine, | 279 int foo |
| 314 int foo | 280 ); |
| 315 ); | 281 void * operator new[]( |
| 316 void * operator new[]( | 282 size_t cb, |
| 317 size_t cb, | 283 int nBlockUse, |
| 318 int nBlockUse, | 284 const char * szFileName, |
| 319 const char * szFileName, | 285 int nLine, |
| 320 int nLine, | 286 int foo |
| 321 int foo | 287 ); |
| 322 ); | 288 void operator delete( |
| 323 void operator delete( | 289 void *pUserData, |
| 324 void *pUserData, | 290 int, const char*, int, int |
| 325 int, const char*, int, int | 291 ); |
| 326 ); | 292 void operator delete( |
| 327 void operator delete( | 293 void *pUserData |
| 328 void *pUserData | 294 ); |
| 329 ); | 295 void operator delete[]( void * p ); |
| 330 void operator delete[]( void * p ); | 296 # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0) |
| 331 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0) | 297 # else |
| 332 #else | 298 # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) |
| 333 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) | 299 # endif |
| 334 #endif | 300 # define new DEBUG_CLIENTBLOCK |
| 335 #define new DEBUG_CLIENTBLOCK | 301 # else |
| 336 #else | 302 # define DEBUG_CLIENTBLOCK |
| 337 #define DEBUG_CLIENTBLOCK | 303 # endif |
| 338 #endif // _DEBUG | |
| 339 | |
| 340 | |
| 341 #endif | |
| 342 | |
| 343 #endif | 304 #endif |
| 344 | 305 |
| 345 ////////////////////////////////////////////////////////////////////// | 306 ////////////////////////////////////////////////////////////////////// |
| 346 | 307 |
| 347 #ifndef SK_OVERRIDE | 308 #ifndef SK_OVERRIDE |
| 348 #if defined(_MSC_VER) | 309 # if defined(_MSC_VER) |
| 349 #define SK_OVERRIDE override | 310 # define SK_OVERRIDE override |
| 350 #elif defined(__clang__) | 311 # elif defined(__clang__) |
| 351 // Clang defaults to C++03 and warns about using override. Squelch that.
Intentionally no | 312 // Using __attribute__((override)) on clang does not appear to always work. |
| 352 // push/pop here so all users of SK_OVERRIDE ignore the warning too. Thi
s is like passing | 313 // Clang defaults to C++03 and warns about using override. Squelch that. In
tentionally no |
| 353 // -Wno-c++11-extensions, except that GCC won't die (because it won't se
e this pragma). | 314 // push/pop here so all users of SK_OVERRIDE ignore the warning too. This i
s like passing |
| 354 #pragma clang diagnostic ignored "-Wc++11-extensions" | 315 // -Wno-c++11-extensions, except that GCC won't die (because it won't see t
his pragma). |
| 355 | 316 # pragma clang diagnostic ignored "-Wc++11-extensions" |
| 356 #if __has_feature(cxx_override_control) | 317 # |
| 357 // Some documentation suggests we should be using __attribute__((ove
rride)), | 318 # if __has_feature(cxx_override_control) |
| 358 // but it doesn't work. | 319 # define SK_OVERRIDE override |
| 359 #define SK_OVERRIDE override | 320 # elif defined(__has_extension) && __has_extension(cxx_override_control) |
| 360 #elif defined(__has_extension) | 321 # define SK_OVERRIDE override |
| 361 #if __has_extension(cxx_override_control) | 322 # endif |
| 362 #define SK_OVERRIDE override | 323 # endif |
| 363 #endif | 324 # ifndef SK_OVERRIDE |
| 364 #endif | 325 # define SK_OVERRIDE |
| 365 #endif | 326 # endif |
| 366 #ifndef SK_OVERRIDE | |
| 367 #define SK_OVERRIDE | |
| 368 #endif | |
| 369 #endif | 327 #endif |
| 370 | 328 |
| 371 ////////////////////////////////////////////////////////////////////// | 329 ////////////////////////////////////////////////////////////////////// |
| 372 | 330 |
| 373 #if !defined(SK_UNUSED) | 331 #if !defined(SK_UNUSED) |
| 374 #define SK_UNUSED SK_ATTRIBUTE(unused) | 332 # define SK_UNUSED SK_ATTRIBUTE(unused) |
| 375 #endif | 333 #endif |
| 376 | 334 |
| 377 #if !defined(SK_ATTR_DEPRECATED) | 335 #if !defined(SK_ATTR_DEPRECATED) |
| 378 // we ignore msg for now... | 336 // FIXME: we ignore msg for now... |
| 379 #define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated) | 337 # define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated) |
| 380 #endif | 338 #endif |
| 381 | 339 |
| 382 // If your judgment is better than the compiler's (i.e. you've profiled it), | 340 /** |
| 383 // you can use SK_ALWAYS_INLINE to force inlining. E.g. | 341 * If your judgment is better than the compiler's (i.e. you've profiled it), |
| 384 // inline void someMethod() { ... } // may not be inlined | 342 * you can use SK_ALWAYS_INLINE to force inlining. E.g. |
| 385 // SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined | 343 * inline void someMethod() { ... } // may not be inlined |
| 344 * SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined |
| 345 */ |
| 386 #if !defined(SK_ALWAYS_INLINE) | 346 #if !defined(SK_ALWAYS_INLINE) |
| 387 # if defined(SK_BUILD_FOR_WIN) | 347 # if defined(SK_BUILD_FOR_WIN) |
| 388 # define SK_ALWAYS_INLINE __forceinline | 348 # define SK_ALWAYS_INLINE __forceinline |
| 389 # else | 349 # else |
| 390 # define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline | 350 # define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline |
| 391 # endif | 351 # endif |
| 392 #endif | 352 #endif |
| 393 | 353 |
| 394 ////////////////////////////////////////////////////////////////////// | 354 ////////////////////////////////////////////////////////////////////// |
| 395 | 355 |
| 396 #if defined(__clang__) || defined(__GNUC__) | 356 #if defined(__clang__) || defined(__GNUC__) |
| 397 #define SK_PREFETCH(ptr) __builtin_prefetch(ptr) | 357 # define SK_PREFETCH(ptr) __builtin_prefetch(ptr) |
| 398 #define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1) | 358 # define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1) |
| 399 #else | 359 #else |
| 400 #define SK_PREFETCH(ptr) | 360 # define SK_PREFETCH(ptr) |
| 401 #define SK_WRITE_PREFETCH(ptr) | 361 # define SK_WRITE_PREFETCH(ptr) |
| 402 #endif | 362 #endif |
| 403 | 363 |
| 404 ////////////////////////////////////////////////////////////////////// | 364 ////////////////////////////////////////////////////////////////////// |
| 365 |
| 405 #ifndef SK_PRINTF_LIKE | 366 #ifndef SK_PRINTF_LIKE |
| 406 #if defined(__clang__) || defined(__GNUC__) | 367 # if defined(__clang__) || defined(__GNUC__) |
| 407 #define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) | 368 # define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) |
| 408 #else | 369 # else |
| 409 #define SK_PRINTF_LIKE(A, B) | 370 # define SK_PRINTF_LIKE(A, B) |
| 410 #endif | 371 # endif |
| 411 #endif | 372 #endif |
| 412 | 373 |
| 413 ////////////////////////////////////////////////////////////////////// | 374 ////////////////////////////////////////////////////////////////////// |
| 414 | 375 |
| 415 #ifndef SK_SIZE_T_SPECIFIER | 376 #ifndef SK_SIZE_T_SPECIFIER |
| 416 #if defined(_MSC_VER) | 377 # if defined(_MSC_VER) |
| 417 #define SK_SIZE_T_SPECIFIER "%Iu" | 378 # define SK_SIZE_T_SPECIFIER "%Iu" |
| 418 #else | 379 # else |
| 419 #define SK_SIZE_T_SPECIFIER "%zu" | 380 # define SK_SIZE_T_SPECIFIER "%zu" |
| 420 #endif | 381 # endif |
| 421 #endif | 382 #endif |
| 422 | 383 |
| 423 ////////////////////////////////////////////////////////////////////// | 384 ////////////////////////////////////////////////////////////////////// |
| 424 | 385 |
| 425 #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 386 #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 426 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1 | 387 # define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1 |
| 427 #endif | 388 #endif |
| 389 |
| 390 #endif // SkPostConfig_DEFINED |
| OLD | NEW |