Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrConfig.h
1 
2 /*
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.
7  */
8 
9 
10 
11 #ifndef GrConfig_DEFINED
12 #define GrConfig_DEFINED
13 
14 #include "SkTypes.h"
15 
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 
35 #if !defined(GR_CACHE_STATS)
36  #if defined(SK_DEBUG) || defined(SK_DUMP_STATS)
37  #define GR_CACHE_STATS 1
38  #else
39  #define GR_CACHE_STATS 0
40  #endif
41 #endif
42 
43 #if !defined(GR_GPU_STATS)
44  #if defined(SK_DEBUG) || defined(SK_DUMP_STATS)
45  #define GR_GPU_STATS 1
46  #else
47  #define GR_GPU_STATS 0
48  #endif
49 #endif
50 
53 
54 #if defined(SK_BUILD_FOR_WIN32)
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;
62 typedef __int64 int64_t;
63 typedef unsigned __int64 uint64_t;
64 #else
65 /*
66  * Include stdint.h with defines that trigger declaration of C99 limit/const
67  * macros here before anyone else has a chance to include stdint.h without
68  * these.
69  */
70 #ifndef __STDC_LIMIT_MACROS
71 #define __STDC_LIMIT_MACROS
72 #endif
73 #ifndef __STDC_CONSTANT_MACROS
74 #define __STDC_CONSTANT_MACROS
75 #endif
76 #include <stdint.h>
77 #endif
78 
81 // postconfig section:
82 //
83 
88 #define GR_STRING(X) GR_STRING_IMPL(X)
89 #define GR_STRING_IMPL(X) #X
90 
95 #define GR_CONCAT(X,Y) GR_CONCAT_IMPL(X,Y)
96 #define GR_CONCAT_IMPL(X,Y) X##Y
97 
101 #define GR_FILE_AND_LINE_STR __FILE__ "(" GR_STRING(__LINE__) ") : "
102 
109 #if defined(_MSC_VER)
110  #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 
118 #if !defined(GR_ALWAYSBREAK)
119  #if defined(SK_BUILD_FOR_WIN32)
120  #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); __debugbreak()
121  #else
122  // TODO: do other platforms really not have continuable breakpoints?
123  // sign extend for 64bit architectures to be sure this is
124  // in the high address range
125  #define GR_ALWAYSBREAK SkNO_RETURN_HINT(); *((int*)(int64_t)(int32_t)0xbeefcafe) = 0;
126  #endif
127 #endif
128 
132 #if !defined(GR_DEBUGBREAK)
133  #ifdef SK_DEBUG
134  #define GR_DEBUGBREAK GR_ALWAYSBREAK
135  #else
136  #define GR_DEBUGBREAK
137  #endif
138 #endif
139 
143 #if !defined(GR_ALWAYSASSERT)
144  #define GR_ALWAYSASSERT(COND) \
145  do { \
146  if (!(COND)) { \
147  SkDebugf("%s %s failed\n", GR_FILE_AND_LINE_STR, #COND); \
148  GR_ALWAYSBREAK; \
149  } \
150  } while (false)
151 #endif
152 
156 #if !defined(GR_DEBUGASSERT)
157  #ifdef SK_DEBUG
158  #define GR_DEBUGASSERT(COND) GR_ALWAYSASSERT(COND)
159  #else
160  #define GR_DEBUGASSERT(COND)
161  #endif
162 #endif
163 
167 #define GrAlwaysAssert(COND) GR_ALWAYSASSERT(COND)
168 
174 #define GR_STATIC_ASSERT(CONDITION) static_assert(CONDITION, "bug")
175 
176 #endif