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