| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #undef GR_QNX_BUILD | 78 #undef GR_QNX_BUILD |
| 79 #define GR_QNX_BUILD 1 | 79 #define GR_QNX_BUILD 1 |
| 80 // #error "QNX" | 80 // #error "QNX" |
| 81 #else | 81 #else |
| 82 #undef GR_LINUX_BUILD | 82 #undef GR_LINUX_BUILD |
| 83 #define GR_LINUX_BUILD 1 | 83 #define GR_LINUX_BUILD 1 |
| 84 // #error "LINUX" | 84 // #error "LINUX" |
| 85 #endif | 85 #endif |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 // we need both GR_DEBUG and GR_RELEASE to be defined as 0 or 1 | 88 #if !defined(SK_DEBUG) && !GR_RELEASE |
| 89 // | 89 #ifdef NDEBUG |
| 90 #ifndef GR_DEBUG | 90 #define GR_RELEASE 1 |
| 91 #ifdef GR_RELEASE | |
| 92 #define GR_DEBUG !GR_RELEASE | |
| 93 #else | |
| 94 #ifdef NDEBUG | |
| 95 #define GR_DEBUG 0 | |
| 96 #else | |
| 97 #define GR_DEBUG 1 | |
| 98 #endif | |
| 99 #endif | 91 #endif |
| 100 #endif | 92 #endif |
| 101 | 93 |
| 102 #ifndef GR_RELEASE | 94 #if defined(SK_DEBUG) && GR_RELEASE |
| 103 #define GR_RELEASE !GR_DEBUG | 95 #error "cannot define both SK_DEBUG and GR_RELEASE" |
| 104 #endif | |
| 105 | |
| 106 #if GR_DEBUG == GR_RELEASE | |
| 107 #error "GR_DEBUG and GR_RELEASE must not be the same" | |
| 108 #endif | 96 #endif |
| 109 | 97 |
| 110 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
| 111 /////////////////////////////////////////////////////////////////////////////// | 99 /////////////////////////////////////////////////////////////////////////////// |
| 112 | 100 |
| 113 #if GR_WIN32_BUILD | 101 #if GR_WIN32_BUILD |
| 114 // VC8 doesn't support stdint.h, so we define those types here. | 102 // VC8 doesn't support stdint.h, so we define those types here. |
| 115 typedef signed char int8_t; | 103 typedef signed char int8_t; |
| 116 typedef unsigned char uint8_t; | 104 typedef unsigned char uint8_t; |
| 117 typedef short int16_t; | 105 typedef short int16_t; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 135 #include <stdint.h> | 123 #include <stdint.h> |
| 136 #endif | 124 #endif |
| 137 | 125 |
| 138 /* | 126 /* |
| 139 * The "user config" file can be empty, and everything should work. It is | 127 * The "user config" file can be empty, and everything should work. It is |
| 140 * meant to store a given platform/client's overrides of our guess-work. | 128 * meant to store a given platform/client's overrides of our guess-work. |
| 141 * | 129 * |
| 142 * A alternate user config file can be specified by defining | 130 * A alternate user config file can be specified by defining |
| 143 * GR_USER_CONFIG_FILE. It should be defined relative to GrConfig.h | 131 * GR_USER_CONFIG_FILE. It should be defined relative to GrConfig.h |
| 144 * | 132 * |
| 145 * e.g. it can specify GR_DEBUG/GR_RELEASE as it please, change the BUILD | 133 * e.g. it can change the BUILD target or supply its own defines for anything |
| 146 * target, or supply its own defines for anything else (e.g. GR_DEFAULT_TEXTURE
_CACHE_MB_LIMIT) | 134 * else (e.g. GR_DEFAULT_TEXTURE_CACHE_MB_LIMIT) |
| 147 */ | 135 */ |
| 148 #if !defined(GR_USER_CONFIG_FILE) | 136 #if !defined(GR_USER_CONFIG_FILE) |
| 149 #include "GrUserConfig.h" | 137 #include "GrUserConfig.h" |
| 150 #else | 138 #else |
| 151 #include GR_USER_CONFIG_FILE | 139 #include GR_USER_CONFIG_FILE |
| 152 #endif | 140 #endif |
| 153 | 141 |
| 154 | 142 |
| 155 /////////////////////////////////////////////////////////////////////////////// | 143 /////////////////////////////////////////////////////////////////////////////// |
| 156 /////////////////////////////////////////////////////////////////////////////// | 144 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // sign extend for 64bit architectures to be sure this is | 193 // sign extend for 64bit architectures to be sure this is |
| 206 // in the high address range | 194 // in the high address range |
| 207 #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xb
eefcafe) = 0; | 195 #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xb
eefcafe) = 0; |
| 208 #endif | 196 #endif |
| 209 #endif | 197 #endif |
| 210 | 198 |
| 211 /** | 199 /** |
| 212 * GR_DEBUGBREAK is an unconditional break in debug builds. | 200 * GR_DEBUGBREAK is an unconditional break in debug builds. |
| 213 */ | 201 */ |
| 214 #if !defined(GR_DEBUGBREAK) | 202 #if !defined(GR_DEBUGBREAK) |
| 215 #if GR_DEBUG | 203 #ifdef SK_DEBUG |
| 216 #define GR_DEBUGBREAK GR_ALWAYSBREAK | 204 #define GR_DEBUGBREAK GR_ALWAYSBREAK |
| 217 #else | 205 #else |
| 218 #define GR_DEBUGBREAK | 206 #define GR_DEBUGBREAK |
| 219 #endif | 207 #endif |
| 220 #endif | 208 #endif |
| 221 | 209 |
| 222 /** | 210 /** |
| 223 * GR_ALWAYSASSERT is an assertion in all builds. | 211 * GR_ALWAYSASSERT is an assertion in all builds. |
| 224 */ | 212 */ |
| 225 #if !defined(GR_ALWAYSASSERT) | 213 #if !defined(GR_ALWAYSASSERT) |
| 226 #define GR_ALWAYSASSERT(COND) \ | 214 #define GR_ALWAYSASSERT(COND) \ |
| 227 do { \ | 215 do { \ |
| 228 if (!(COND)) { \ | 216 if (!(COND)) { \ |
| 229 GrPrintf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \ | 217 GrPrintf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \ |
| 230 GR_ALWAYSBREAK; \ | 218 GR_ALWAYSBREAK; \ |
| 231 } \ | 219 } \ |
| 232 } while (false) | 220 } while (false) |
| 233 #endif | 221 #endif |
| 234 | 222 |
| 235 /** | 223 /** |
| 236 * GR_DEBUGASSERT is an assertion in debug builds only. | 224 * GR_DEBUGASSERT is an assertion in debug builds only. |
| 237 */ | 225 */ |
| 238 #if !defined(GR_DEBUGASSERT) | 226 #if !defined(GR_DEBUGASSERT) |
| 239 #if GR_DEBUG | 227 #ifdef SK_DEBUG |
| 240 #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND) | 228 #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND) |
| 241 #else | 229 #else |
| 242 #define GR_DEBUGASSERT(COND) | 230 #define GR_DEBUGASSERT(COND) |
| 243 #endif | 231 #endif |
| 244 #endif | 232 #endif |
| 245 | 233 |
| 246 /** | 234 /** |
| 247 * Prettier forms of the above macros. | 235 * Prettier forms of the above macros. |
| 248 */ | 236 */ |
| 249 #define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND) | 237 #define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND) |
| 250 | 238 |
| 251 /** | 239 /** |
| 252 * Crash from unrecoverable condition, optionally with a message. The debug vari
ants only | 240 * Crash from unrecoverable condition, optionally with a message. The debug vari
ants only |
| 253 * crash in a debug build. The message versions print the message regardless of
release vs debug. | 241 * crash in a debug build. The message versions print the message regardless of
release vs debug. |
| 254 */ | 242 */ |
| 255 inline void GrCrash() { GrAlwaysAssert(false); } | 243 inline void GrCrash() { GrAlwaysAssert(false); } |
| 256 inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); } | 244 inline void GrCrash(const char* msg) { GrPrintf(msg); GrAlwaysAssert(false); } |
| 257 inline void GrDebugCrash() { SkASSERT(false); } | 245 inline void GrDebugCrash() { SkASSERT(false); } |
| 258 inline void GrDebugCrash(const char* msg) { GrPrintf(msg); SkASSERT(false); } | 246 inline void GrDebugCrash(const char* msg) { GrPrintf(msg); SkASSERT(false); } |
| 259 | 247 |
| 260 /** | 248 /** |
| 261 * GR_DEBUGCODE compiles the code X in debug builds only | 249 * GR_DEBUGCODE compiles the code X in debug builds only |
| 262 */ | 250 */ |
| 263 #if !defined(GR_DEBUGCODE) | 251 #if !defined(GR_DEBUGCODE) |
| 264 #if GR_DEBUG | 252 #ifdef SK_DEBUG |
| 265 #define GR_DEBUGCODE(X) X | 253 #define GR_DEBUGCODE(X) X |
| 266 #else | 254 #else |
| 267 #define GR_DEBUGCODE(X) | 255 #define GR_DEBUGCODE(X) |
| 268 #endif | 256 #endif |
| 269 #endif | 257 #endif |
| 270 | 258 |
| 271 /** | 259 /** |
| 272 * GR_STATIC_ASSERT is a compile time assertion. Depending on the platform | 260 * GR_STATIC_ASSERT is a compile time assertion. Depending on the platform |
| 273 * it may print the message in the compiler log. Obviously, the condition must | 261 * it may print the message in the compiler log. Obviously, the condition must |
| 274 * be evaluatable at compile time. | 262 * be evaluatable at compile time. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 #endif | 335 #endif |
| 348 #if GR_LINUX_BUILD | 336 #if GR_LINUX_BUILD |
| 349 // #pragma message GR_WARN("GR_LINUX_BUILD") | 337 // #pragma message GR_WARN("GR_LINUX_BUILD") |
| 350 #endif | 338 #endif |
| 351 #if GR_QNX_BUILD | 339 #if GR_QNX_BUILD |
| 352 // #pragma message GR_WARN("GR_QNX_BUILD") | 340 // #pragma message GR_WARN("GR_QNX_BUILD") |
| 353 #endif | 341 #endif |
| 354 #endif | 342 #endif |
| 355 | 343 |
| 356 #endif | 344 #endif |
| OLD | NEW |