add SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE flag for skia api change
[chromium-blink-merge.git] / skia / config / SkUserConfig.h
blob501e88d6294ea929233526408fb6332301344b7c
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 /* 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.
51 //#define SK_SCALAR_IS_FLOAT
52 //#define SK_SCALAR_IS_FIXED
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.
60 //#define SK_CAN_USE_FLOAT
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.
67 //#define SK_SOFTWARE_FLOAT
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.
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.
79 //#define SK_DEBUG
80 //#define SK_RELEASE
82 #ifdef DCHECK_ALWAYS_ON
83 #undef SK_RELEASE
84 #define SK_DEBUG
85 #endif
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
91 //#define SK_CRASH() *(int *)(uintptr_t)0 = 0
94 /* preconfig will have attempted to determine the endianness of the system,
95 but you can change these mutually exclusive flags here.
97 //#define SK_CPU_BENDIAN
98 //#define SK_CPU_LENDIAN
101 /* Some compilers don't support long long for 64bit integers. If yours does
102 not, define this to the appropriate type.
104 //#define SkLONGLONG int64_t
107 /* Some envorinments do not suport writable globals (eek!). If yours does not,
108 define this flag.
110 //#define SK_USE_RUNTIME_GLOBALS
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.
116 //#define SK_ZLIB_INCLUDE <zlib.h>
117 #define SK_ZLIB_INCLUDE "third_party/zlib/zlib.h"
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.
122 //#define SK_ALLOW_LARGE_PDF_SCALARS
124 /* Define this to provide font subsetter for font subsetting when generating
125 PDF documents.
127 #define SK_SFNTLY_SUBSETTER \
128 "third_party/sfntly/cpp/src/sample/chromium/font_subsetter.h"
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
134 //#define SkDebugf(...) MyFunction(__VA_ARGS__)
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.
141 #ifdef SK_DEBUG
142 #define SK_SUPPORT_UNITTEST
143 #endif
145 /* If cross process SkPictureImageFilters are not explicitly enabled then
146 they are always disabled.
148 #ifndef SK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
149 #ifndef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
150 #define SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
151 #endif
152 #endif
155 /* If your system embeds skia and has complex event logging, define this
156 symbol to name a file that maps the following macros to your system's
157 equivalents:
158 SK_TRACE_EVENT0(event)
159 SK_TRACE_EVENT1(event, name1, value1)
160 SK_TRACE_EVENT2(event, name1, value1, name2, value2)
161 src/utils/SkDebugTrace.h has a trivial implementation that writes to
162 the debug output stream. If SK_USER_TRACE_INCLUDE_FILE is not defined,
163 SkTrace.h will define the above three macros to do nothing.
165 #undef SK_USER_TRACE_INCLUDE_FILE
167 // ===== Begin Chrome-specific definitions =====
169 #ifdef SK_DEBUG
170 #define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_debug.h"
171 #else
172 #define SK_REF_CNT_MIXIN_INCLUDE "sk_ref_cnt_ext_release.h"
173 #endif
175 #define SK_SCALAR_IS_FLOAT
176 #undef SK_SCALAR_IS_FIXED
178 #define SK_MSCALAR_IS_FLOAT
179 #undef SK_MSCALAR_IS_DOUBLE
181 #define GR_MAX_OFFSCREEN_AA_DIM 512
183 // Log the file and line number for assertions.
184 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, false, __VA_ARGS__)
185 SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
186 const char* format, ...);
188 // Marking the debug print as "fatal" will cause a debug break, so we don't need
189 // a separate crash call here.
190 #define SK_DEBUGBREAK(cond) do { if (!(cond)) { \
191 SkDebugf_FileLine(__FILE__, __LINE__, true, \
192 "%s:%d: failed assertion \"%s\"\n", \
193 __FILE__, __LINE__, #cond); } } while (false)
195 #if !defined(ANDROID) // On Android, we use the skia default settings.
196 #define SK_A32_SHIFT 24
197 #define SK_R32_SHIFT 16
198 #define SK_G32_SHIFT 8
199 #define SK_B32_SHIFT 0
200 #endif
202 #if defined(SK_BUILD_FOR_WIN32)
204 #define SK_BUILD_FOR_WIN
206 // Skia uses this deprecated bzero function to fill zeros into a string.
207 #define bzero(str, len) memset(str, 0, len)
209 #elif defined(SK_BUILD_FOR_MAC)
211 #define SK_CPU_LENDIAN
212 #undef SK_CPU_BENDIAN
214 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
216 // Prefer FreeType's emboldening algorithm to Skia's
217 // TODO: skia used to just use hairline, but has improved since then, so
218 // we should revisit this choice...
219 #define SK_USE_FREETYPE_EMBOLDEN
221 #if defined(SK_BUILD_FOR_UNIX) && defined(SK_CPU_BENDIAN)
222 // Above we set the order for ARGB channels in registers. I suspect that, on
223 // big endian machines, you can keep this the same and everything will work.
224 // The in-memory order will be different, of course, but as long as everything
225 // is reading memory as words rather than bytes, it will all work. However, if
226 // you find that colours are messed up I thought that I would leave a helpful
227 // locator for you. Also see the comments in
228 // base/gfx/bitmap_platform_device_linux.h
229 #error Read the comment at this location
230 #endif
232 #endif
234 // The default crash macro writes to badbeef which can cause some strange
235 // problems. Instead, pipe this through to the logging function as a fatal
236 // assertion.
237 #define SK_CRASH() SkDebugf_FileLine(__FILE__, __LINE__, true, "SK_CRASH")
239 // These flags are no longer defined in Skia, but we have them (temporarily)
240 // until we update our call-sites (typically these are for API changes).
242 // Remove these as we update our sites.
244 #ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE
245 # define SK_SUPPORT_LEGACY_GETTOPDEVICE
246 #endif
248 #ifndef SK_SUPPORT_LEGACY_GETDEVICE
249 # define SK_SUPPORT_LEGACY_GETDEVICE
250 #endif
252 #ifndef SK_IGNORE_ETC1_SUPPORT
253 # define SK_IGNORE_ETC1_SUPPORT
254 #endif
256 #ifndef SK_IGNORE_GPU_DITHER
257 # define SK_IGNORE_GPU_DITHER
258 #endif
260 #ifndef SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
261 # define SK_SUPPORT_LEGACY_UNBALANCED_PIXELREF_LOCKCOUNT
262 #endif
264 #ifndef SK_SUPPORT_LEGACY_XFERMODES
265 # define SK_SUPPORT_LEGACY_XFERMODES
266 #endif
268 #ifndef SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
269 # define SK_LEGACY_IMAGE_GENERATOR_ENUMS_AND_OPTIONS
270 #endif
272 #ifndef SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
273 # define SK_SUPPORT_LEGACY_DRAWBITMAPRECTFLAGS_TYPE
274 #endif
276 #ifndef SK_LEGACY_IMAGE_FILTER_CROP_RECT_EDGES
277 # define SK_LEGACY_IMAGE_FILTER_CROP_RECT_EDGES
278 #endif
280 ///////////////////////// Imported from BUILD.gn and skia_common.gypi
282 /* In some places Skia can use static initializers for global initialization,
283 * or fall back to lazy runtime initialization. Chrome always wants the latter.
285 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
287 /* Forcing the unoptimized path for the offset image filter in skia until
288 * all filters used in Blink support the optimized path properly
290 #define SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION
292 /* This flag forces Skia not to use typographic metrics with GDI.
294 #define SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
296 #define IGNORE_ROT_AA_RECT_OPT
297 #define SK_IGNORE_BLURRED_RRECT_OPT
298 #define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
299 #define SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT
301 #define SK_ATTR_DEPRECATED SK_NOTHING_ARG1
302 #define SK_ENABLE_INST_COUNT 0
303 #define GR_GL_CUSTOM_SETUP_HEADER "GrGLConfig_chrome.h"
305 // ===== End Chrome-specific definitions =====
307 #endif