3 * Copyright 2006 The Android Open Source Project
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #ifndef SKIA_CONFIG_SKUSERCONFIG_H_
11 #define SKIA_CONFIG_SKUSERCONFIG_H_
13 /* SkTypes.h, the root of the public header files, does the following trick:
15 #include "include/config/SkUserConfig.h"
16 #include "include/core/SkPostConfig.h"
17 #include "include/core/SkPreConfig.h"
19 SkPreConfig.h runs first, and it is responsible for initializing certain
22 SkPostConfig.h runs last, and its job is to just check that the final
23 defines are consistent (i.e. that we don't have mutually conflicting
26 SkUserConfig.h (this file) runs in the middle. It gets to change or augment
27 the list of flags initially set in preconfig, and then postconfig checks
28 that everything still makes sense.
30 Below are optional defines that add, subtract, or change default behavior
31 in Skia. Your port can locally edit this file to enable/disable flags as
32 you choose, or these can be delared on your command line (i.e. -Dfoo).
34 By default, this include file will always default to having all of the flags
35 commented out, so including it will have no effect.
38 ///////////////////////////////////////////////////////////////////////////////
40 /* Skia has lots of debug-only code. Often this is just null checks or other
41 parameter checking, but sometimes it can be quite intrusive (e.g. check that
42 each 32bit pixel is in premultiplied form). This code can be very useful
43 during development, but will slow things down in a shipping product.
45 By default, these mutually exclusive flags are defined in SkPreConfig.h,
46 based on the presence or absence of NDEBUG, but that decision can be changed
52 /* Skia has certain debug-only code that is extremely intensive even for debug
53 builds. This code is useful for diagnosing specific issues, but is not
54 generally applicable, therefore it must be explicitly enabled to avoid
55 the performance impact. By default these flags are undefined, but can be
56 enabled by uncommenting them below.
58 //#define SK_DEBUG_GLYPH_CACHE
59 //#define SK_DEBUG_PATH
61 /* preconfig will have attempted to determine the endianness of the system,
62 but you can change these mutually exclusive flags here.
64 //#define SK_CPU_BENDIAN
65 //#define SK_CPU_LENDIAN
67 /* Most compilers use the same bit endianness for bit flags in a byte as the
68 system byte endianness, and this is the default. If for some reason this
69 needs to be overridden, specify which of the mutually exclusive flags to
70 use. For example, some atom processors in certain configurations have big
71 endian byte order but little endian bit orders.
73 //#define SK_UINT8_BITFIELD_BENDIAN
74 //#define SK_UINT8_BITFIELD_LENDIAN
77 /* To write debug messages to a console, skia will call SkDebugf(...) following
78 printf conventions (e.g. const char* format, ...). If you want to redirect
79 this to something other than printf, define yours here
81 //#define SkDebugf(...) MyFunction(__VA_ARGS__)
84 * To specify a different default font cache limit, define this. If this is
85 * undefined, skia will use a built-in value.
87 //#define SK_DEFAULT_FONT_CACHE_LIMIT (1024 * 1024)
90 * To specify the default size of the image cache, undefine this and set it to
91 * the desired value (in bytes). SkGraphics.h as a runtime API to set this
92 * value as well. If this is undefined, a built-in value will be used.
94 //#define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024)
96 /* Define this to set the upper limit for text to support LCD. Values that
97 are very large increase the cost in the font cache and draw slower, without
98 improving readability. If this is undefined, Skia will use its default
101 //#define SK_MAX_SIZE_FOR_LCDTEXT 48
103 /* Change the kN32_SkColorType ordering to BGRA to work in X windows.
105 //#define SK_R32_SHIFT 16
108 /* Determines whether to build code that supports the Ganesh GPU backend. Some classes
109 that are not GPU-specific, such as SkShader subclasses, have optional code
110 that is used allows them to interact with this GPU backend. If you'd like to
111 include this code, include -DSK_GANESH in your cflags or uncomment below.
112 Defaults to not set (No Ganesh GPU backend).
113 This define affects the ABI of Skia, so make sure it matches the client which uses
114 the compiled version of Skia.
118 /* Skia makes use of histogram logging macros to trace the frequency of
119 * events. By default, Skia provides no-op versions of these macros.
120 * Skia consumers can provide their own definitions of these macros to
121 * integrate with their histogram collection backend.
123 //#define SK_HISTOGRAM_BOOLEAN(name, sample)
124 //#define SK_HISTOGRAM_EXACT_LINEAR(name, sample, value_max)
125 //#define SK_HISTOGRAM_MEMORY_KB(name, sample)
126 #include "base/component_export.h"
127 #include "skia/ext/skia_histogram.h"
129 // ===== Begin Chrome-specific definitions =====
131 #ifdef DCHECK_ALWAYS_ON
136 /* Define this to provide font subsetter for font subsetting when generating
139 #define SK_PDF_USE_HARFBUZZ_SUBSET
141 // Handle exporting using base/component_export.h
142 #define SK_API COMPONENT_EXPORT(SKIA)
144 // Chromium does not use these fonts. This define causes type1 fonts to be
145 // converted to type3 when producing PDFs, and reduces build size.
146 #define SK_PDF_DO_NOT_SUPPORT_TYPE_1_FONTS
149 #define SK_REF_CNT_MIXIN_INCLUDE "skia/config/sk_ref_cnt_ext_debug.h"
151 #define SK_REF_CNT_MIXIN_INCLUDE "skia/config/sk_ref_cnt_ext_release.h"
154 // Log the file and line number for assertions.
155 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, __VA_ARGS__)
156 SK_API void SkDebugf_FileLine(const char* file,
161 #define SK_ABORT(format, ...) SkAbort_FileLine(__FILE__, __LINE__, \
162 format,##__VA_ARGS__)
163 [[noreturn]] SK_API void SkAbort_FileLine(const char* file,
168 #if !defined(ANDROID) // On Android, we use the skia default settings.
169 #define SK_A32_SHIFT 24
170 #define SK_R32_SHIFT 16
171 #define SK_G32_SHIFT 8
172 #define SK_B32_SHIFT 0
175 #if defined(SK_BUILD_FOR_MAC)
177 #define SK_CPU_LENDIAN
178 #undef SK_CPU_BENDIAN
180 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
182 // Prefer FreeType's emboldening algorithm to Skia's
183 // TODO: skia used to just use hairline, but has improved since then, so
184 // we should revisit this choice...
185 #define SK_USE_FREETYPE_EMBOLDEN
187 #if defined(SK_BUILD_FOR_UNIX) && defined(SK_CPU_BENDIAN)
188 // Above we set the order for ARGB channels in registers. I suspect that, on
189 // big endian machines, you can keep this the same and everything will work.
190 // The in-memory order will be different, of course, but as long as everything
191 // is reading memory as words rather than bytes, it will all work. However, if
192 // you find that colours are messed up I thought that I would leave a helpful
193 // locator for you. Also see the comments in
194 // base/gfx/bitmap_platform_device_linux.h
195 #error Read the comment at this location
200 #if defined(__has_attribute)
201 #if __has_attribute(trivial_abi)
202 #define SK_TRIVIAL_ABI [[clang::trivial_abi]]
204 #define SK_TRIVIAL_ABI
207 #define SK_TRIVIAL_ABI
210 // These flags are no longer defined in Skia, but we have them (temporarily)
211 // until we update our call-sites (typically these are for API changes).
213 // Remove these as we update our sites.
215 #define SK_LEGACY_LAYER_BOUNDS_EXPANSION // skbug.com/12083, skbug.com/12303
217 // Workaround for poor anisotropic mipmap quality,
218 // pending Skia ripmap support.
219 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863)
220 #define SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
222 // Temporarily insulate Chrome pixel tests from Skia LOD bias change on GPU.
223 #define SK_USE_LEGACY_MIPMAP_LOD_BIAS
225 // Max. verb count for paths rendered by the edge-AA tessellating path renderer.
226 #define GR_AA_TESSELLATOR_MAX_VERB_COUNT 100
230 #define SK_SUPPORT_LEGACY_DRAWLOOPER
232 #define SK_USE_LEGACY_MIPMAP_BUILDER
234 #define SK_SUPPORT_LEGACY_CONIC_CHOP
236 // To be replaced with SK_ENABLE_SKSL_IN_RASTER_PIPELINE (go/sksl-rp):
237 #define SK_ENABLE_SKVM
239 // Use the original std::vector based serializer
240 // Remove when new streaming support operations has been verified.
241 // #define SK_SUPPORT_LEGACY_STRIKE_SERIALIZATION
243 ///////////////////////// Imported from BUILD.gn and skia_common.gypi
245 /* In some places Skia can use static initializers for global initialization,
246 * or fall back to lazy runtime initialization. Chrome always wants the latter.
248 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
250 /* Restrict formats for Skia font matching to SFNT type fonts. */
251 #define SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS
253 #define SK_IGNORE_BLURRED_RRECT_OPT
254 #define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
256 #define SK_ATTR_DEPRECATED SK_NOTHING_ARG1
257 #define GR_GL_CUSTOM_SETUP_HEADER "GrGLConfig_chrome.h"
259 #endif // SKIA_CONFIG_SKUSERCONFIG_H_