• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SKIA_CONFIG_SKUSERCONFIG_H_
18 #define SKIA_CONFIG_SKUSERCONFIG_H_
19 
20 /*  SkTypes.h, the root of the public header files, does the following trick:
21 
22     #include <SkPreConfig.h>
23     #include <SkUserConfig.h>
24     #include <SkPostConfig.h>
25 
26     SkPreConfig.h runs first, and it is responsible for initializing certain
27     skia defines.
28 
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).
32 
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.
36 
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).
40 
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.
43 */
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 
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.
51 
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.
55  */
56 // #define SK_DEBUG
57 // #define SK_RELEASE
58 
59 // #ifdef DCHECK_ALWAYS_ON
60 //     #undef SK_RELEASE
61 //     #define SK_DEBUG
62 // #endif
63 
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
67  */
68 // #define SK_CRASH() *(int *)(uintptr_t)0 = 0
69 
70 /*  preconfig will have attempted to determine the endianness of the system,
71     but you can change these mutually exclusive flags here.
72  */
73 // #define SK_CPU_BENDIAN
74 // #define SK_CPU_LENDIAN
75 
76 /*  If zlib is available and you want to support the flate compression
77     algorithm (used in PDF generation), define SK_ZLIB_INCLUDE to be the
78     include path.
79  */
80 // #define SK_ZLIB_INCLUDE <zlib.h>
81 
82 /*  Define this to allow PDF scalars above 32k.  The PDF/A spec doesn't allow
83     them, but modern PDF interpreters should handle them just fine.
84  */
85 // #define SK_ALLOW_LARGE_PDF_SCALARS
86 
87 /*  Define this to provide font subsetter for font subsetting when generating
88     PDF documents.
89  */
90 // #define SK_SFNTLY_SUBSETTER \
91 //    "third_party/sfntly/src/cpp/src/sample/chromium/font_subsetter.h"
92 
93 /*  To write debug messages to a console, skia will call SkDebugf(...) following
94     printf conventions (e.g. const char* format, ...). If you want to redirect
95     this to something other than printf, define yours here
96  */
97 // #define SkDebugf(...)  MyFunction(__VA_ARGS__)
98 
99 /*  If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
100     which will run additional self-tests at startup. These can take a long time,
101     so this flag is optional.
102  */
103 #ifdef SK_DEBUG
104 #define SK_SUPPORT_UNITTEST
105 #endif
106 
107 /* If cross process SkPictureImageFilters are not explicitly enabled then
108    they are always disabled.
109  */
110 #ifndef SK_ALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
111 #ifndef SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
112 #define SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS
113 #endif
114 #endif
115 
116 /* If your system embeds skia and has complex event logging, define this
117    symbol to name a file that maps the following macros to your system's
118    equivalents:
119        SK_TRACE_EVENT0(event)
120        SK_TRACE_EVENT1(event, name1, value1)
121        SK_TRACE_EVENT2(event, name1, value1, name2, value2)
122    src/utils/SkDebugTrace.h has a trivial implementation that writes to
123    the debug output stream. If SK_USER_TRACE_INCLUDE_FILE is not defined,
124    SkTrace.h will define the above three macros to do nothing.
125 */
126 #undef SK_USER_TRACE_INCLUDE_FILE
127 
128 // ===== Begin Chrome-specific definitions =====
129 
130 #define SK_MSCALAR_IS_FLOAT
131 #undef SK_MSCALAR_IS_DOUBLE
132 
133 #define GR_MAX_OFFSCREEN_AA_DIM 512
134 
135 // Log the file and line number for assertions.
136 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, false, __VA_ARGS__)
137 SK_API void SkDebugf_FileLine(const char* file,
138                               int line,
139                               bool fatal,
140                               const char* format,
141                               ...);
142 
143 // Marking the debug print as "fatal" will cause a debug break, so we don't need
144 // a separate crash call here.
145 #define SK_DEBUGBREAK(cond)                                           \
146   do {                                                                \
147     if (!(cond)) {                                                    \
148       SkDebugf_FileLine(__FILE__, __LINE__, true,                     \
149                         "%s:%d: failed assertion \"%s\"\n", __FILE__, \
150                         __LINE__, #cond);                             \
151     }                                                                 \
152   } while (false)
153 
154 #if !defined(ANDROID)  // On Android, we use the skia default settings.
155 #define SK_A32_SHIFT 24
156 #define SK_R32_SHIFT 16
157 #define SK_G32_SHIFT 8
158 #define SK_B32_SHIFT 0
159 #endif
160 
161 #if defined(SK_BUILD_FOR_WIN32)
162 
163 #define SK_BUILD_FOR_WIN
164 
165 // Skia uses this deprecated bzero function to fill zeros into a string.
166 #define bzero(str, len) memset(str, 0, len)
167 
168 #elif 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 #if defined(SK_BUILD_FOR_UNIX) && defined(SK_CPU_BENDIAN)
181 // Above we set the order for ARGB channels in registers. I suspect that, on
182 // big endian machines, you can keep this the same and everything will work.
183 // The in-memory order will be different, of course, but as long as everything
184 // is reading memory as words rather than bytes, it will all work. However, if
185 // you find that colours are messed up I thought that I would leave a helpful
186 // locator for you. Also see the comments in
187 // base/gfx/bitmap_platform_device_linux.h
188 #error Read the comment at this location
189 #endif
190 
191 #endif
192 
193 // The default crash macro writes to badbeef which can cause some strange
194 // problems. Instead, pipe this through to the logging function as a fatal
195 // assertion.
196 #define SK_CRASH() SkDebugf_FileLine(__FILE__, __LINE__, true, "SK_CRASH")
197 
198 // These flags are no longer defined in Skia, but we have them (temporarily)
199 // until we update our call-sites (typically these are for API changes).
200 //
201 // Remove these as we update our sites.
202 //
203 #ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE
204 #define SK_SUPPORT_LEGACY_GETTOPDEVICE
205 #endif
206 
207 #ifndef SK_SUPPORT_EXOTIC_CLIPOPS
208 #define SK_SUPPORT_EXOTIC_CLIPOPS
209 #endif
210 
211 #ifndef SK_SUPPORT_LEGACY_GETDEVICE
212 #define SK_SUPPORT_LEGACY_GETDEVICE
213 #endif
214 
215 // Workaround for poor anisotropic mipmap quality,
216 // pending Skia ripmap support.
217 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863)
218 #ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
219 #define SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
220 #endif
221 
222 #ifndef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
223 #define SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
224 #endif
225 
226 #ifndef SK_IGNORE_ETC1_SUPPORT
227 #define SK_IGNORE_ETC1_SUPPORT
228 #endif
229 
230 #ifndef SK_IGNORE_GPU_DITHER
231 #define SK_IGNORE_GPU_DITHER
232 #endif
233 
234 #ifndef SK_SUPPORT_LEGACY_EVAL_CUBIC
235 #define SK_SUPPORT_LEGACY_EVAL_CUBIC
236 #endif
237 
238 ///////////////////////// Imported from BUILD.gn and skia_common.gypi
239 
240 /* In some places Skia can use static initializers for global initialization,
241  *  or fall back to lazy runtime initialization. Chrome always wants the latter.
242  */
243 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0
244 
245 /* This flag forces Skia not to use typographic metrics with GDI.
246  */
247 #define SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
248 
249 #define SK_IGNORE_BLURRED_RRECT_OPT
250 #define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
251 #define SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT
252 
253 #define SK_ATTR_DEPRECATED SK_NOTHING_ARG1
254 #define SK_ENABLE_INST_COUNT 0
255 #define GR_GL_CUSTOM_SETUP_HEADER "GrGLConfig_chrome.h"
256 
257 // Blink layout tests are baselined to Clang optimizing through the UB in
258 // SkDivBits.
259 #define SK_SUPPORT_LEGACY_DIVBITS_UB
260 
261 // mtklein's fiddling with Src / SrcOver.  Will rebaseline these only once when
262 // done.
263 #define SK_SUPPORT_LEGACY_X86_BLITS
264 
265 #define SK_DISABLE_TILE_IMAGE_FILTER_OPTIMIZATION
266 
267 // ===== End Chrome-specific definitions =====
268 
269 #endif  // SKIA_CONFIG_SKUSERCONFIG_H_
270