blob: acdff3af2bcfecb2386c911e3e4221e80f40e6a1 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrConfig_DEFINED
12#define GrConfig_DEFINED
13
robertphillips@google.com59552022012-08-31 13:07:37 +000014#include "SkTypes.h"
15
reed@google.comac10a2d2010-12-22 21:39:39 +000016///////////////////////////////////////////////////////////////////////////////
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.com59552022012-08-31 13:07:37 +000035#if !defined(GR_CACHE_STATS)
djsollenefe46d22016-04-29 06:41:35 -070036 #if defined(SK_DEBUG) || defined(SK_DUMP_STATS)
bsalomon24234fe2014-10-24 09:34:41 -070037 #define GR_CACHE_STATS 1
38 #else
39 #define GR_CACHE_STATS 0
40 #endif
robertphillips@google.com59552022012-08-31 13:07:37 +000041#endif
reed@google.comac10a2d2010-12-22 21:39:39 +000042
robertphillips754f4e92014-09-18 13:52:08 -070043#if !defined(GR_GPU_STATS)
djsollenefe46d22016-04-29 06:41:35 -070044 #if defined(SK_DEBUG) || defined(SK_DUMP_STATS)
bsalomon24234fe2014-10-24 09:34:41 -070045 #define GR_GPU_STATS 1
46 #else
47 #define GR_GPU_STATS 0
48 #endif
robertphillips754f4e92014-09-18 13:52:08 -070049#endif
50
reed@google.comac10a2d2010-12-22 21:39:39 +000051///////////////////////////////////////////////////////////////////////////////
52///////////////////////////////////////////////////////////////////////////////
53
commit-bot@chromium.org43823302013-09-25 20:57:51 +000054#if defined(SK_BUILD_FOR_WIN32)
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000055// VC8 doesn't support stdint.h, so we define those types here.
56typedef signed char int8_t;
57typedef unsigned char uint8_t;
58typedef short int16_t;
59typedef unsigned short uint16_t;
60typedef int int32_t;
61typedef unsigned uint32_t;
bsalomon@google.com4be283f2011-04-19 21:15:09 +000062typedef __int64 int64_t;
63typedef unsigned __int64 uint64_t;
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000064#else
reed@google.comac10a2d2010-12-22 21:39:39 +000065/*
bsalomon@google.com91826102011-03-21 19:51:57 +000066 * Include stdint.h with defines that trigger declaration of C99 limit/const
rmistry@google.comfbfcd562012-08-23 18:09:54 +000067 * macros here before anyone else has a chance to include stdint.h without
bsalomon@google.com91826102011-03-21 19:51:57 +000068 * these.
reed@google.comac10a2d2010-12-22 21:39:39 +000069 */
senorblanco@chromium.orgf9a14552012-11-06 18:36:33 +000070#ifndef __STDC_LIMIT_MACROS
reed@google.comac10a2d2010-12-22 21:39:39 +000071#define __STDC_LIMIT_MACROS
senorblanco@chromium.orgf9a14552012-11-06 18:36:33 +000072#endif
73#ifndef __STDC_CONSTANT_MACROS
reed@google.comac10a2d2010-12-22 21:39:39 +000074#define __STDC_CONSTANT_MACROS
senorblanco@chromium.orgf9a14552012-11-06 18:36:33 +000075#endif
reed@google.comac10a2d2010-12-22 21:39:39 +000076#include <stdint.h>
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000077#endif
reed@google.comac10a2d2010-12-22 21:39:39 +000078
reed@google.comac10a2d2010-12-22 21:39:39 +000079///////////////////////////////////////////////////////////////////////////////
80///////////////////////////////////////////////////////////////////////////////
81// postconfig section:
82//
bsalomon@google.com91826102011-03-21 19:51:57 +000083
reed@google.comac10a2d2010-12-22 21:39:39 +000084/**
85 * GR_STRING makes a string of X where X is expanded before conversion to a string
86 * if X itself contains macros.
87 */
88#define GR_STRING(X) GR_STRING_IMPL(X)
89#define GR_STRING_IMPL(X) #X
90
91/**
bsalomon@google.com1c13c962011-02-14 16:51:21 +000092 * GR_CONCAT concatenates X and Y where each is expanded before
reed@google.comac10a2d2010-12-22 21:39:39 +000093 * contanenation if either contains macros.
94 */
95#define GR_CONCAT(X,Y) GR_CONCAT_IMPL(X,Y)
96#define GR_CONCAT_IMPL(X,Y) X##Y
97
98/**
99 * Creates a string of the form "<filename>(<linenumber>) : "
100 */
101#define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
102
103/**
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000104 * Compilers have different ways of issuing warnings. This macro
105 * attempts to abstract them, but may need to be specialized for your
reed@google.comac10a2d2010-12-22 21:39:39 +0000106 * particular compiler.
107 * To insert compiler warnings use "#pragma message GR_WARN(<string>)"
108 */
bungemand7dc76f2016-03-10 11:14:40 -0800109#if defined(_MSC_VER)
reed@google.comac10a2d2010-12-22 21:39:39 +0000110 #define GR_WARN(MSG) (GR_FILE_AND_LINE_STR "WARNING: " MSG)
111#else//__GNUC__ - may need other defines for different compilers
112 #define GR_WARN(MSG) ("WARNING: " MSG)
113#endif
114
115/**
116 * GR_ALWAYSBREAK is an unconditional break in all builds.
117 */
118#if !defined(GR_ALWAYSBREAK)
commit-bot@chromium.org43823302013-09-25 20:57:51 +0000119 #if defined(SK_BUILD_FOR_WIN32)
bsalomon@google.com04423802011-11-23 21:25:35 +0000120 #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak()
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000121 #else
reed@google.comac10a2d2010-12-22 21:39:39 +0000122 // TODO: do other platforms really not have continuable breakpoints?
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000123 // sign extend for 64bit architectures to be sure this is
reed@google.comac10a2d2010-12-22 21:39:39 +0000124 // in the high address range
bsalomon@google.com04423802011-11-23 21:25:35 +0000125 #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000126 #endif
127#endif
128
129/**
130 * GR_DEBUGBREAK is an unconditional break in debug builds.
131 */
132#if !defined(GR_DEBUGBREAK)
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +0000133 #ifdef SK_DEBUG
reed@google.comac10a2d2010-12-22 21:39:39 +0000134 #define GR_DEBUGBREAK GR_ALWAYSBREAK
135 #else
136 #define GR_DEBUGBREAK
137 #endif
138#endif
139
140/**
141 * GR_ALWAYSASSERT is an assertion in all builds.
142 */
143#if !defined(GR_ALWAYSASSERT)
144 #define GR_ALWAYSASSERT(COND) \
145 do { \
146 if (!(COND)) { \
tfarina38406c82014-10-31 07:11:12 -0700147 SkDebugf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \
reed@google.comac10a2d2010-12-22 21:39:39 +0000148 GR_ALWAYSBREAK; \
149 } \
150 } while (false)
151#endif
152
153/**
154 * GR_DEBUGASSERT is an assertion in debug builds only.
155 */
156#if !defined(GR_DEBUGASSERT)
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +0000157 #ifdef SK_DEBUG
reed@google.comac10a2d2010-12-22 21:39:39 +0000158 #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND)
159 #else
160 #define GR_DEBUGASSERT(COND)
161 #endif
162#endif
163
164/**
165 * Prettier forms of the above macros.
166 */
reed@google.comac10a2d2010-12-22 21:39:39 +0000167#define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND)
168
169/**
reed@google.comac10a2d2010-12-22 21:39:39 +0000170 * GR_STATIC_ASSERT is a compile time assertion. Depending on the platform
171 * it may print the message in the compiler log. Obviously, the condition must
172 * be evaluatable at compile time.
173 */
bungemand7dc76f2016-03-10 11:14:40 -0800174#define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug")
reed@google.comac10a2d2010-12-22 21:39:39 +0000175
joshualitt5651ee62016-01-11 10:39:11 -0800176/**
ethannicholas22793252016-01-30 09:59:10 -0800177 * Set to 1 to enable pixel local storage path rendering on supported devices.
178 */
179#if !defined(GR_ENABLE_PLS_PATH_RENDERING)
180 #define GR_ENABLE_PLS_PATH_RENDERING 0
181#endif
182
reed@google.comac10a2d2010-12-22 21:39:39 +0000183#endif