epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrConfig_DEFINED |
| 12 | #define GrConfig_DEFINED |
| 13 | |
robertphillips@google.com | 5955202 | 2012-08-31 13:07:37 +0000 | [diff] [blame] | 14 | #include "SkTypes.h" |
| 15 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 16 | /////////////////////////////////////////////////////////////////////////////// |
| 17 | // preconfig section: |
| 18 | // |
| 19 | // All the work before including GrUserConfig.h should center around guessing |
| 20 | // what platform we're on, and defining low-level symbols based on that. |
| 21 | // |
| 22 | // A build environment may have already defined symbols, so we first check |
| 23 | // for that |
| 24 | // |
| 25 | |
| 26 | // hack to ensure we know what sort of Apple platform we're on |
| 27 | #if defined(__APPLE_CPP__) || defined(__APPLE_CC__) |
| 28 | #include <TargetConditionals.h> |
| 29 | #endif |
| 30 | |
| 31 | /** |
| 32 | * Gr defines are set to 0 or 1, rather than being undefined or defined |
| 33 | */ |
| 34 | |
robertphillips@google.com | 5955202 | 2012-08-31 13:07:37 +0000 | [diff] [blame] | 35 | #if !defined(GR_CACHE_STATS) |
bsalomon | 24234fe | 2014-10-24 09:34:41 -0700 | [diff] [blame] | 36 | #ifdef SK_DEVELOPER |
| 37 | #define GR_CACHE_STATS 1 |
| 38 | #else |
| 39 | #define GR_CACHE_STATS 0 |
| 40 | #endif |
robertphillips@google.com | 5955202 | 2012-08-31 13:07:37 +0000 | [diff] [blame] | 41 | #endif |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 42 | |
robertphillips | 754f4e9 | 2014-09-18 13:52:08 -0700 | [diff] [blame] | 43 | #if !defined(GR_GPU_STATS) |
bsalomon | 24234fe | 2014-10-24 09:34:41 -0700 | [diff] [blame] | 44 | #ifdef SK_DEVELOPER |
| 45 | #define GR_GPU_STATS 1 |
| 46 | #else |
| 47 | #define GR_GPU_STATS 0 |
| 48 | #endif |
robertphillips | 754f4e9 | 2014-09-18 13:52:08 -0700 | [diff] [blame] | 49 | #endif |
| 50 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 51 | /////////////////////////////////////////////////////////////////////////////// |
| 52 | /////////////////////////////////////////////////////////////////////////////// |
| 53 | |
commit-bot@chromium.org | 4382330 | 2013-09-25 20:57:51 +0000 | [diff] [blame] | 54 | #if defined(SK_BUILD_FOR_WIN32) |
senorblanco@chromium.org | 9d18b78 | 2011-03-28 20:47:09 +0000 | [diff] [blame] | 55 | // VC8 doesn't support stdint.h, so we define those types here. |
| 56 | typedef signed char int8_t; |
| 57 | typedef unsigned char uint8_t; |
| 58 | typedef short int16_t; |
| 59 | typedef unsigned short uint16_t; |
| 60 | typedef int int32_t; |
| 61 | typedef unsigned uint32_t; |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 62 | typedef __int64 int64_t; |
| 63 | typedef unsigned __int64 uint64_t; |
senorblanco@chromium.org | 9d18b78 | 2011-03-28 20:47:09 +0000 | [diff] [blame] | 64 | #else |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 65 | /* |
bsalomon@google.com | 9182610 | 2011-03-21 19:51:57 +0000 | [diff] [blame] | 66 | * Include stdint.h with defines that trigger declaration of C99 limit/const |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 67 | * macros here before anyone else has a chance to include stdint.h without |
bsalomon@google.com | 9182610 | 2011-03-21 19:51:57 +0000 | [diff] [blame] | 68 | * these. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 69 | */ |
senorblanco@chromium.org | f9a1455 | 2012-11-06 18:36:33 +0000 | [diff] [blame] | 70 | #ifndef __STDC_LIMIT_MACROS |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 71 | #define __STDC_LIMIT_MACROS |
senorblanco@chromium.org | f9a1455 | 2012-11-06 18:36:33 +0000 | [diff] [blame] | 72 | #endif |
| 73 | #ifndef __STDC_CONSTANT_MACROS |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 74 | #define __STDC_CONSTANT_MACROS |
senorblanco@chromium.org | f9a1455 | 2012-11-06 18:36:33 +0000 | [diff] [blame] | 75 | #endif |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 76 | #include <stdint.h> |
senorblanco@chromium.org | 9d18b78 | 2011-03-28 20:47:09 +0000 | [diff] [blame] | 77 | #endif |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 78 | |
| 79 | /* |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 80 | * The "user config" file can be empty, and everything should work. It is |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 81 | * meant to store a given platform/client's overrides of our guess-work. |
| 82 | * |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 83 | * A alternate user config file can be specified by defining |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 84 | * GR_USER_CONFIG_FILE. It should be defined relative to GrConfig.h |
| 85 | * |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 86 | * e.g. it can change the BUILD target or supply its own defines for anything |
robertphillips@google.com | 4e5559a | 2013-10-30 17:04:16 +0000 | [diff] [blame] | 87 | * else (e.g. GR_DEFAULT_RESOURCE_CACHE_MB_LIMIT) |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 88 | */ |
| 89 | #if !defined(GR_USER_CONFIG_FILE) |
| 90 | #include "GrUserConfig.h" |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 91 | #else |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 92 | #include GR_USER_CONFIG_FILE |
| 93 | #endif |
| 94 | |
| 95 | |
| 96 | /////////////////////////////////////////////////////////////////////////////// |
| 97 | /////////////////////////////////////////////////////////////////////////////// |
| 98 | // postconfig section: |
| 99 | // |
bsalomon@google.com | 9182610 | 2011-03-21 19:51:57 +0000 | [diff] [blame] | 100 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 101 | /** |
| 102 | * GR_STRING makes a string of X where X is expanded before conversion to a string |
| 103 | * if X itself contains macros. |
| 104 | */ |
| 105 | #define GR_STRING(X) GR_STRING_IMPL(X) |
| 106 | #define GR_STRING_IMPL(X) #X |
| 107 | |
| 108 | /** |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 109 | * GR_CONCAT concatenates X and Y where each is expanded before |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 110 | * contanenation if either contains macros. |
| 111 | */ |
| 112 | #define GR_CONCAT(X,Y) GR_CONCAT_IMPL(X,Y) |
| 113 | #define GR_CONCAT_IMPL(X,Y) X##Y |
| 114 | |
| 115 | /** |
| 116 | * Creates a string of the form "<filename>(<linenumber>) : " |
| 117 | */ |
| 118 | #define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : " |
| 119 | |
| 120 | /** |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 121 | * Compilers have different ways of issuing warnings. This macro |
| 122 | * attempts to abstract them, but may need to be specialized for your |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 123 | * particular compiler. |
| 124 | * To insert compiler warnings use "#pragma message GR_WARN(<string>)" |
| 125 | */ |
reed@google.com | c921843 | 2011-01-25 19:05:12 +0000 | [diff] [blame] | 126 | #if defined(_MSC_VER) && _MSC_VER |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 127 | #define GR_WARN(MSG) (GR_FILE_AND_LINE_STR "WARNING: " MSG) |
| 128 | #else//__GNUC__ - may need other defines for different compilers |
| 129 | #define GR_WARN(MSG) ("WARNING: " MSG) |
| 130 | #endif |
| 131 | |
| 132 | /** |
| 133 | * GR_ALWAYSBREAK is an unconditional break in all builds. |
| 134 | */ |
| 135 | #if !defined(GR_ALWAYSBREAK) |
commit-bot@chromium.org | 4382330 | 2013-09-25 20:57:51 +0000 | [diff] [blame] | 136 | #if defined(SK_BUILD_FOR_WIN32) |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 137 | #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak() |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 138 | #else |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 139 | // TODO: do other platforms really not have continuable breakpoints? |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 140 | // sign extend for 64bit architectures to be sure this is |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 141 | // in the high address range |
bsalomon@google.com | 0442380 | 2011-11-23 21:25:35 +0000 | [diff] [blame] | 142 | #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 143 | #endif |
| 144 | #endif |
| 145 | |
| 146 | /** |
| 147 | * GR_DEBUGBREAK is an unconditional break in debug builds. |
| 148 | */ |
| 149 | #if !defined(GR_DEBUGBREAK) |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 150 | #ifdef SK_DEBUG |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 151 | #define GR_DEBUGBREAK GR_ALWAYSBREAK |
| 152 | #else |
| 153 | #define GR_DEBUGBREAK |
| 154 | #endif |
| 155 | #endif |
| 156 | |
| 157 | /** |
| 158 | * GR_ALWAYSASSERT is an assertion in all builds. |
| 159 | */ |
| 160 | #if !defined(GR_ALWAYSASSERT) |
| 161 | #define GR_ALWAYSASSERT(COND) \ |
| 162 | do { \ |
| 163 | if (!(COND)) { \ |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 164 | SkDebugf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \ |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 165 | GR_ALWAYSBREAK; \ |
| 166 | } \ |
| 167 | } while (false) |
| 168 | #endif |
| 169 | |
| 170 | /** |
| 171 | * GR_DEBUGASSERT is an assertion in debug builds only. |
| 172 | */ |
| 173 | #if !defined(GR_DEBUGASSERT) |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 174 | #ifdef SK_DEBUG |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 175 | #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND) |
| 176 | #else |
| 177 | #define GR_DEBUGASSERT(COND) |
| 178 | #endif |
| 179 | #endif |
| 180 | |
| 181 | /** |
| 182 | * Prettier forms of the above macros. |
| 183 | */ |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 184 | #define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND) |
| 185 | |
| 186 | /** |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 187 | * GR_STATIC_ASSERT is a compile time assertion. Depending on the platform |
| 188 | * it may print the message in the compiler log. Obviously, the condition must |
| 189 | * be evaluatable at compile time. |
| 190 | */ |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 191 | // VS 2010 and GCC compiled with c++0x or gnu++0x support the new |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 192 | // static_assert. |
| 193 | #if !defined(GR_STATIC_ASSERT) |
reed@google.com | c921843 | 2011-01-25 19:05:12 +0000 | [diff] [blame] | 194 | #if (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__) |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 195 | #define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug") |
| 196 | #else |
| 197 | template <bool> class GR_STATIC_ASSERT_FAILURE; |
| 198 | template <> class GR_STATIC_ASSERT_FAILURE<true> {}; |
| 199 | #define GR_STATIC_ASSERT(CONDITION) \ |
| 200 | enum {GR_CONCAT(X,__LINE__) = \ |
| 201 | sizeof(GR_STATIC_ASSERT_FAILURE<CONDITION>)} |
| 202 | #endif |
| 203 | #endif |
| 204 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 205 | /** |
commit-bot@chromium.org | 8341eb7 | 2014-05-07 20:51:05 +0000 | [diff] [blame] | 206 | * GR_GEOM_BUFFER_MAP_THRESHOLD gives a threshold (in bytes) for when Gr should |
| 207 | * map a GrGeometryBuffer to update its contents. It will use map() if the |
bsalomon@google.com | 96e96df | 2011-10-10 14:49:29 +0000 | [diff] [blame] | 208 | * size of the updated region is greater than the threshold. Otherwise it will |
| 209 | * use updateData(). |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 210 | */ |
commit-bot@chromium.org | 8341eb7 | 2014-05-07 20:51:05 +0000 | [diff] [blame] | 211 | #if !defined(GR_GEOM_BUFFER_MAP_THRESHOLD) |
| 212 | #define GR_GEOM_BUFFER_MAP_THRESHOLD (1 << 15) |
bsalomon@google.com | 1c13c96 | 2011-02-14 16:51:21 +0000 | [diff] [blame] | 213 | #endif |
| 214 | |
djsollen@google.com | 42041e6 | 2012-10-29 19:24:45 +0000 | [diff] [blame] | 215 | /** |
sugoi@google.com | e3453cb | 2013-01-07 14:26:40 +0000 | [diff] [blame] | 216 | * GR_STROKE_PATH_RENDERING controls whether or not the GrStrokePathRenderer can be selected |
| 217 | * as a path renderer. GrStrokePathRenderer is currently an experimental path renderer. |
| 218 | */ |
| 219 | #if !defined(GR_STROKE_PATH_RENDERING) |
| 220 | #define GR_STROKE_PATH_RENDERING 0 |
| 221 | #endif |
| 222 | |
george | b62508b | 2014-08-12 18:00:47 -0700 | [diff] [blame] | 223 | /** |
| 224 | * GR_ALWAYS_ALLOCATE_ON_HEAP determines whether various temporary buffers created |
| 225 | * in the GPU backend are always allocated on the heap or are allowed to be |
| 226 | * allocated on the stack for smaller memory requests. |
| 227 | * |
| 228 | * This is only used for memory buffers that are created and then passed through to the |
| 229 | * 3D API (e.g. as texture or geometry data) |
| 230 | */ |
| 231 | #if !defined(GR_ALWAYS_ALLOCATE_ON_HEAP) |
| 232 | #define GR_ALWAYS_ALLOCATE_ON_HEAP 0 |
| 233 | #endif |
| 234 | |
egdaniel | bdad9c3 | 2015-03-05 12:19:17 -0800 | [diff] [blame] | 235 | /** |
| 236 | * GR_FORCE_GPU_TRACE_DEBUGGING will force gpu tracing/debug markers to be turned on. The trace |
| 237 | * markers will be printed out instead of making the backend calls to push and pop them. |
| 238 | */ |
| 239 | #if !defined(GR_FORCE_GPU_TRACE_DEBUGGING) |
| 240 | #define GR_FORCE_GPU_TRACE_DEBUGGING 0 |
| 241 | #endif |
| 242 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 243 | #endif |