| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * 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 |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTypes_DEFINED | 8 #ifndef SkTypes_DEFINED |
| 9 #define SkTypes_DEFINED | 9 #define SkTypes_DEFINED |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 */ | 60 */ |
| 61 | 61 |
| 62 /** Called internally if we run out of memory. The platform implementation must | 62 /** Called internally if we run out of memory. The platform implementation must |
| 63 not return, but should either throw an exception or otherwise exit. | 63 not return, but should either throw an exception or otherwise exit. |
| 64 */ | 64 */ |
| 65 SK_API extern void sk_out_of_memory(void); | 65 SK_API extern void sk_out_of_memory(void); |
| 66 /** Called internally if we hit an unrecoverable error. | 66 /** Called internally if we hit an unrecoverable error. |
| 67 The platform implementation must not return, but should either throw | 67 The platform implementation must not return, but should either throw |
| 68 an exception or otherwise exit. | 68 an exception or otherwise exit. |
| 69 */ | 69 */ |
| 70 SK_API extern void sk_throw(void); | 70 SK_API extern void sk_abort_no_print(void); |
| 71 | 71 |
| 72 enum { | 72 enum { |
| 73 SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory wil
l be freed in the scope of the stack frame | 73 SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory wil
l be freed in the scope of the stack frame |
| 74 SK_MALLOC_THROW = 0x02 //!< instructs sk_malloc to call sk_throw if the mem
ory cannot be allocated. | 74 SK_MALLOC_THROW = 0x02 //!< instructs sk_malloc to call sk_throw if the mem
ory cannot be allocated. |
| 75 }; | 75 }; |
| 76 /** Return a block of memory (at least 4-byte aligned) of at least the | 76 /** Return a block of memory (at least 4-byte aligned) of at least the |
| 77 specified size. If the requested memory cannot be returned, either | 77 specified size. If the requested memory cannot be returned, either |
| 78 return null (if SK_MALLOC_TEMP bit is clear) or throw an exception | 78 return null (if SK_MALLOC_TEMP bit is clear) or throw an exception |
| 79 (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free(). | 79 (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free(). |
| 80 */ | 80 */ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 /////////////////////////////////////////////////////////////////////////////// | 123 /////////////////////////////////////////////////////////////////////////////// |
| 124 | 124 |
| 125 #define SK_INIT_TO_AVOID_WARNING = 0 | 125 #define SK_INIT_TO_AVOID_WARNING = 0 |
| 126 | 126 |
| 127 #ifndef SkDebugf | 127 #ifndef SkDebugf |
| 128 SK_API void SkDebugf(const char format[], ...); | 128 SK_API void SkDebugf(const char format[], ...); |
| 129 #endif | 129 #endif |
| 130 | 130 |
| 131 #define SkASSERT_RELEASE(cond) if(!(cond)) { SK_ABORT(#cond); } |
| 132 |
| 131 #ifdef SK_DEBUG | 133 #ifdef SK_DEBUG |
| 132 #define SkASSERT(cond) SK_ALWAYSBREAK(cond) | 134 #define SkASSERT(cond) SkASSERT_RELEASE(cond) |
| 133 #define SkDEBUGFAIL(message) SkASSERT(false && message) | 135 #define SkDEBUGFAIL(message) SkASSERT(false && message) |
| 134 #define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__) | 136 #define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__) |
| 135 #define SkDEBUGCODE(code) code | 137 #define SkDEBUGCODE(code) code |
| 136 #define SkDECLAREPARAM(type, var) , type var | 138 #define SkDECLAREPARAM(type, var) , type var |
| 137 #define SkPARAM(var) , var | 139 #define SkPARAM(var) , var |
| 138 // #define SkDEBUGF(args ) SkDebugf##args | 140 // #define SkDEBUGF(args ) SkDebugf##args |
| 139 #define SkDEBUGF(args ) SkDebugf args | 141 #define SkDEBUGF(args ) SkDebugf args |
| 140 #define SkAssertResult(cond) SkASSERT(cond) | 142 #define SkAssertResult(cond) SkASSERT(cond) |
| 141 #else | 143 #else |
| 142 #define SkASSERT(cond) | 144 #define SkASSERT(cond) |
| 143 #define SkDEBUGFAIL(message) | 145 #define SkDEBUGFAIL(message) |
| 144 #define SkDEBUGCODE(code) | 146 #define SkDEBUGCODE(code) |
| 145 #define SkDEBUGF(args) | 147 #define SkDEBUGF(args) |
| 146 #define SkDECLAREPARAM(type, var) | 148 #define SkDECLAREPARAM(type, var) |
| 147 #define SkPARAM(var) | 149 #define SkPARAM(var) |
| 148 | 150 |
| 149 // unlike SkASSERT, this guy executes its condition in the non-debug build | 151 // unlike SkASSERT, this guy executes its condition in the non-debug build |
| 150 #define SkAssertResult(cond) cond | 152 #define SkAssertResult(cond) cond |
| 151 #endif | 153 #endif |
| 152 | 154 |
| 153 #define SkFAIL(message) SK_ALWAYSBREAK(false && message) | 155 // Legacy macro names for SK_ABORT |
| 156 #define SkFAIL(message) SK_ABORT(message) |
| 157 #define sk_throw() SK_ABORT("sk_throw") |
| 154 | 158 |
| 155 // We want to evaluate cond only once, and inside the SkASSERT somewhere so we s
ee its string form. | 159 // We want to evaluate cond only once, and inside the SkASSERT somewhere so we s
ee its string form. |
| 156 // So we use the comma operator to make an SkDebugf that always returns false: w
e'll evaluate cond, | 160 // So we use the comma operator to make an SkDebugf that always returns false: w
e'll evaluate cond, |
| 157 // and if it's true the assert passes; if it's false, we'll print the message an
d the assert fails. | 161 // and if it's true the assert passes; if it's false, we'll print the message an
d the assert fails. |
| 158 #define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __
VA_ARGS__), false)) | 162 #define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __
VA_ARGS__), false)) |
| 159 | 163 |
| 160 #ifdef SK_DEVELOPER | 164 #ifdef SK_DEVELOPER |
| 161 #define SkDEVCODE(code) code | 165 #define SkDEVCODE(code) code |
| 162 #else | 166 #else |
| 163 #define SkDEVCODE(code) | 167 #define SkDEVCODE(code) |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 private: | 688 private: |
| 685 void* fPtr; | 689 void* fPtr; |
| 686 size_t fSize; // can be larger than the requested size (see kReuse) | 690 size_t fSize; // can be larger than the requested size (see kReuse) |
| 687 uint32_t fStorage[(kSize + 3) >> 2]; | 691 uint32_t fStorage[(kSize + 3) >> 2]; |
| 688 }; | 692 }; |
| 689 // Can't guard the constructor because it's a template class. | 693 // Can't guard the constructor because it's a template class. |
| 690 | 694 |
| 691 #endif /* C++ */ | 695 #endif /* C++ */ |
| 692 | 696 |
| 693 #endif | 697 #endif |
| OLD | NEW |