1 /* 2 * Copyright 2006 The PDFium Authors 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #ifndef SKIA_CONFIG_SKUSERCONFIG_H_ 8 #define SKIA_CONFIG_SKUSERCONFIG_H_ 9 10 /* SkTypes.h, the root of the public header files, does the following trick: 11 12 #include "SkPreConfig.h" 13 #include "SkUserConfig.h" 14 #include "SkPostConfig.h" 15 16 SkPreConfig.h runs first, and it is responsible for initializing certain 17 skia defines. 18 19 SkPostConfig.h runs last, and its job is to just check that the final 20 defines are consistent (i.e. that we don't have mutually conflicting 21 defines). 22 23 SkUserConfig.h (this file) runs in the middle. It gets to change or augment 24 the list of flags initially set in preconfig, and then postconfig checks 25 that everything still makes sense. 26 27 Below are optional defines that add, subtract, or change default behavior 28 in Skia. Your port can locally edit this file to enable/disable flags as 29 you choose, or these can be delared on your command line (i.e. -Dfoo). 30 31 By default, this include file will always default to having all of the flags 32 commented out, so including it will have no effect. 33 */ 34 35 /////////////////////////////////////////////////////////////////////////////// 36 37 /* Skia has lots of debug-only code. Often this is just null checks or other 38 parameter checking, but sometimes it can be quite intrusive (e.g. check that 39 each 32bit pixel is in premultiplied form). This code can be very useful 40 during development, but will slow things down in a shipping product. 41 42 By default, these mutually exclusive flags are defined in SkPreConfig.h, 43 based on the presence or absence of NDEBUG, but that decision can be changed 44 here. 45 */ 46 // #define SK_DEBUG 47 // #define SK_RELEASE 48 49 /* Skia has certain debug-only code that is extremely intensive even for debug 50 builds. This code is useful for diagnosing specific issues, but is not 51 generally applicable, therefore it must be explicitly enabled to avoid 52 the performance impact. By default these flags are undefined, but can be 53 enabled by uncommenting them below. 54 */ 55 // #define SK_DEBUG_GLYPH_CACHE 56 // #define SK_DEBUG_PATH 57 58 /* preconfig will have attempted to determine the endianness of the system, 59 but you can change these mutually exclusive flags here. 60 */ 61 // #define SK_CPU_BENDIAN 62 // #define SK_CPU_LENDIAN 63 64 /* Most compilers use the same bit endianness for bit flags in a byte as the 65 system byte endianness, and this is the default. If for some reason this 66 needs to be overridden, specify which of the mutually exclusive flags to 67 use. For example, some atom processors in certain configurations have big 68 endian byte order but little endian bit orders. 69 */ 70 // #define SK_UINT8_BITFIELD_BENDIAN 71 // #define SK_UINT8_BITFIELD_LENDIAN 72 73 74 /* To write debug messages to a console, skia will call SkDebugf(...) following 75 printf conventions (e.g. const char* format, ...). If you want to redirect 76 this to something other than printf, define yours here 77 */ 78 // #define SkDebugf(...) MyFunction(__VA_ARGS__) 79 80 /* 81 * To specify a different default font cache limit, define this. If this is 82 * undefined, skia will use a built-in value. 83 */ 84 // #define SK_DEFAULT_FONT_CACHE_LIMIT (1024 * 1024) 85 86 /* 87 * To specify the default size of the image cache, undefine this and set it to 88 * the desired value (in bytes). SkGraphics.h as a runtime API to set this 89 * value as well. If this is undefined, a built-in value will be used. 90 */ 91 // #define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024) 92 93 /* Define this to set the upper limit for text to support LCD. Values that 94 are very large increase the cost in the font cache and draw slower, without 95 improving readability. If this is undefined, Skia will use its default 96 value (e.g. 48) 97 */ 98 // #define SK_MAX_SIZE_FOR_LCDTEXT 48 99 100 /* Change the ordering to work in X windows. 101 */ 102 // #ifdef SK_SAMPLES_FOR_X 103 // #define SK_R32_SHIFT 16 104 // #define SK_G32_SHIFT 8 105 // #define SK_B32_SHIFT 0 106 // #define SK_A32_SHIFT 24 107 // #endif 108 109 110 /* Determines whether to build code that supports the Ganesh GPU backend. Some classes 111 that are not GPU-specific, such as SkShader subclasses, have optional code 112 that is used to interact with this GPU backend. If you'd like to 113 include this code, include -DSK_GANESH in your cflags or uncomment below. 114 Defaults to not set (No Ganesh GPU backend). 115 This define affects the ABI of Skia, so make sure it matches the client which uses 116 the compiled version of Skia. 117 */ 118 // #define SK_GANESH 119 120 /* Skia makes use of histogram logging macros to trace the frequency of 121 * events. By default, Skia provides no-op versions of these macros. 122 * Skia consumers can provide their own definitions of these macros to 123 * integrate with their histogram collection backend. 124 */ 125 // #define SK_HISTOGRAM_BOOLEAN(name, value) 126 // #define SK_HISTOGRAM_ENUMERATION(name, value, boundary_value) 127 #include "third_party/base/component_export.h" 128 129 // ===== Begin Chrome-specific definitions ===== 130 131 #define SK_MSCALAR_IS_FLOAT 132 #undef SK_MSCALAR_IS_DOUBLE 133 134 #define GR_MAX_OFFSCREEN_AA_DIM 512 135 136 // Handle exporting using base/component_export.h 137 #define SK_API COMPONENT_EXPORT(SKIA) 138 139 // Log the file and line number for assertions. 140 #if defined(SK_BUILD_FOR_WIN) && !defined(__clang__) 141 // String formatting with this toolchain not supported. 142 #define SkDebugf(...) SkDebugf_FileLineOnly(__FILE__, __LINE__) 143 SK_API void SkDebugf_FileLineOnly(const char* file, int line); 144 #else 145 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, __VA_ARGS__) 146 SK_API void SkDebugf_FileLine(const char* file, 147 int line, 148 const char* format, 149 ...); 150 #endif 151 152 #if !defined(ANDROID) // On Android, we use the skia default settings. 153 #define SK_A32_SHIFT 24 154 #define SK_R32_SHIFT 16 155 #define SK_G32_SHIFT 8 156 #define SK_B32_SHIFT 0 157 #endif 158 159 #if defined(SK_BUILD_FOR_WIN32) 160 161 #define SK_BUILD_FOR_WIN 162 163 // Skia uses this deprecated bzero function to fill zeros into a string. 164 #define bzero(str, len) memset(str, 0, len) 165 166 #elif defined(SK_BUILD_FOR_MAC) 167 168 #define SK_CPU_LENDIAN 169 #undef SK_CPU_BENDIAN 170 171 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) 172 173 // Prefer FreeType's emboldening algorithm to Skia's 174 // TODO: skia used to just use hairline, but has improved since then, so 175 // we should revisit this choice... 176 #define SK_USE_FREETYPE_EMBOLDEN 177 178 #if defined(SK_BUILD_FOR_UNIX) && defined(SK_CPU_BENDIAN) 179 // Above we set the order for ARGB channels in registers. I suspect that, on 180 // big endian machines, you can keep this the same and everything will work. 181 // The in-memory order will be different, of course, but as long as everything 182 // is reading memory as words rather than bytes, it will all work. However, if 183 // you find that colours are messed up I thought that I would leave a helpful 184 // locator for you. Also see the comments in 185 // base/gfx/bitmap_platform_device_linux.h 186 #error Read the comment at this location 187 #endif 188 189 #endif 190 191 // These flags are no longer defined in Skia, but we have them (temporarily) 192 // until we update our call-sites (typically these are for API changes). 193 // 194 // Remove these as we update our sites. 195 // 196 #ifndef SK_SUPPORT_LEGACY_GETTOPDEVICE 197 #define SK_SUPPORT_LEGACY_GETTOPDEVICE 198 #endif 199 200 #ifndef SK_SUPPORT_EXOTIC_CLIPOPS 201 #define SK_SUPPORT_EXOTIC_CLIPOPS 202 #endif 203 204 #ifndef SK_SUPPORT_LEGACY_GETDEVICE 205 #define SK_SUPPORT_LEGACY_GETDEVICE 206 #endif 207 208 // Workaround for poor anisotropic mipmap quality, 209 // pending Skia ripmap support. 210 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863) 211 #ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE 212 #define SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE 213 #endif 214 215 #ifndef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX 216 #define SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX 217 #endif 218 219 #ifndef SK_IGNORE_ETC1_SUPPORT 220 #define SK_IGNORE_ETC1_SUPPORT 221 #endif 222 223 #ifndef SK_IGNORE_GPU_DITHER 224 #define SK_IGNORE_GPU_DITHER 225 #endif 226 227 #ifndef SK_SUPPORT_LEGACY_EVAL_CUBIC 228 #define SK_SUPPORT_LEGACY_EVAL_CUBIC 229 #endif 230 231 ///////////////////////// Imported from BUILD.gn 232 233 /* In some places Skia can use static initializers for global initialization, 234 * or fall back to lazy runtime initialization. Chrome always wants the latter. 235 */ 236 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0 237 238 /* This flag forces Skia not to use typographic metrics with GDI. 239 */ 240 #define SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS 241 242 #define SK_IGNORE_BLURRED_RRECT_OPT 243 #define SK_USE_DISCARDABLE_SCALEDIMAGECACHE 244 #define SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT 245 246 #define SK_ATTR_DEPRECATED SK_NOTHING_ARG1 247 #define SK_ENABLE_INST_COUNT 0 248 #define GR_GL_CUSTOM_SETUP_HEADER "GrGLConfig_chrome.h" 249 250 // Blink layout tests are baselined to Clang optimizing through the UB in 251 // SkDivBits. 252 #define SK_SUPPORT_LEGACY_DIVBITS_UB 253 254 // mtklein's fiddling with Src / SrcOver. Will rebaseline these only once when 255 // done. 256 #define SK_SUPPORT_LEGACY_X86_BLITS 257 258 #define SK_DISABLE_TILE_IMAGE_FILTER_OPTIMIZATION 259 260 #if defined(SK_BUILD_FOR_WIN) && !defined(__clang__) 261 #define SK_ABORT(format, ...) \ 262 SkAbort_FileLine(__FILE__, __LINE__, format, ##__VA_ARGS__) 263 [[noreturn]] SK_API void SkAbort_FileLine(const char* file, 264 int line, 265 const char* format, 266 ...); 267 #endif 268 269 // ===== End Chrome-specific definitions ===== 270 271 #endif // SKIA_CONFIG_SKUSERCONFIG_H_ 272