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 | |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 8 | // IWYU pragma: private, include "SkTypes.h" |
| 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkPostConfig_DEFINED |
| 11 | #define SkPostConfig_DEFINED |
| 12 | |
bungeman | f20488b | 2015-07-29 11:49:40 -0700 | [diff] [blame] | 13 | #if defined(SK_BUILD_FOR_WIN32) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 14 | # define SK_BUILD_FOR_WIN |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 15 | #endif |
| 16 | |
| 17 | #if defined(SK_DEBUG) && defined(SK_RELEASE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 18 | # error "cannot define both SK_DEBUG and SK_RELEASE" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 19 | #elif !defined(SK_DEBUG) && !defined(SK_RELEASE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 20 | # error "must define either SK_DEBUG or SK_RELEASE" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | #endif |
| 22 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 23 | #if defined(SK_SUPPORT_UNITTEST) && !defined(SK_DEBUG) |
| 24 | # error "can't have unittests without debug" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 25 | #endif |
| 26 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 27 | /** |
| 28 | * Matrix calculations may be float or double. |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 29 | * The default is float, as that's what Chromium's using. |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 30 | */ |
vollick@chromium.org | 5596a69 | 2012-11-13 20:12:00 +0000 | [diff] [blame] | 31 | #if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 32 | # 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] | 33 | #elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT) |
mtklein | 5195805 | 2015-06-09 15:06:22 -0700 | [diff] [blame] | 34 | # define SK_MSCALAR_IS_FLOAT |
vollick@chromium.org | 5596a69 | 2012-11-13 20:12:00 +0000 | [diff] [blame] | 35 | #endif |
| 36 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 38 | # error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 39 | #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 40 | # error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 41 | #endif |
| 42 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 43 | /** |
| 44 | * Ensure the port has defined all of SK_X32_SHIFT, or none of them. |
| 45 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | #ifdef SK_A32_SHIFT |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 47 | # if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT) |
| 48 | # error "all or none of the 32bit SHIFT amounts must be defined" |
| 49 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 50 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 51 | # if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT) |
| 52 | # error "all or none of the 32bit SHIFT amounts must be defined" |
| 53 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 54 | #endif |
| 55 | |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 56 | #if !defined(SK_HAS_COMPILER_FEATURE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 57 | # if defined(__has_feature) |
| 58 | # define SK_HAS_COMPILER_FEATURE(x) __has_feature(x) |
| 59 | # else |
| 60 | # define SK_HAS_COMPILER_FEATURE(x) 0 |
| 61 | # endif |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 62 | #endif |
| 63 | |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 64 | #if !defined(SK_ATTRIBUTE) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 65 | # if defined(__clang__) || defined(__GNUC__) |
| 66 | # define SK_ATTRIBUTE(attr) __attribute__((attr)) |
| 67 | # else |
| 68 | # define SK_ATTRIBUTE(attr) |
| 69 | # endif |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 70 | #endif |
| 71 | |
mtklein | e761614 | 2015-02-26 10:14:15 -0800 | [diff] [blame] | 72 | // As usual, there are two ways to increase alignment... the MSVC way and the everyone-else way. |
| 73 | #ifndef SK_STRUCT_ALIGN |
| 74 | #ifdef _MSC_VER |
| 75 | #define SK_STRUCT_ALIGN(N) __declspec(align(N)) |
| 76 | #else |
| 77 | #define SK_STRUCT_ALIGN(N) __attribute__((aligned(N))) |
| 78 | #endif |
| 79 | #endif |
| 80 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 81 | #if !defined(SK_SUPPORT_GPU) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 82 | # define SK_SUPPORT_GPU 1 |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 83 | #endif |
| 84 | |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 85 | /** |
| 86 | * The clang static analyzer likes to know that when the program is not |
| 87 | * expected to continue (crash, assertion failure, etc). It will notice that |
| 88 | * some combination of parameters lead to a function call that does not return. |
| 89 | * It can then make appropriate assumptions about the parameters in code |
| 90 | * executed only if the non-returning function was *not* called. |
| 91 | */ |
| 92 | #if !defined(SkNO_RETURN_HINT) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 93 | # if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn) |
| 94 | static inline void SkNO_RETURN_HINT() __attribute__((analyzer_noreturn)); |
| 95 | static inline void SkNO_RETURN_HINT() {} |
| 96 | # else |
| 97 | # define SkNO_RETURN_HINT() do {} while (false) |
| 98 | # endif |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 99 | #endif |
| 100 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 101 | /////////////////////////////////////////////////////////////////////////////// |
| 102 | |
mdempsky | 106b124 | 2015-09-22 06:10:35 -0700 | [diff] [blame] | 103 | // TODO(mdempsky): Move elsewhere as appropriate. |
| 104 | #include <new> |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 105 | |
| 106 | #ifndef SK_CRASH |
mtklein | 3f73e8c | 2014-06-19 07:41:58 -0700 | [diff] [blame] | 107 | # ifdef SK_BUILD_FOR_WIN |
| 108 | # define SK_CRASH() __debugbreak() |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 109 | # else |
mtklein | 3f73e8c | 2014-06-19 07:41:58 -0700 | [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 |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 115 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 116 | #endif |
| 117 | |
| 118 | /////////////////////////////////////////////////////////////////////////////// |
| 119 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 120 | #ifdef SK_BUILD_FOR_WIN |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 121 | # ifndef WIN32_LEAN_AND_MEAN |
| 122 | # define WIN32_LEAN_AND_MEAN |
| 123 | # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 124 | # endif |
| 125 | # ifndef NOMINMAX |
| 126 | # define NOMINMAX |
| 127 | # define NOMINMAX_WAS_LOCALLY_DEFINED |
| 128 | # endif |
| 129 | # |
| 130 | # include <windows.h> |
| 131 | # |
| 132 | # ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 133 | # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
| 134 | # undef WIN32_LEAN_AND_MEAN |
| 135 | # endif |
| 136 | # ifdef NOMINMAX_WAS_LOCALLY_DEFINED |
| 137 | # undef NOMINMAX_WAS_LOCALLY_DEFINED |
| 138 | # undef NOMINMAX |
| 139 | # endif |
| 140 | # |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 141 | # ifndef SK_A32_SHIFT |
| 142 | # define SK_A32_SHIFT 24 |
| 143 | # define SK_R32_SHIFT 16 |
| 144 | # define SK_G32_SHIFT 8 |
| 145 | # define SK_B32_SHIFT 0 |
| 146 | # endif |
| 147 | # |
mtklein | 3f73e8c | 2014-06-19 07:41:58 -0700 | [diff] [blame] | 148 | #endif |
| 149 | |
| 150 | #ifndef SK_ALWAYSBREAK |
benjaminwagner | 8a3760f | 2015-10-29 13:40:27 -0700 | [diff] [blame^] | 151 | # if defined(GOOGLE3) |
| 152 | void DebugWriteToStderr(const char*, void*); |
| 153 | void DumpStackTrace(int skip_count, void w(const char*, void*), |
| 154 | void* arg); |
| 155 | # define SK_ALWAYSBREAK(cond) do { \ |
| 156 | if (cond) break; \ |
| 157 | SkNO_RETURN_HINT(); \ |
| 158 | SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, #cond); \ |
| 159 | DumpStackTrace(0, DebugWriteToStderr, nullptr); \ |
| 160 | SK_CRASH(); \ |
| 161 | } while (false) |
| 162 | # elif defined(SK_DEBUG) |
mtklein | 3f73e8c | 2014-06-19 07:41:58 -0700 | [diff] [blame] | 163 | # define SK_ALWAYSBREAK(cond) do { \ |
| 164 | if (cond) break; \ |
| 165 | SkNO_RETURN_HINT(); \ |
| 166 | SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, #cond); \ |
| 167 | SK_CRASH(); \ |
| 168 | } while (false) |
| 169 | # else |
| 170 | # define SK_ALWAYSBREAK(cond) do { if (cond) break; SK_CRASH(); } while (false) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 171 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 172 | #endif |
| 173 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 174 | /** |
bsalomon@google.com | 2766118 | 2011-05-19 15:57:44 +0000 | [diff] [blame] | 175 | * We check to see if the SHIFT value has already been defined. |
| 176 | * if not, we define it ourself to some default values. We default to OpenGL |
| 177 | * order (in memory: r,g,b,a) |
| 178 | */ |
| 179 | #ifndef SK_A32_SHIFT |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 180 | # ifdef SK_CPU_BENDIAN |
| 181 | # define SK_R32_SHIFT 24 |
| 182 | # define SK_G32_SHIFT 16 |
| 183 | # define SK_B32_SHIFT 8 |
| 184 | # define SK_A32_SHIFT 0 |
| 185 | # else |
| 186 | # define SK_R32_SHIFT 0 |
| 187 | # define SK_G32_SHIFT 8 |
| 188 | # define SK_B32_SHIFT 16 |
| 189 | # define SK_A32_SHIFT 24 |
| 190 | # endif |
bsalomon@google.com | 2766118 | 2011-05-19 15:57:44 +0000 | [diff] [blame] | 191 | #endif |
| 192 | |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 193 | /** |
djsollen@google.com | 2b343cc | 2013-08-20 20:28:03 +0000 | [diff] [blame] | 194 | * SkColor has well defined shift values, but SkPMColor is configurable. This |
| 195 | * macro is a convenience that returns true if the shift values are equal while |
| 196 | * ignoring the machine's endianness. |
| 197 | */ |
| 198 | #define SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER \ |
| 199 | (SK_A32_SHIFT == 24 && SK_R32_SHIFT == 16 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 0) |
| 200 | |
| 201 | /** |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 202 | * SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. The |
| 203 | * relationship between the byte order and shift values depends on machine endianness. If the shift |
| 204 | * order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R channel on a little |
| 205 | * endian machine and the A channel on a big endian machine. Thus, given those shifts values, |
| 206 | * SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and |
| 207 | * SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine. |
| 208 | */ |
| 209 | #ifdef SK_CPU_BENDIAN |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 210 | # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 211 | (SK_ ## C3 ## 32_SHIFT == 0 && \ |
| 212 | SK_ ## C2 ## 32_SHIFT == 8 && \ |
| 213 | SK_ ## C1 ## 32_SHIFT == 16 && \ |
| 214 | SK_ ## C0 ## 32_SHIFT == 24) |
| 215 | #else |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 216 | # define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \ |
commit-bot@chromium.org | e4657ed | 2013-03-19 14:16:31 +0000 | [diff] [blame] | 217 | (SK_ ## C0 ## 32_SHIFT == 0 && \ |
| 218 | SK_ ## C1 ## 32_SHIFT == 8 && \ |
| 219 | SK_ ## C2 ## 32_SHIFT == 16 && \ |
| 220 | SK_ ## C3 ## 32_SHIFT == 24) |
| 221 | #endif |
| 222 | |
robertphillips@google.com | 0e6e8cc | 2013-08-15 13:43:23 +0000 | [diff] [blame] | 223 | ////////////////////////////////////////////////////////////////////////////////////////////// |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 224 | |
| 225 | #if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32 |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 226 | # ifdef free |
| 227 | # undef free |
| 228 | # endif |
| 229 | # include <crtdbg.h> |
| 230 | # undef free |
| 231 | # |
| 232 | # ifdef SK_DEBUGx |
| 233 | # if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus) |
| 234 | void * operator new( |
| 235 | size_t cb, |
| 236 | int nBlockUse, |
| 237 | const char * szFileName, |
| 238 | int nLine, |
| 239 | int foo |
| 240 | ); |
| 241 | void * operator new[]( |
| 242 | size_t cb, |
| 243 | int nBlockUse, |
| 244 | const char * szFileName, |
| 245 | int nLine, |
| 246 | int foo |
| 247 | ); |
| 248 | void operator delete( |
| 249 | void *pUserData, |
| 250 | int, const char*, int, int |
| 251 | ); |
| 252 | void operator delete( |
| 253 | void *pUserData |
| 254 | ); |
| 255 | void operator delete[]( void * p ); |
| 256 | # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0) |
| 257 | # else |
| 258 | # define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) |
| 259 | # endif |
| 260 | # define new DEBUG_CLIENTBLOCK |
| 261 | # else |
| 262 | # define DEBUG_CLIENTBLOCK |
| 263 | # endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 264 | #endif |
| 265 | |
tomhudson@google.com | 1341304 | 2011-10-03 16:01:10 +0000 | [diff] [blame] | 266 | ////////////////////////////////////////////////////////////////////// |
| 267 | |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 268 | #if !defined(SK_UNUSED) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 269 | # define SK_UNUSED SK_ATTRIBUTE(unused) |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 270 | #endif |
| 271 | |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 272 | #if !defined(SK_ATTR_DEPRECATED) |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 273 | // FIXME: we ignore msg for now... |
| 274 | # define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated) |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 275 | #endif |
| 276 | |
commit-bot@chromium.org | d70fa20 | 2014-04-24 21:51:58 +0000 | [diff] [blame] | 277 | #if !defined(SK_ATTR_EXTERNALLY_DEPRECATED) |
| 278 | # if !defined(SK_INTERNAL) |
| 279 | # define SK_ATTR_EXTERNALLY_DEPRECATED(msg) SK_ATTR_DEPRECATED(msg) |
| 280 | # else |
| 281 | # define SK_ATTR_EXTERNALLY_DEPRECATED(msg) |
| 282 | # endif |
| 283 | #endif |
| 284 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 285 | /** |
| 286 | * If your judgment is better than the compiler's (i.e. you've profiled it), |
| 287 | * you can use SK_ALWAYS_INLINE to force inlining. E.g. |
| 288 | * inline void someMethod() { ... } // may not be inlined |
| 289 | * SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined |
| 290 | */ |
mtklein@google.com | 1950d5f | 2013-11-22 16:56:22 +0000 | [diff] [blame] | 291 | #if !defined(SK_ALWAYS_INLINE) |
| 292 | # if defined(SK_BUILD_FOR_WIN) |
| 293 | # define SK_ALWAYS_INLINE __forceinline |
| 294 | # else |
| 295 | # define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline |
| 296 | # endif |
| 297 | #endif |
| 298 | |
mtklein | cd1930d | 2015-07-21 12:39:57 -0700 | [diff] [blame] | 299 | #if defined(SK_BUILD_FOR_WIN) |
| 300 | #define SK_VECTORCALL __vectorcall |
| 301 | #elif defined(SK_CPU_ARM32) |
| 302 | #define SK_VECTORCALL __attribute__((pcs("aapcs-vfp"))) |
| 303 | #else |
| 304 | #define SK_VECTORCALL |
| 305 | #endif |
| 306 | |
bungeman@google.com | 5ebbbe5 | 2013-08-06 18:32:29 +0000 | [diff] [blame] | 307 | ////////////////////////////////////////////////////////////////////// |
| 308 | |
mtklein | 6885a1e | 2015-10-27 13:06:47 -0700 | [diff] [blame] | 309 | #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1 |
mtklein | 72815e9 | 2015-10-28 09:52:20 -0700 | [diff] [blame] | 310 | #define SK_PREFETCH(ptr) _mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0) |
| 311 | #define SK_WRITE_PREFETCH(ptr) _mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0) |
mtklein | 6885a1e | 2015-10-27 13:06:47 -0700 | [diff] [blame] | 312 | #elif defined(__GNUC__) |
| 313 | #define SK_PREFETCH(ptr) __builtin_prefetch(ptr) |
| 314 | #define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1) |
commit-bot@chromium.org | fedf13d | 2013-11-05 15:03:26 +0000 | [diff] [blame] | 315 | #else |
mtklein | 6885a1e | 2015-10-27 13:06:47 -0700 | [diff] [blame] | 316 | #define SK_PREFETCH(ptr) |
| 317 | #define SK_WRITE_PREFETCH(ptr) |
commit-bot@chromium.org | fedf13d | 2013-11-05 15:03:26 +0000 | [diff] [blame] | 318 | #endif |
| 319 | |
| 320 | ////////////////////////////////////////////////////////////////////// |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 321 | |
senorblanco@chromium.org | 3a67a66 | 2012-07-09 18:22:08 +0000 | [diff] [blame] | 322 | #ifndef SK_PRINTF_LIKE |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 323 | # if defined(__clang__) || defined(__GNUC__) |
| 324 | # define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B)))) |
| 325 | # else |
| 326 | # define SK_PRINTF_LIKE(A, B) |
| 327 | # endif |
senorblanco@chromium.org | 3a67a66 | 2012-07-09 18:22:08 +0000 | [diff] [blame] | 328 | #endif |
| 329 | |
| 330 | ////////////////////////////////////////////////////////////////////// |
| 331 | |
| 332 | #ifndef SK_SIZE_T_SPECIFIER |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 333 | # if defined(_MSC_VER) |
| 334 | # define SK_SIZE_T_SPECIFIER "%Iu" |
| 335 | # else |
| 336 | # define SK_SIZE_T_SPECIFIER "%zu" |
| 337 | # endif |
senorblanco@chromium.org | 3a67a66 | 2012-07-09 18:22:08 +0000 | [diff] [blame] | 338 | #endif |
| 339 | |
| 340 | ////////////////////////////////////////////////////////////////////// |
| 341 | |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 342 | #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 343 | # define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1 |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 344 | #endif |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 345 | |
bungeman@google.com | d9947f6 | 2013-12-18 15:27:39 +0000 | [diff] [blame] | 346 | ////////////////////////////////////////////////////////////////////// |
| 347 | |
derekf | 29dda80 | 2014-10-01 10:52:52 -0700 | [diff] [blame] | 348 | #ifndef SK_EGL |
borenet | 4808757 | 2015-04-02 12:16:36 -0700 | [diff] [blame] | 349 | # if defined(SK_BUILD_FOR_ANDROID) |
derekf | 29dda80 | 2014-10-01 10:52:52 -0700 | [diff] [blame] | 350 | # define SK_EGL 1 |
| 351 | # else |
| 352 | # define SK_EGL 0 |
| 353 | # endif |
| 354 | #endif |
bungeman@google.com | 4770a3b | 2014-04-10 22:26:29 +0000 | [diff] [blame] | 355 | |
| 356 | ////////////////////////////////////////////////////////////////////// |
| 357 | |
| 358 | #if defined(SK_GAMMA_EXPONENT) && defined(SK_GAMMA_SRGB) |
| 359 | # error "cannot define both SK_GAMMA_EXPONENT and SK_GAMMA_SRGB" |
| 360 | #elif defined(SK_GAMMA_SRGB) |
| 361 | # define SK_GAMMA_EXPONENT (0.0f) |
| 362 | #elif !defined(SK_GAMMA_EXPONENT) |
| 363 | # define SK_GAMMA_EXPONENT (2.2f) |
| 364 | #endif |
| 365 | |
joshualitt | 3f655f3 | 2015-04-29 10:01:22 -0700 | [diff] [blame] | 366 | ////////////////////////////////////////////////////////////////////// |
| 367 | |
| 368 | #ifndef GR_TEST_UTILS |
| 369 | # define GR_TEST_UTILS 1 |
| 370 | #endif |
| 371 | |
bungeman@google.com | 7fd1f50 | 2013-12-04 16:40:42 +0000 | [diff] [blame] | 372 | #endif // SkPostConfig_DEFINED |