1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SKIA_CONFIG_SKUSERCONFIG_H_
11 #define SKIA_CONFIG_SKUSERCONFIG_H_
12 
13 /*  SkTypes.h, the root of the public header files, does the following trick:
14 
15     #include "include/config/SkUserConfig.h"
16     #include "include/core/SkPostConfig.h"
17     #include "include/core/SkPreConfig.h"
18 
19     SkPreConfig.h runs first, and it is responsible for initializing certain
20     skia defines.
21 
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
24     defines).
25 
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.
29 
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).
33 
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.
36 */
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 
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.
44 
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
47     here.
48  */
49 //#define SK_DEBUG
50 //#define SK_RELEASE
51 
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.
57  */
58 //#define SK_DEBUG_GLYPH_CACHE
59 //#define SK_DEBUG_PATH
60 
61 /*  preconfig will have attempted to determine the endianness of the system,
62     but you can change these mutually exclusive flags here.
63  */
64 //#define SK_CPU_BENDIAN
65 //#define SK_CPU_LENDIAN
66 
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.
72 */
73 //#define SK_UINT8_BITFIELD_BENDIAN
74 //#define SK_UINT8_BITFIELD_LENDIAN
75 
76 
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
80  */
81 //#define SkDebugf(...)  MyFunction(__VA_ARGS__)
82 
83 /*
84  *  To specify a different default font cache limit, define this. If this is
85  *  undefined, skia will use a built-in value.
86  */
87 //#define SK_DEFAULT_FONT_CACHE_LIMIT   (1024 * 1024)
88 
89 /*
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.
93  */
94 //#define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024)
95 
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
99     value (e.g. 48)
100  */
101 //#define SK_MAX_SIZE_FOR_LCDTEXT     48
102 
103 /*  Change the kN32_SkColorType ordering to BGRA to work in X windows.
104  */
105 //#define SK_R32_SHIFT    16
106 
107 
108 /* Determines whether to build code that supports the 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 the GPU backend. If you'd like to
111    omit this code set SK_SUPPORT_GPU to 0. This also allows you to omit the gpu
112    directories from your include search path when you're not building the GPU
113    backend. Defaults to 1 (build the GPU code).
114  */
115 //#define SK_SUPPORT_GPU 1
116 
117 /* Skia makes use of histogram logging macros to trace the frequency of
118  * events. By default, Skia provides no-op versions of these macros.
119  * Skia consumers can provide their own definitions of these macros to
120  * integrate with their histogram collection backend.
121  */
122 //#define SK_HISTOGRAM_BOOLEAN(name, value)
123 //#define SK_HISTOGRAM_ENUMERATION(name, value, boundary_value)
124 
125 // ===== Begin Chrome-specific definitions =====
126 
127 #ifdef DCHECK_ALWAYS_ON
128     #undef SK_RELEASE
129     #define SK_DEBUG
130 #endif
131 
132 /*  Define this to provide font subsetter for font subsetting when generating
133     PDF documents.
134  */
135 // #define SK_PDF_USE_HARFBUZZ_SUBSET
136 
137 // Chromium does not use these fonts.  This define causes type1 fonts to be
138 // converted to type3 when producing PDFs, and reduces build size.
139 #define SK_PDF_DO_NOT_SUPPORT_TYPE_1_FONTS
140 
141 #ifdef SK_DEBUG
142 #define SK_REF_CNT_MIXIN_INCLUDE "skia/config/sk_ref_cnt_ext_debug.h"
143 #else
144 #define SK_REF_CNT_MIXIN_INCLUDE "skia/config/sk_ref_cnt_ext_release.h"
145 #endif
146 
147 // Log the file and line number for assertions.
148 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, __VA_ARGS__)
149 SK_API void SkDebugf_FileLine(const char* file,
150                               int line,
151                               const char* format,
152                               ...);
153 
154 #if !defined(ANDROID)   // On Android, we use the skia default settings.
155 #if defined(SK_CPU_BENDIAN)
156 #define SK_A32_SHIFT    0
157 #define SK_R32_SHIFT    8
158 #define SK_G32_SHIFT    16
159 #define SK_B32_SHIFT    24
160 #else
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
166 #endif
167 
168 #if defined(SK_BUILD_FOR_MAC)
169 
170 #define SK_CPU_LENDIAN
171 #undef  SK_CPU_BENDIAN
172 
173 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
174 
175 // Prefer FreeType's emboldening algorithm to Skia's
176 // TODO: skia used to just use hairline, but has improved since then, so
177 // we should revisit this choice...
178 #define SK_USE_FREETYPE_EMBOLDEN
179 
180 #endif
181 
182 // These flags are no longer defined in Skia, but we have them (temporarily)
183 // until we update our call-sites (typically these are for API changes).
184 //
185 // Remove these as we update our sites.
186 
187 // Workaround for poor anisotropic mipmap quality,
188 // pending Skia ripmap support.
189 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863)
190 #ifndef    SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
191 #   define SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
192 #endif
193 
194 // For now, Chrome should only attempt to reduce opList splitting when recording
195 // DDLs
196 #ifndef SK_DISABLE_REDUCE_OPLIST_SPLITTING
197 #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
198 #endif
199 
200 // Max. verb count for paths rendered by the edge-AA tessellating path renderer.
201 #define GR_AA_TESSELLATOR_MAX_VERB_COUNT 100
202 
203 #ifndef SK_SUPPORT_LEGACY_AAA_CHOICE
204 #define SK_SUPPORT_LEGACY_AAA_CHOICE
205 #endif
206 
207 // Staging for lowp::bilerp_clamp_8888, and for planned misc. others.
208 #define SK_DISABLE_LOWP_BILERP_CLAMP_CLAMP_STAGE
209 
210 ///////////////////////// Imported from BUILD.gn and skia_common.gypi
211 
212 /* In some places Skia can use static initializers for global initialization,
213  *  or fall back to lazy runtime initialization. Chrome always wants the latter.
214  */
215 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
216 
217 /* Restrict formats for Skia font matching to SFNT type fonts. */
218 #define SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS
219 
220 #define SK_IGNORE_BLURRED_RRECT_OPT
221 #define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
222 
223 #define SK_ATTR_DEPRECATED          SK_NOTHING_ARG1
224 #define GR_GL_CUSTOM_SETUP_HEADER   "GrGLConfig_chrome.h"
225 
226 #endif
227