887d37ae9adb58b3947452b74aa22d3145b9fc18
[platform/framework/web/crosswalk.git] / src / skia / config / SkUserConfig.h
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef SkUserConfig_DEFINED
18 #define SkUserConfig_DEFINED
19
20 /*  SkTypes.h, the root of the public header files, does the following trick:
21
22     #include <SkPreConfig.h>
23     #include <SkUserConfig.h>
24     #include <SkPostConfig.h>
25
26     SkPreConfig.h runs first, and it is responsible for initializing certain
27     skia defines.
28
29     SkPostConfig.h runs last, and its job is to just check that the final
30     defines are consistent (i.e. that we don't have mutually conflicting
31     defines).
32
33     SkUserConfig.h (this file) runs in the middle. It gets to change or augment
34     the list of flags initially set in preconfig, and then postconfig checks
35     that everything still makes sense.
36
37     Below are optional defines that add, subtract, or change default behavior
38     in Skia. Your port can locally edit this file to enable/disable flags as
39     you choose, or these can be delared on your command line (i.e. -Dfoo).
40
41     By default, this include file will always default to having all of the flags
42     commented out, so including it will have no effect.
43 */
44
45 ///////////////////////////////////////////////////////////////////////////////
46
47 /*  Scalars (the fractional value type in skia) can be implemented either as
48     floats or 16.16 integers (fixed). Exactly one of these two symbols must be
49     defined.
50 */
51 //#define SK_SCALAR_IS_FLOAT
52 //#define SK_SCALAR_IS_FIXED
53
54
55 /*  Somewhat independent of how SkScalar is implemented, Skia also wants to know
56     if it can use floats at all. Naturally, if SK_SCALAR_IS_FLOAT is defined,
57     then so muse SK_CAN_USE_FLOAT, but if scalars are fixed, SK_CAN_USE_FLOAT
58     can go either way.
59  */
60 //#define SK_CAN_USE_FLOAT
61
62 /*  For some performance-critical scalar operations, skia will optionally work
63     around the standard float operators if it knows that the CPU does not have
64     native support for floats. If your environment uses software floating point,
65     define this flag.
66  */
67 //#define SK_SOFTWARE_FLOAT
68
69
70 /*  Skia has lots of debug-only code. Often this is just null checks or other
71     parameter checking, but sometimes it can be quite intrusive (e.g. check that
72     each 32bit pixel is in premultiplied form). This code can be very useful
73     during development, but will slow things down in a shipping product.
74
75     By default, these mutually exclusive flags are defined in SkPreConfig.h,
76     based on the presence or absence of NDEBUG, but that decision can be changed
77     here.
78  */
79 //#define SK_DEBUG
80 //#define SK_RELEASE
81
82
83 /*  If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
84     it will call SK_CRASH(). If this is not defined it, it is defined in
85     SkPostConfig.h to write to an illegal address
86  */
87 //#define SK_CRASH() *(int *)(uintptr_t)0 = 0
88
89
90 /*  preconfig will have attempted to determine the endianness of the system,
91     but you can change these mutually exclusive flags here.
92  */
93 //#define SK_CPU_BENDIAN
94 //#define SK_CPU_LENDIAN
95
96
97 /*  Some compilers don't support long long for 64bit integers. If yours does
98     not, define this to the appropriate type.
99  */
100 //#define SkLONGLONG int64_t
101
102
103 /*  Some envorinments do not suport writable globals (eek!). If yours does not,
104     define this flag.
105  */
106 //#define SK_USE_RUNTIME_GLOBALS
107
108 /*  If zlib is available and you want to support the flate compression
109     algorithm (used in PDF generation), define SK_ZLIB_INCLUDE to be the
110     include path.
111  */
112 //#define SK_ZLIB_INCLUDE <zlib.h>
113 #define SK_ZLIB_INCLUDE "third_party/zlib/zlib.h"
114
115 /*  Define this to allow PDF scalars above 32k.  The PDF/A spec doesn't allow
116     them, but modern PDF interpreters should handle them just fine.
117  */
118 //#define SK_ALLOW_LARGE_PDF_SCALARS
119
120 /*  Define this to provide font subsetter for font subsetting when generating
121     PDF documents.
122  */
123 #define SK_SFNTLY_SUBSETTER \
124     "third_party/sfntly/cpp/src/sample/chromium/font_subsetter.h"
125
126 /*  To write debug messages to a console, skia will call SkDebugf(...) following
127     printf conventions (e.g. const char* format, ...). If you want to redirect
128     this to something other than printf, define yours here
129  */
130 //#define SkDebugf(...)  MyFunction(__VA_ARGS__)
131
132
133 /*  If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
134     which will run additional self-tests at startup. These can take a long time,
135     so this flag is optional.
136  */
137 #ifdef SK_DEBUG
138 #define SK_SUPPORT_UNITTEST
139 #endif
140
141 /* If your system embeds skia and has complex event logging, define this
142    symbol to name a file that maps the following macros to your system's
143    equivalents:
144        SK_TRACE_EVENT0(event)
145        SK_TRACE_EVENT1(event, name1, value1)
146        SK_TRACE_EVENT2(event, name1, value1, name2, value2)
147    src/utils/SkDebugTrace.h has a trivial implementation that writes to
148    the debug output stream. If SK_USER_TRACE_INCLUDE_FILE is not defined,
149    SkTrace.h will define the above three macros to do nothing.
150 */
151 #undef SK_USER_TRACE_INCLUDE_FILE
152
153 // ===== Begin Chrome-specific definitions =====
154
155 #ifdef SK_DEBUG
156 #define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_debug.h"
157 #else
158 #define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_release.h"
159 #endif
160
161 #define SK_SCALAR_IS_FLOAT
162 #undef SK_SCALAR_IS_FIXED
163
164 #define SK_MSCALAR_IS_FLOAT
165 #undef SK_MSCALAR_IS_DOUBLE
166
167 #define GR_MAX_OFFSCREEN_AA_DIM     512
168
169 // Log the file and line number for assertions.
170 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, false, __VA_ARGS__)
171 SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
172                               const char* format, ...);
173
174 // Marking the debug print as "fatal" will cause a debug break, so we don't need
175 // a separate crash call here.
176 #define SK_DEBUGBREAK(cond) do { if (!(cond)) { \
177     SkDebugf_FileLine(__FILE__, __LINE__, true, \
178     "%s:%d: failed assertion \"%s\"\n", \
179     __FILE__, __LINE__, #cond); } } while (false)
180
181 #if !defined(ANDROID)   // On Android, we use the skia default settings.
182 #define SK_A32_SHIFT    24
183 #define SK_R32_SHIFT    16
184 #define SK_G32_SHIFT    8
185 #define SK_B32_SHIFT    0
186 #endif
187
188 #if defined(SK_BUILD_FOR_WIN32)
189
190 #define SK_BUILD_FOR_WIN
191
192 // Skia uses this deprecated bzero function to fill zeros into a string.
193 #define bzero(str, len) memset(str, 0, len)
194
195 #elif defined(SK_BUILD_FOR_MAC)
196
197 #define SK_CPU_LENDIAN
198 #undef  SK_CPU_BENDIAN
199
200 #elif defined(SK_BUILD_FOR_UNIX)
201
202 // Prefer FreeType's emboldening algorithm to Skia's
203 // TODO: skia used to just use hairline, but has improved since then, so
204 // we should revisit this choice...
205 #define SK_USE_FREETYPE_EMBOLDEN
206
207 #ifdef SK_CPU_BENDIAN
208 // Above we set the order for ARGB channels in registers. I suspect that, on
209 // big endian machines, you can keep this the same and everything will work.
210 // The in-memory order will be different, of course, but as long as everything
211 // is reading memory as words rather than bytes, it will all work. However, if
212 // you find that colours are messed up I thought that I would leave a helpful
213 // locator for you. Also see the comments in
214 // base/gfx/bitmap_platform_device_linux.h
215 #error Read the comment at this location
216 #endif
217
218 #endif
219
220 // The default crash macro writes to badbeef which can cause some strange
221 // problems. Instead, pipe this through to the logging function as a fatal
222 // assertion.
223 #define SK_CRASH() SkDebugf_FileLine(__FILE__, __LINE__, true, "SK_CRASH")
224
225 // Uncomment the following line to forward skia trace events to Chrome
226 // tracing.
227 // #define SK_USER_TRACE_INCLUDE_FILE "skia/ext/skia_trace_shim.h"
228
229 #ifndef SK_ATOMICS_PLATFORM_H
230 #  if defined(SK_BUILD_FOR_WIN)
231 #    define SK_ATOMICS_PLATFORM_H "third_party/skia/src/ports/SkAtomics_win.h"
232 #  elif defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
233 #    define SK_ATOMICS_PLATFORM_H "third_party/skia/src/ports/SkAtomics_android.h"
234 #  else
235 #    define SK_ATOMICS_PLATFORM_H "third_party/skia/src/ports/SkAtomics_sync.h"
236 #  endif
237 #endif
238
239 #ifndef SK_MUTEX_PLATFORM_H
240 #  if defined(SK_BUILD_FOR_WIN)
241 #    define SK_MUTEX_PLATFORM_H "third_party/skia/src/ports/SkMutex_win.h"
242 #  else
243 #    define SK_MUTEX_PLATFORM_H "third_party/skia/src/ports/SkMutex_pthread.h"
244 #  endif
245 #endif
246
247 // These flags are no longer defined in Skia, but we have them (temporarily)
248 // until we update our call-sites (typically these are for API changes).
249 //
250 // Remove these as we update our sites.
251 //
252 #ifndef    SK_SUPPORT_LEGACY_GETTOPDEVICE
253 #   define SK_SUPPORT_LEGACY_GETTOPDEVICE
254 #endif
255
256 #ifndef    SK_SUPPORT_LEGACY_GETDEVICE
257 #   define SK_SUPPORT_LEGACY_GETDEVICE
258 #endif
259
260 #ifndef    SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS
261 #   define SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS
262 #endif
263
264 #ifndef    SK_SUPPORT_LEGACY_PICTURE_CLONE
265 #   define SK_SUPPORT_LEGACY_PICTURE_CLONE
266 #endif
267
268 #ifndef    SK_IGNORE_ETC1_SUPPORT
269 #   define SK_IGNORE_ETC1_SUPPORT
270 #endif
271
272 #ifndef    SK_IGNORE_GPU_DITHER
273 #   define SK_IGNORE_GPU_DITHER
274 #endif
275
276 #ifndef    SK_LEGACY_PICTURE_SIZE_API
277 #   define SK_LEGACY_PICTURE_SIZE_API
278 #endif
279
280 #ifndef    SK_LEGACY_PICTURE_DRAW_API
281 #   define SK_LEGACY_PICTURE_DRAW_API
282 #endif
283
284
285 // Turns SkPicture::clone() into a simple "return SkRef(this);" as a way to
286 // test the threadsafety of SkPicture playback.
287 #define SK_PICTURE_CLONE_NOOP 1
288
289 // Turns on new (nicer, hopefully faster) SkPicture backend.
290 #define SK_PICTURE_USE_SK_RECORD 1
291
292 // Run a few optimization passes over the SkRecord after recording.
293 #define SK_PICTURE_OPTIMIZE_SK_RECORD 1
294
295 // ===== End Chrome-specific definitions =====
296
297 #endif