Skia
2DGraphicsLibrary
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
SkPostConfig.h
1
/*
2
* Copyright 2006 The Android Open Source Project
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
// IWYU pragma: private, include "SkTypes.h"
9
10
#ifndef SkPostConfig_DEFINED
11
#define SkPostConfig_DEFINED
12
13
#if defined(SK_BUILD_FOR_WIN32)
14
# define SK_BUILD_FOR_WIN
15
#endif
16
17
#if !defined(SK_DEBUG) && !defined(SK_RELEASE)
18
#ifdef NDEBUG
19
#define SK_RELEASE
20
#else
21
#define SK_DEBUG
22
#endif
23
#endif
24
25
#if defined(SK_DEBUG) && defined(SK_RELEASE)
26
# error "cannot define both SK_DEBUG and SK_RELEASE"
27
#elif !defined(SK_DEBUG) && !defined(SK_RELEASE)
28
# error "must define either SK_DEBUG or SK_RELEASE"
29
#endif
30
31
#if defined(SK_SUPPORT_UNITTEST) && !defined(SK_DEBUG)
32
# error "can't have unittests without debug"
33
#endif
34
39
#if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT)
40
# error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT"
41
#elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT)
42
# define SK_MSCALAR_IS_FLOAT
43
#endif
44
45
#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
46
# error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
47
#elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
48
# error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
49
#endif
50
54
#ifdef SK_A32_SHIFT
55
# if !defined(SK_R32_SHIFT) || !defined(SK_G32_SHIFT) || !defined(SK_B32_SHIFT)
56
# error "all or none of the 32bit SHIFT amounts must be defined"
57
# endif
58
#else
59
# if defined(SK_R32_SHIFT) || defined(SK_G32_SHIFT) || defined(SK_B32_SHIFT)
60
# error "all or none of the 32bit SHIFT amounts must be defined"
61
# endif
62
#endif
63
64
#if !defined(SK_HAS_COMPILER_FEATURE)
65
# if defined(__has_feature)
66
# define SK_HAS_COMPILER_FEATURE(x) __has_feature(x)
67
# else
68
# define SK_HAS_COMPILER_FEATURE(x) 0
69
# endif
70
#endif
71
72
#if !defined(SK_ATTRIBUTE)
73
# if defined(__clang__) || defined(__GNUC__)
74
# define SK_ATTRIBUTE(attr) __attribute__((attr))
75
# else
76
# define SK_ATTRIBUTE(attr)
77
# endif
78
#endif
79
80
// As usual, there are two ways to increase alignment... the MSVC way and the everyone-else way.
81
#ifndef SK_STRUCT_ALIGN
82
#ifdef _MSC_VER
83
#define SK_STRUCT_ALIGN(N) __declspec(align(N))
84
#else
85
#define SK_STRUCT_ALIGN(N) __attribute__((aligned(N)))
86
#endif
87
#endif
88
89
#if defined(_MSC_VER) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
90
#define SK_VECTORCALL __vectorcall
91
#elif defined(SK_CPU_ARM32) && defined(SK_ARM_HAS_NEON)
92
#define SK_VECTORCALL __attribute__((pcs("aapcs-vfp")))
93
#else
94
#define SK_VECTORCALL
95
#endif
96
97
#if !defined(SK_SUPPORT_GPU)
98
# define SK_SUPPORT_GPU 1
99
#endif
100
108
#if !defined(SkNO_RETURN_HINT)
109
# if SK_HAS_COMPILER_FEATURE(attribute_analyzer_noreturn)
110
static
inline
void
SkNO_RETURN_HINT() __attribute__((analyzer_noreturn));
111
static inline
void
SkNO_RETURN_HINT() {}
112
# else
113
# define SkNO_RETURN_HINT() do {} while (false)
114
# endif
115
#endif
116
118
119
// TODO(mdempsky): Move elsewhere as appropriate.
120
#include <new>
121
122
124
125
#ifdef SK_BUILD_FOR_WIN
126
# ifndef SK_A32_SHIFT
127
# define SK_A32_SHIFT 24
128
# define SK_R32_SHIFT 16
129
# define SK_G32_SHIFT 8
130
# define SK_B32_SHIFT 0
131
# endif
132
#
133
#endif
134
135
#if defined(GOOGLE3)
136
void
SkDebugfForDumpStackTrace(
const
char
* data,
void
* unused);
137
void
DumpStackTrace(
int
skip_count,
void
w(
const
char
*,
void
*),
void
* arg);
138
# define SK_DUMP_GOOGLE3_STACK() DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr)
139
#else
140
# define SK_DUMP_GOOGLE3_STACK()
141
#endif
142
143
#ifndef SK_ABORT
144
# define SK_ABORT(message) \
145
do { \
146
SkNO_RETURN_HINT(); \
147
SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, message); \
148
SK_DUMP_GOOGLE3_STACK(); \
149
sk_abort_no_print(); \
150
} while (false)
151
#endif
152
158
#ifndef SK_A32_SHIFT
159
# ifdef SK_CPU_BENDIAN
160
# define SK_R32_SHIFT 24
161
# define SK_G32_SHIFT 16
162
# define SK_B32_SHIFT 8
163
# define SK_A32_SHIFT 0
164
# else
165
# define SK_R32_SHIFT 0
166
# define SK_G32_SHIFT 8
167
# define SK_B32_SHIFT 16
168
# define SK_A32_SHIFT 24
169
# endif
170
#endif
171
177
#define SK_COLOR_MATCHES_PMCOLOR_BYTE_ORDER \
178
(SK_A32_SHIFT == 24 && SK_R32_SHIFT == 16 && SK_G32_SHIFT == 8 && SK_B32_SHIFT == 0)
179
188
#ifdef SK_CPU_BENDIAN
189
# define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
190
(SK_ ## C3 ## 32_SHIFT == 0 && \
191
SK_ ## C2 ## 32_SHIFT == 8 && \
192
SK_ ## C1 ## 32_SHIFT == 16 && \
193
SK_ ## C0 ## 32_SHIFT == 24)
194
#else
195
# define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3) \
196
(SK_ ## C0 ## 32_SHIFT == 0 && \
197
SK_ ## C1 ## 32_SHIFT == 8 && \
198
SK_ ## C2 ## 32_SHIFT == 16 && \
199
SK_ ## C3 ## 32_SHIFT == 24)
200
#endif
201
203
204
#if defined SK_DEBUG && defined SK_BUILD_FOR_WIN32
205
# ifdef free
206
# undef free
207
# endif
208
# include <crtdbg.h>
209
# undef free
210
#
211
# ifdef SK_DEBUGx
212
# if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
213
void
*
operator
new
(
214
size_t
cb,
215
int
nBlockUse,
216
const
char
* szFileName,
217
int
nLine,
218
int
foo
219
);
220
void
*
operator
new
[](
221
size_t
cb,
222
int
nBlockUse,
223
const
char
* szFileName,
224
int
nLine,
225
int
foo
226
);
227
void
operator
delete
(
228
void
*pUserData,
229
int,
const
char
*, int, int
230
);
231
void
operator
delete
(
232
void
*pUserData
233
);
234
void
operator
delete
[](
void
* p );
235
# define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
236
# else
237
# define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
238
# endif
239
# define new DEBUG_CLIENTBLOCK
240
# else
241
# define DEBUG_CLIENTBLOCK
242
# endif
243
#endif
244
246
247
#if !defined(SK_UNUSED)
248
# if defined(_MSC_VER)
249
# define SK_UNUSED __pragma(warning(suppress:4189))
250
# else
251
# define SK_UNUSED SK_ATTRIBUTE(unused)
252
# endif
253
#endif
254
255
#if !defined(SK_ATTR_DEPRECATED)
256
// FIXME: we ignore msg for now...
257
# define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated)
258
#endif
259
260
#if !defined(SK_ATTR_EXTERNALLY_DEPRECATED)
261
# if !defined(SK_INTERNAL)
262
# define SK_ATTR_EXTERNALLY_DEPRECATED(msg) SK_ATTR_DEPRECATED(msg)
263
# else
264
# define SK_ATTR_EXTERNALLY_DEPRECATED(msg)
265
# endif
266
#endif
267
274
#if !defined(SK_ALWAYS_INLINE)
275
# if defined(SK_BUILD_FOR_WIN)
276
# define SK_ALWAYS_INLINE __forceinline
277
# else
278
# define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline
279
# endif
280
#endif
281
286
#if !defined(SK_NEVER_INLINE)
287
# if defined(SK_BUILD_FOR_WIN)
288
# define SK_NEVER_INLINE __declspec(noinline)
289
# else
290
# define SK_NEVER_INLINE SK_ATTRIBUTE(noinline)
291
# endif
292
#endif
293
295
296
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
297
#define SK_PREFETCH(ptr) _mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0)
298
#define SK_WRITE_PREFETCH(ptr) _mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0)
299
#elif defined(__GNUC__)
300
#define SK_PREFETCH(ptr) __builtin_prefetch(ptr)
301
#define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1)
302
#else
303
#define SK_PREFETCH(ptr)
304
#define SK_WRITE_PREFETCH(ptr)
305
#endif
306
308
309
#ifndef SK_PRINTF_LIKE
310
# if defined(__clang__) || defined(__GNUC__)
311
# define SK_PRINTF_LIKE(A, B) __attribute__((format(printf, (A), (B))))
312
# else
313
# define SK_PRINTF_LIKE(A, B)
314
# endif
315
#endif
316
318
319
#ifndef SK_SIZE_T_SPECIFIER
320
# if defined(_MSC_VER)
321
# define SK_SIZE_T_SPECIFIER "%Iu"
322
# else
323
# define SK_SIZE_T_SPECIFIER "%zu"
324
# endif
325
#endif
326
328
329
#ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
330
# define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
331
#endif
332
334
335
#ifndef SK_EGL
336
# if defined(SK_BUILD_FOR_ANDROID)
337
# define SK_EGL 1
338
# else
339
# define SK_EGL 0
340
# endif
341
#endif
342
344
345
#if !defined(SK_GAMMA_EXPONENT)
346
#define SK_GAMMA_EXPONENT (0.0f) // SRGB
347
#endif
348
350
351
#ifndef GR_TEST_UTILS
352
# define GR_TEST_UTILS 1
353
#endif
354
356
357
#if defined(SK_HISTOGRAM_ENUMERATION) && defined(SK_HISTOGRAM_BOOLEAN)
358
# define SK_HISTOGRAMS_ENABLED 1
359
#else
360
# define SK_HISTOGRAMS_ENABLED 0
361
#endif
362
363
#ifndef SK_HISTOGRAM_BOOLEAN
364
# define SK_HISTOGRAM_BOOLEAN(name, value)
365
#endif
366
367
#ifndef SK_HISTOGRAM_ENUMERATION
368
# define SK_HISTOGRAM_ENUMERATION(name, value, boundary_value)
369
#endif
370
371
#endif // SkPostConfig_DEFINED