Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / skia / config / SkUserConfig.h
blobef74202b640bb73e58bac09728e25526a22752c7
1 /*
2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef SkUserConfig_DEFINED
18 #define SkUserConfig_DEFINED
20 /* SkTypes.h, the root of the public header files, does the following trick:
22 #include <SkPreConfig.h>
23 #include <SkUserConfig.h>
24 #include <SkPostConfig.h>
26 SkPreConfig.h runs first, and it is responsible for initializing certain
27 skia defines.
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).
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.
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).
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.
45 ///////////////////////////////////////////////////////////////////////////////
47 /* Skia has lots of debug-only code. Often this is just null checks or other
48 parameter checking, but sometimes it can be quite intrusive (e.g. check that
49 each 32bit pixel is in premultiplied form). This code can be very useful
50 during development, but will slow things down in a shipping product.
52 By default, these mutually exclusive flags are defined in SkPreConfig.h,
53 based on the presence or absence of NDEBUG, but that decision can be changed
54 here.
56 //#define SK_DEBUG
57 //#define SK_RELEASE
59 #ifdef DCHECK_ALWAYS_ON
60 #undef SK_RELEASE
61 #define SK_DEBUG
62 #endif
64 /* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
65 it will call SK_CRASH(). If this is not defined it, it is defined in
66 SkPostConfig.h to write to an illegal address
68 //#define SK_CRASH() *(int *)(uintptr_t)0 = 0
71 /* preconfig will have attempted to determine the endianness of the system,
72 but you can change these mutually exclusive flags here.
74 //#define SK_CPU_BENDIAN
75 //#define SK_CPU_LENDIAN
77 /* If zlib is available and you want to support the flate compression
78 algorithm (used in PDF generation), define SK_ZLIB_INCLUDE to be the
79 include path.
81 //#define SK_ZLIB_INCLUDE <zlib.h>
82 #define SK_ZLIB_INCLUDE "third_party/zlib/zlib.h"
84 /* Define this to allow PDF scalars above 32k. The PDF/A spec doesn't allow
85 them, but modern PDF interpreters should handle them just fine.
87 //#define SK_ALLOW_LARGE_PDF_SCALARS
89 /* Define this to provide font subsetter for font subsetting when generating
90 PDF documents.
92 #define SK_SFNTLY_SUBSETTER \
93 "third_party/sfntly/cpp/src/sample/chromium/font_subsetter.h"
95 /* To write debug messages to a console, skia will call SkDebugf(...) following
96 printf conventions (e.g. const char* format, ...). If you want to redirect
97 this to something other than printf, define yours here
99 //#define SkDebugf(...) MyFunction(__VA_ARGS__)
102 /* If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
103 which will run additional self-tests at startup. These can take a long time,
104 so this flag is optional.
106 #ifdef SK_DEBUG
107 #define SK_SUPPORT_UNITTEST
108 #endif
110 /* If cross process SkPictureImageFilters are not explicitly enabled then
111 they are always disabled.
113 #ifndef SK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
114 #ifndef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
115 #define SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
116 #endif
117 #endif
120 /* If your system embeds skia and has complex event logging, define this
121 symbol to name a file that maps the following macros to your system's
122 equivalents:
123 SK_TRACE_EVENT0(event)
124 SK_TRACE_EVENT1(event, name1, value1)
125 SK_TRACE_EVENT2(event, name1, value1, name2, value2)
126 src/utils/SkDebugTrace.h has a trivial implementation that writes to
127 the debug output stream. If SK_USER_TRACE_INCLUDE_FILE is not defined,
128 SkTrace.h will define the above three macros to do nothing.
130 #undef SK_USER_TRACE_INCLUDE_FILE
132 // ===== Begin Chrome-specific definitions =====
134 #ifdef SK_DEBUG
135 #define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_debug.h"
136 #else
137 #define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_release.h"
138 #endif
140 #define SK_SCALAR_IS_FLOAT
141 #undef SK_SCALAR_IS_FIXED
143 #define SK_MSCALAR_IS_FLOAT
144 #undef SK_MSCALAR_IS_DOUBLE
146 #define GR_MAX_OFFSCREEN_AA_DIM 512
148 // Log the file and line number for assertions.
149 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, false, __VA_ARGS__)
150 SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
151 const char* format, ...);
153 // Marking the debug print as "fatal" will cause a debug break, so we don't need
154 // a separate crash call here.
155 #define SK_DEBUGBREAK(cond) do { if (!(cond)) { \
156 SkDebugf_FileLine(__FILE__, __LINE__, true, \
157 "%s:%d: failed assertion \"%s\"\n", \
158 __FILE__, __LINE__, #cond); } } while (false)
160 #if !defined(ANDROID) // On Android, we use the skia default settings.
161 #define SK_A32_SHIFT 24
162 #define SK_R32_SHIFT 16
163 #define SK_G32_SHIFT 8
164 #define SK_B32_SHIFT 0
165 #endif
167 #if defined(SK_BUILD_FOR_WIN32)
169 #define SK_BUILD_FOR_WIN
171 // Skia uses this deprecated bzero function to fill zeros into a string.
172 #define bzero(str, len) memset(str, 0, len)
174 #elif defined(SK_BUILD_FOR_MAC)
176 #define SK_CPU_LENDIAN
177 #undef SK_CPU_BENDIAN
179 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
181 // Prefer FreeType's emboldening algorithm to Skia's
182 // TODO: skia used to just use hairline, but has improved since then, so
183 // we should revisit this choice...
184 #define SK_USE_FREETYPE_EMBOLDEN
186 #if defined(SK_BUILD_FOR_UNIX) && defined(SK_CPU_BENDIAN)
187 // Above we set the order for ARGB channels in registers. I suspect that, on
188 // big endian machines, you can keep this the same and everything will work.
189 // The in-memory order will be different, of course, but as long as everything
190 // is reading memory as words rather than bytes, it will all work. However, if
191 // you find that colours are messed up I thought that I would leave a helpful
192 // locator for you. Also see the comments in
193 // base/gfx/bitmap_platform_device_linux.h
194 #error Read the comment at this location
195 #endif
197 #endif
199 // The default crash macro writes to badbeef which can cause some strange
200 // problems. Instead, pipe this through to the logging function as a fatal
201 // assertion.
202 #define SK_CRASH() SkDebugf_FileLine(__FILE__, __LINE__, true, "SK_CRASH")
204 // These flags are no longer defined in Skia, but we have them (temporarily)
205 // until we update our call-sites (typically these are for API changes).
207 // Remove these as we update our sites.
209 #ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE
210 # define SK_SUPPORT_LEGACY_GETTOPDEVICE
211 #endif
213 #ifndef SK_SUPPORT_LEGACY_GETDEVICE
214 # define SK_SUPPORT_LEGACY_GETDEVICE
215 #endif
217 #ifndef SK_IGNORE_ETC1_SUPPORT
218 # define SK_IGNORE_ETC1_SUPPORT
219 #endif
221 #ifndef SK_IGNORE_GPU_DITHER
222 # define SK_IGNORE_GPU_DITHER
223 #endif
225 #ifndef SK_SAVE_LAYER_BOUNDS_ARE_FILTERED
226 # define SK_SAVE_LAYER_BOUNDS_ARE_FILTERED
227 #endif
229 ///////////////////////// Imported from BUILD.gn and skia_common.gypi
231 /* In some places Skia can use static initializers for global initialization,
232 * or fall back to lazy runtime initialization. Chrome always wants the latter.
234 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
236 /* Forcing the unoptimized path for the offset image filter in skia until
237 * all filters used in Blink support the optimized path properly
239 #define SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION
241 /* This flag forces Skia not to use typographic metrics with GDI.
243 #define SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
245 #define SK_IGNORE_BLURRED_RRECT_OPT
246 #define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
247 #define SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT
249 #define SK_ATTR_DEPRECATED SK_NOTHING_ARG1
250 #define SK_ENABLE_INST_COUNT 0
251 #define GR_GL_CUSTOM_SETUP_HEADER "GrGLConfig_chrome.h"
253 // ===== End Chrome-specific definitions =====
255 #endif