reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef SkPostConfig_DEFINED |
| 9 | #define SkPostConfig_DEFINED |
| 10 | |
| 11 | #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 12 | # define SK_BUILD_FOR_WIN |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 13 | #endif |
| 14 | |
| 15 | #if defined(SK_DEBUG) && defined(SK_RELEASE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 16 | # error "cannot define both SK_DEBUG and SK_RELEASE" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 17 | #elif !defined(SK_DEBUG) && !defined(SK_RELEASE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 18 | # error "must define either SK_DEBUG or SK_RELEASE" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 19 | #endif |
| 20 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 21 | #if defined(SK_SUPPORT_UNITTEST) && !defined(SK_DEBUG) |
| 22 | # error "can't have unittests without debug" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | #endif |
| 24 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 25 | /** |
| 26 | * Matrix calculations may be float or double. |
| 27 | * The default is double, as that is faster given our impl uses doubles |
| 28 | * for intermediate calculations. |
| 29 | */ |
vollick@chromium.org | 5596a69 | 2012-11-13 20:12:00 +0000 | [diff] [blame] | 30 | #if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 31 | # error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT" |
vollick@chromium.org | 5596a69 | 2012-11-13 20:12:00 +0000 | [diff] [blame] | 32 | #elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 33 | # define SK_MSCALAR_IS_DOUBLE |
vollick@chromium.org | 5596a69 | 2012-11-13 20:12:00 +0000 | [diff] [blame] | 34 | #endif |
| 35 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 36 | #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 37 | # error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 39 | # error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | #endif |
| 41 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 42 | /** |
| 43 | * Ensure the port has defined all of SK_X32_SHIFT, or none of them. |
| 44 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | #ifdef SK_A32_SHIFT |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 46 | # if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT) |
| 47 | # error "all or none of the 32bit SHIFT amounts must be defined" |
| 48 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 50 | # if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT) |
| 51 | # error "all or none of the 32bit SHIFT amounts must be defined" |
| 52 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 53 | #endif |
| 54 | |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 55 | #if !defined(SK_HAS_COMPILER_FEATURE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 56 | # if defined(__has_feature) |
| 57 | # define SK_HAS_COMPILER_FEATURE(x) __has_feature(x) |
| 58 | # else |
| 59 | # define SK_HAS_COMPILER_FEATURE(x) 0 |
| 60 | # endif |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 61 | #endif |
| 62 | |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 63 | #if !defined(SK_ATTRIBUTE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 64 | # if defined(__clang__) || defined(__GNUC__) |
| 65 | # define SK_ATTRIBUTE(attr) __attribute__((attr)) |
| 66 | # else |
| 67 | # define SK_ATTRIBUTE(attr) |
| 68 | # endif |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 69 | #endif |
| 70 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 71 | #if !defined(SK_SUPPORT_GPU) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 72 | # define SK_SUPPORT_GPU 1 |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 73 | #endif |
| 74 | |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 75 | /** |
| 76 | * The clang static analyzer likes to know that when the program is not |
| 77 | * expected to continue (crash, assertion failure, etc). It will notice that |
| 78 | * some combination of parameters lead to a function call that does not return. |
| 79 | * It can then make appropriate assumptions about the parameters in code |
| 80 | * executed only if the non-returning function was *not* called. |
| 81 | */ |
| 82 | #if !defined(SkNO_RETURN_HINT) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 83 | # if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn) |
| 84 | static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn)); |
| 85 | static inline void SkNO_RETURN_HINT() {} |
| 86 | # else |
| 87 | # define SkNO_RETURN_HINT() do {} while (false) |
| 88 | # endif |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 89 | #endif |
| 90 | |
justinlin@google.com | fffb2f1 | 2012-04-16 19:10:21 +0000 | [diff] [blame] | 91 | #if defined(SK_ZLIB_INCLUDE) && defined(SK_SYSTEM_ZLIB) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 92 | # error "cannot define both SK_ZLIB_INCLUDE and SK_SYSTEM_ZLIB" |
justinlin@google.com | fffb2f1 | 2012-04-16 19:10:21 +0000 | [diff] [blame] | 93 | #elif defined(SK_ZLIB_INCLUDE) || defined(SK_SYSTEM_ZLIB) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 94 | # define SK_HAS_ZLIB |
justinlin@google.com | fffb2f1 | 2012-04-16 19:10:21 +0000 | [diff] [blame] | 95 | #endif |
| 96 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 97 | /////////////////////////////////////////////////////////////////////////////// |
| 98 | |
| 99 | #ifndef SkNEW |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 100 | # define SkNEW(type_name) (new type_name) |
| 101 | # define SkNEW_ARGS(type_name, args) (new type_name args) |
| 102 | # define SkNEW_ARRAY(type_name, count) (new type_name[(count)]) |
| 103 | # define SkNEW_PLACEMENT(buf, type_name) (new (buf) type_name) |
| 104 | # define SkNEW_PLACEMENT_ARGS(buf, type_name, args) (new (buf) type_name args) |
| 105 | # define SkDELETE(obj) (delete (obj)) |
| 106 | # define SkDELETE_ARRAY(array) (delete[] (array)) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 107 | #endif |
| 108 | |
| 109 | #ifndef SK_CRASH |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 110 | # if 1 // set to 0 for infinite loop, which can help connecting gdb |
| 111 | # define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false) |
| 112 | # else |
| 113 | # define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true) |
| 114 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 115 | #endif |
| 116 | |
| 117 | /////////////////////////////////////////////////////////////////////////////// |
| 118 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 119 | /** |
| 120 | * SK_ENABLE_INST_COUNT controlls printing how many reference counted objects |
| 121 | * are still held on exit. |
| 122 | * Defaults to 1 in DEBUG and 0 in RELEASE. |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 123 | */ |
bsalomon@google.com | 4e23068 | 2013-01-15 20:37:04 +0000 | [diff] [blame] | 124 | #ifndef SK_ENABLE_INST_COUNT |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 125 | # ifdef SK_DEBUG |
commit-bot@chromium.org | 2ab1ba0 | 2014-01-17 17:55:02 +0000 | [diff] [blame] | 126 | // Only enabled for static builds, because instance counting relies on static |
| 127 | // variables in functions defined in header files. |
| 128 | # define SK_ENABLE_INST_COUNT !defined(SKIA_DLL) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 129 | # else |
| 130 | # define SK_ENABLE_INST_COUNT 0 |
| 131 | # endif |
bsalomon@google.com | 4e23068 | 2013-01-15 20:37:04 +0000 | [diff] [blame] | 132 | #endif |
| 133 | |
| 134 | /////////////////////////////////////////////////////////////////////////////// |
| 135 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 136 | #ifdef SK_BUILD_FOR_WIN |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 137 | # ifndef WIN32_LEAN_AND_MEAN |
| 138 | # define WIN32_LEAN_AND_MEAN |
| 139 | # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 140 | # endif |
| 141 | # ifndef NOMINMAX |
| 142 | # define NOMINMAX |
| 143 | # define NOMINMAX_WAS_LOCALLY_DEFINED |
| 144 | # endif |
| 145 | # |
| 146 | # include <windows.h> |
| 147 | # |
| 148 | # ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 149 | # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 150 | # undef WIN32_LEAN_AND_MEAN |
| 151 | # endif |
| 152 | # ifdef NOMINMAX_WAS_LOCALLY_DEFINED |
| 153 | # undef NOMINMAX_WAS_LOCALLY_DEFINED |
| 154 | # undef NOMINMAX |
| 155 | # endif |
| 156 | # |
| 157 | # ifndef SK_DEBUGBREAK |
| 158 | # define SK_DEBUGBREAK(p) do { if (!(p)) { SkNO_RETURN_HINT(); __debugbreak(); }} while (false) |
| 159 | # endif |
| 160 | # |
| 161 | # ifndef SK_A32_SHIFT |
| 162 | # define SK_A32_SHIFT 24 |
| 163 | # define SK_R32_SHIFT 16 |
| 164 | # define SK_G32_SHIFT 8 |
| 165 | # define SK_B32_SHIFT 0 |
| 166 | # endif |
| 167 | # |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 168 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 169 | # ifdef SK_DEBUG |
| 170 | # include <stdio.h> |
| 171 | # ifndef SK_DEBUGBREAK |
| 172 | # define SK_DEBUGBREAK(cond) do { if (cond) break; \ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 173 | SkDebugf("%s:%d: failed assertion \"%s\"\n", \ |
| 174 | __FILE__, __LINE__, #cond); SK_CRASH(); } while (false) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 175 | # endif |
| 176 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 177 | #endif |
| 178 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 179 | /** |
bsalomon@google.com | 2766118 | 2011-05-19 15:57:44 +0000 | [diff] [blame] | 180 | * We check to see if the SHIFT value has already been defined. |
| 181 | * if not, we define it ourself to some default values. We default to OpenGL |
| 182 | * order (in memory: r,g,b,a) |
| 183 | */ |
| 184 | #ifndef SK_A32_SHIFT |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 185 | # ifdef SK_CPU_BENDIAN |
| 186 | # define SK_R32_SHIFT 24 |
| 187 | # define SK_G32_SHIFT 16 |
| 188 | # define SK_B32_SHIFT 8 |
| 189 | # define SK_A32_SHIFT 0 |
| 190 | # else |
| 191 | # define SK_R32_SHIFT 0 |
| 192 | # define SK_G32_SHIFT 8 |
| 193 | # define SK_B32_SHIFT 16 |
| 194 | # define SK_A32_SHIFT 24 |
| 195 | # endif |
bsalomon@google.com | 2766118 | 2011-05-19 15:57:44 +0000 | [diff] [blame] | 196 | #endif |
| 197 | |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 198 | /** |
djsollen@google.com | 2b343cc | 2013-08-20 20:28:03 +0000 | [diff] [blame] | 199 | * SkColor has well defined shift values, but SkPMColor is configurable. This |
| 200 | * macro is a convenience that returns true if the shift values are equal while |
| 201 | * ignoring the machine's endianness. |
| 202 | */ |
| 203 | #define SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER \ |
| 204 | (SK_A32_SHIFT == 24 && SK_R32_SHIFT == 16 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 0) |
| 205 | |
| 206 | /** |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 207 | * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. The |
| 208 | * relationship between the byte order and shift values depends on machine endianness. If the shift |
| 209 | * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R channel on a little |
| 210 | * endian machine and the A channel on a big endian machine. Thus, given those shifts values, |
| 211 | * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and |
| 212 | * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine. |
| 213 | */ |
| 214 | #ifdef SK_CPU_BENDIAN |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 215 | # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 216 | (SK_ ## C3 ## 32_SHIFT == 0 && \ |
| 217 | SK_ ## C2 ## 32_SHIFT == 8 && \ |
| 218 | SK_ ## C1 ## 32_SHIFT == 16 && \ |
| 219 | SK_ ## C0 ## 32_SHIFT == 24) |
| 220 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 221 | # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 222 | (SK_ ## C0 ## 32_SHIFT == 0 && \ |
| 223 | SK_ ## C1 ## 32_SHIFT == 8 && \ |
| 224 | SK_ ## C2 ## 32_SHIFT == 16 && \ |
| 225 | SK_ ## C3 ## 32_SHIFT == 24) |
| 226 | #endif |
| 227 | |
reed@android.com | 5c80ea1 | 2009-01-08 17:49:50 +0000 | [diff] [blame] | 228 | ////////////////////////////////////////////////////////////////////// |
| 229 | |
reed@google.com | 01c41a5 | 2013-12-20 14:24:21 +0000 | [diff] [blame] | 230 | // TODO: rebaseline as needed so we can remove this flag entirely. |
| 231 | // - all platforms have int64_t now |
| 232 | // - we have slightly different fixed math results because of this check |
| 233 | // since we don't define this for linux/android |
robertphillips@google.com | 0e6e8cc | 2013-08-15 13:43:23 +0000 | [diff] [blame] | 234 | #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 235 | # ifndef SkLONGLONG |
reed@google.com | 01c41a5 | 2013-12-20 14:24:21 +0000 | [diff] [blame] | 236 | # define SkLONGLONG int64_t |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 237 | # endif |
robertphillips@google.com | 0e6e8cc | 2013-08-15 13:43:23 +0000 | [diff] [blame] | 238 | #endif |
| 239 | |
| 240 | ////////////////////////////////////////////////////////////////////////////////////////////// |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 241 | #ifndef SK_BUILD_FOR_WINCE |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 242 | # include <string.h> |
| 243 | # include <stdlib.h> |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 244 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 245 | # define _CMNINTRIN_DECLARE_ONLY |
| 246 | # include "cmnintrin.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 247 | #endif |
| 248 | |
| 249 | #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32 |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 250 | # ifdef free |
| 251 | # undef free |
| 252 | # endif |
| 253 | # include <crtdbg.h> |
| 254 | # undef free |
| 255 | # |
| 256 | # ifdef SK_DEBUGx |
| 257 | # if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus) |
| 258 | void * operator new( |
| 259 | size_t cb, |
| 260 | int nBlockUse, |
| 261 | const char * szFileName, |
| 262 | int nLine, |
| 263 | int foo |
| 264 | ); |
| 265 | void * operator new[]( |
| 266 | size_t cb, |
| 267 | int nBlockUse, |
| 268 | const char * szFileName, |
| 269 | int nLine, |
| 270 | int foo |
| 271 | ); |
| 272 | void operator delete( |
| 273 | void *pUserData, |
| 274 | int, const char*, int, int |
| 275 | ); |
| 276 | void operator delete( |
| 277 | void *pUserData |
| 278 | ); |
| 279 | void operator delete[]( void * p ); |
| 280 | # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0) |
| 281 | # else |
| 282 | # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) |
| 283 | # endif |
| 284 | # define new DEBUG_CLIENTBLOCK |
| 285 | # else |
| 286 | # define DEBUG_CLIENTBLOCK |
| 287 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 288 | #endif |
| 289 | |
tomhudson@google.com | 1341304 | 2011-10-03 16:01:10 +0000 | [diff] [blame] | 290 | ////////////////////////////////////////////////////////////////////// |
| 291 | |
| 292 | #ifndef SK_OVERRIDE |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 293 | # if defined(_MSC_VER) |
| 294 | # define SK_OVERRIDE override |
| 295 | # elif defined(__clang__) |
| 296 | // Using __attribute__((override)) on clang does not appear to always work. |
| 297 | // Clang defaults to C++03 and warns about using override. Squelch that. Intentionally no |
| 298 | // push/pop here so all users of SK_OVERRIDE ignore the warning too. This is like passing |
| 299 | // -Wno-c++11-extensions, except that GCC won't die (because it won't see this pragma). |
| 300 | # pragma clang diagnostic ignored "-Wc++11-extensions" |
| 301 | # |
| 302 | # if __has_feature(cxx_override_control) |
| 303 | # define SK_OVERRIDE override |
| 304 | # elif defined(__has_extension) && __has_extension(cxx_override_control) |
| 305 | # define SK_OVERRIDE override |
| 306 | # endif |
| 307 | # endif |
| 308 | # ifndef SK_OVERRIDE |
| 309 | # define SK_OVERRIDE |
| 310 | # endif |
tomhudson@google.com | 1341304 | 2011-10-03 16:01:10 +0000 | [diff] [blame] | 311 | #endif |
| 312 | |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 313 | ////////////////////////////////////////////////////////////////////// |
| 314 | |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 315 | #if !defined(SK_UNUSED) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 316 | # define SK_UNUSED SK_ATTRIBUTE(unused) |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 317 | #endif |
| 318 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 319 | #if !defined(SK_ATTR_DEPRECATED) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 320 | // FIXME: we ignore msg for now... |
| 321 | # define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated) |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 322 | #endif |
| 323 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 324 | /** |
| 325 | * If your judgment is better than the compiler's (i.e. you've profiled it), |
| 326 | * you can use SK_ALWAYS_INLINE to force inlining. E.g. |
| 327 | * inline void someMethod() { ... } // may not be inlined |
| 328 | * SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined |
| 329 | */ |
mtklein@google.com | 1950d5f | 2013-11-22 16:56:22 +0000 | [diff] [blame] | 330 | #if !defined(SK_ALWAYS_INLINE) |
| 331 | # if defined(SK_BUILD_FOR_WIN) |
| 332 | # define SK_ALWAYS_INLINE __forceinline |
| 333 | # else |
| 334 | # define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline |
| 335 | # endif |
| 336 | #endif |
| 337 | |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 338 | ////////////////////////////////////////////////////////////////////// |
| 339 | |
commit-bot@chromium.org | fedf13d | 2013-11-05 15:03:26 +0000 | [diff] [blame] | 340 | #if defined(__clang__) || defined(__GNUC__) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 341 | # define SK_PREFETCH(ptr) __builtin_prefetch(ptr) |
| 342 | # define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1) |
commit-bot@chromium.org | fedf13d | 2013-11-05 15:03:26 +0000 | [diff] [blame] | 343 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 344 | # define SK_PREFETCH(ptr) |
| 345 | # define SK_WRITE_PREFETCH(ptr) |
commit-bot@chromium.org | fedf13d | 2013-11-05 15:03:26 +0000 | [diff] [blame] | 346 | #endif |
| 347 | |
| 348 | ////////////////////////////////////////////////////////////////////// |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 349 | |
senorblanco@chromium.org | 3a67a66 | 2012-07-09 18:22:08 +0000 | [diff] [blame] | 350 | #ifndef SK_PRINTF_LIKE |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 351 | # if defined(__clang__) || defined(__GNUC__) |
| 352 | # define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) |
| 353 | # else |
| 354 | # define SK_PRINTF_LIKE(A, B) |
| 355 | # endif |
senorblanco@chromium.org | 3a67a66 | 2012-07-09 18:22:08 +0000 | [diff] [blame] | 356 | #endif |
| 357 | |
| 358 | ////////////////////////////////////////////////////////////////////// |
| 359 | |
| 360 | #ifndef SK_SIZE_T_SPECIFIER |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 361 | # if defined(_MSC_VER) |
| 362 | # define SK_SIZE_T_SPECIFIER "%Iu" |
| 363 | # else |
| 364 | # define SK_SIZE_T_SPECIFIER "%zu" |
| 365 | # endif |
senorblanco@chromium.org | 3a67a66 | 2012-07-09 18:22:08 +0000 | [diff] [blame] | 366 | #endif |
| 367 | |
| 368 | ////////////////////////////////////////////////////////////////////// |
| 369 | |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 370 | #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 371 | # define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1 |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 372 | #endif |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 373 | |
bungeman@google.com | d9947f6 | 2013-12-18 15:27:39 +0000 | [diff] [blame] | 374 | ////////////////////////////////////////////////////////////////////// |
| 375 | |
| 376 | #ifndef SK_ATOMICS_PLATFORM_H |
commit-bot@chromium.org | 8e13a15 | 2014-03-19 19:28:00 +0000 | [diff] [blame^] | 377 | # if defined(_MSC_VER) |
bungeman@google.com | d9947f6 | 2013-12-18 15:27:39 +0000 | [diff] [blame] | 378 | # define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_win.h" |
| 379 | # elif defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 380 | # define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_android.h" |
| 381 | # else |
| 382 | # define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h" |
| 383 | # endif |
| 384 | #endif |
| 385 | |
| 386 | #ifndef SK_MUTEX_PLATFORM_H |
| 387 | # if defined(SK_BUILD_FOR_WIN) |
| 388 | # define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_win.h" |
| 389 | # else |
| 390 | # define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_pthread.h" |
| 391 | # endif |
| 392 | #endif |
| 393 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 394 | #endif // SkPostConfig_DEFINED |