dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 1 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import("//build/config/features.gni") |
| 6 | import("//build/config/ui.gni") |
| 7 | import("//testing/test.gni") |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 8 | import("//third_party/skia/gn/shared_sources.gni") |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 9 | |
| 10 | if (current_cpu == "arm") { |
| 11 | import("//build/config/arm.gni") |
| 12 | } |
| 13 | if (current_cpu == "mipsel" || current_cpu == "mips64el") { |
| 14 | import("//build/config/mips.gni") |
| 15 | } |
| 16 | |
| 17 | skia_support_gpu = !is_ios |
| 18 | skia_support_pdf = false #!is_ios && (enable_basic_printing || enable_print_preview) |
| 19 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 20 | # External-facing config for dependent code. |
| 21 | config("skia_config") { |
| 22 | include_dirs = [ |
| 23 | "config", |
| 24 | "ext", |
| 25 | "//third_party/skia/include/c", |
Mike Reed | 72b82a8 | 2017-10-16 13:56:53 -0400 | [diff] [blame] | 26 | "//third_party/skia/include/codec", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 27 | "//third_party/skia/include/config", |
| 28 | "//third_party/skia/include/core", |
| 29 | "//third_party/skia/include/effects", |
Hal Canary | 5e57faa | 2017-06-21 09:56:46 -0400 | [diff] [blame] | 30 | "//third_party/skia/include/encode", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 31 | "//third_party/skia/include/images", |
| 32 | "//third_party/skia/include/lazy", |
| 33 | "//third_party/skia/include/pathops", |
| 34 | "//third_party/skia/include/pdf", |
| 35 | "//third_party/skia/include/pipe", |
| 36 | "//third_party/skia/include/ports", |
| 37 | "//third_party/skia/include/utils", |
Cary Clark | f452f56 | 2017-04-27 16:14:47 -0400 | [diff] [blame] | 38 | "//third_party/skia/third_party/vulkan", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 39 | ] |
| 40 | |
| 41 | defines = [] |
| 42 | |
dan sinclair | ecc3c83 | 2017-04-10 10:47:18 -0400 | [diff] [blame] | 43 | if (is_win) { |
| 44 | defines += [ "SK_FREETYPE_MINIMUM_RUNTIME_VERSION=(((FREETYPE_MAJOR) * 0x01000000) | ((FREETYPE_MINOR) * 0x00010000) | ((FREETYPE_PATCH) * 0x00000100))" ] |
| 45 | } |
| 46 | |
| 47 | if (is_component_build) { |
| 48 | defines += [ |
| 49 | "SKIA_DLL", |
| 50 | "GR_GL_IGNORE_ES3_MSAA=0", |
| 51 | ] |
| 52 | } |
| 53 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 54 | if (skia_support_gpu) { |
| 55 | include_dirs += [ |
| 56 | "//third_party/skia/include/gpu", |
| 57 | "//third_party/skia/src/gpu", |
| 58 | ] |
| 59 | defines += [ "SK_SUPPORT_GPU=1" ] |
| 60 | } else { |
| 61 | defines += [ "SK_SUPPORT_GPU=0" ] |
| 62 | } |
| 63 | |
| 64 | if (is_android) { |
| 65 | defines += [ |
| 66 | "SK_BUILD_FOR_ANDROID", |
| 67 | "USE_CHROMIUM_SKIA", |
| 68 | ] |
| 69 | } |
| 70 | |
| 71 | if (is_mac) { |
| 72 | defines += [ "SK_BUILD_FOR_MAC" ] |
| 73 | } |
| 74 | |
| 75 | if (is_win) { |
| 76 | defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ] |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | # Internal-facing config for Skia library code. |
| 81 | config("skia_library_config") { |
| 82 | # These include directories are only included for Skia code and are not |
| 83 | # exported to dependents. It's not clear if this is on purpose, but this |
| 84 | # matches the GYP build. |
| 85 | include_dirs = [ |
| 86 | "//third_party/skia/include/private", |
| 87 | "//third_party/skia/include/client/android", |
| 88 | "//third_party/skia/src/core", |
| 89 | "//third_party/skia/src/image", |
| 90 | "//third_party/skia/src/opts", |
| 91 | "//third_party/skia/src/pdf", |
| 92 | "//third_party/skia/src/ports", |
| 93 | "//third_party/skia/src/sfnt", |
Florin Malita | 05f3359 | 2017-05-25 16:35:02 -0400 | [diff] [blame] | 94 | "//third_party/skia/src/shaders", |
ethannicholas | 52ef14e | 2016-10-12 13:08:18 -0700 | [diff] [blame] | 95 | "//third_party/skia/src/sksl", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 96 | "//third_party/skia/src/utils", |
| 97 | "//third_party/skia/src/lazy", |
| 98 | ] |
| 99 | if (is_mac || is_ios) { |
| 100 | include_dirs += [ "//third_party/skia/include/utils/mac" ] |
| 101 | } |
| 102 | if (is_mac) { |
| 103 | include_dirs += [ "//third_party/skia/include/utils/ios" ] |
| 104 | } |
| 105 | |
| 106 | defines = [] |
| 107 | |
dan sinclair | ecc3c83 | 2017-04-10 10:47:18 -0400 | [diff] [blame] | 108 | if (is_component_build) { |
| 109 | defines += [ "SKIA_IMPLEMENTATION=1" ] |
| 110 | } |
| 111 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 112 | if (current_cpu == "arm") { |
| 113 | if (arm_use_neon) { |
| 114 | defines += [ "SK_ARM_HAS_NEON" ] |
| 115 | } else if (arm_optionally_use_neon) { |
| 116 | defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ] |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | # Settings for text blitting, chosen to approximate the system browser. |
| 121 | if (is_linux) { |
| 122 | defines += [ |
| 123 | "SK_GAMMA_EXPONENT=1.2", |
| 124 | "SK_GAMMA_CONTRAST=0.2", |
| 125 | ] |
| 126 | } else if (is_android) { |
| 127 | defines += [ |
| 128 | "SK_GAMMA_APPLY_TO_A8", |
| 129 | "SK_GAMMA_EXPONENT=1.4", |
| 130 | "SK_GAMMA_CONTRAST=0.0", |
| 131 | ] |
| 132 | } else if (is_win) { |
| 133 | defines += [ |
| 134 | "SK_GAMMA_SRGB", |
| 135 | "SK_GAMMA_CONTRAST=0.5", |
| 136 | ] |
| 137 | } else if (is_mac) { |
| 138 | defines += [ |
| 139 | "SK_GAMMA_SRGB", |
| 140 | "SK_GAMMA_CONTRAST=0.0", |
| 141 | ] |
| 142 | } |
| 143 | |
| 144 | if (is_android) { |
| 145 | defines += [ |
| 146 | # Android devices are typically more memory constrained, so default to a |
| 147 | # smaller glyph cache (it may be overriden at runtime when the renderer |
| 148 | # starts up, depending on the actual device memory). |
| 149 | "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024 |
| 150 | ] |
| 151 | } else { |
| 152 | defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024 |
| 153 | } |
| 154 | |
| 155 | if (is_win) { |
| 156 | include_dirs += [ |
| 157 | "//third_party/skia/include/utils/win", |
| 158 | "//third_party/skia/src/utils/win", |
| 159 | ] |
| 160 | |
| 161 | defines += [ |
| 162 | # On windows, GDI handles are a scarse system-wide resource so we have to |
| 163 | # keep the glyph cache, which holds up to 4 GDI handles per entry, to a |
| 164 | # fairly small size. http://crbug.com/314387 |
| 165 | "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256", |
| 166 | ] |
| 167 | |
| 168 | cflags = [ |
| 169 | "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)' |
| 170 | "/wd4267", # conversion from 'size_t' (64 bit) to 'type'(32 bit). |
| 171 | "/wd4341", # signed value is out of range for enum constant. |
| 172 | "/wd4345", # Object is default-initialized if initialization is omitted. |
| 173 | "/wd4390", # ';'empty statement found in looping;is it what was intended? |
| 174 | "/wd4554", # 'operator' : check operator precedence for possible error |
| 175 | "/wd4748", # compiler will disable optimizations if a function has inline |
| 176 | # assembly code contains flow control(jmp or jcc) statements. |
| 177 | |
| 178 | "/wd4800", # forcing value to bool 'true/false'(assigning int to bool). |
| 179 | ] |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | component("skia") { |
| 184 | sources = [ |
thestig | 19ea309 | 2016-05-13 11:24:26 -0700 | [diff] [blame] | 185 | # PDFium sources. |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 186 | "config/SkUserConfig.h", |
| 187 | "ext/google_logging.cc", |
| 188 | ] |
| 189 | |
Lei Zhang | 65a2192 | 2017-04-15 21:30:32 -0700 | [diff] [blame] | 190 | # The skia sources values are relative to the skia_dir, so we need to rebase. |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 191 | sources += skia_core_sources |
| 192 | sources += skia_effects_sources |
ethannicholas | 52ef14e | 2016-10-12 13:08:18 -0700 | [diff] [blame] | 193 | sources += skia_sksl_sources |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 194 | sources += skia_utils_sources |
| 195 | sources += [ |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 196 | "//third_party/skia/src/fonts/SkFontMgr_indirect.cpp", |
| 197 | "//third_party/skia/src/fonts/SkRemotableFontMgr.cpp", |
Hal Canary | 5e57faa | 2017-06-21 09:56:46 -0400 | [diff] [blame] | 198 | "//third_party/skia/src/images/SkImageEncoder.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 199 | "//third_party/skia/src/ports/SkFontHost_FreeType.cpp", |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 200 | "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 201 | "//third_party/skia/src/ports/SkFontHost_win.cpp", |
| 202 | "//third_party/skia/src/ports/SkFontMgr_android.cpp", |
| 203 | "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp", |
| 204 | "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp", |
| 205 | "//third_party/skia/src/ports/SkGlobalInitialization_default.cpp", |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 206 | "//third_party/skia/src/ports/SkImageGenerator_none.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 207 | "//third_party/skia/src/ports/SkOSFile_posix.cpp", |
| 208 | "//third_party/skia/src/ports/SkOSFile_stdio.cpp", |
| 209 | "//third_party/skia/src/ports/SkOSFile_win.cpp", |
| 210 | "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp", |
| 211 | "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp", |
| 212 | "//third_party/skia/src/ports/SkTLS_pthread.cpp", |
| 213 | "//third_party/skia/src/ports/SkTLS_win.cpp", |
| 214 | "//third_party/skia/src/ports/SkTypeface_win_dw.cpp", |
| 215 | "//third_party/skia/src/sfnt/SkOTTable_name.cpp", |
| 216 | "//third_party/skia/src/sfnt/SkOTUtils.cpp", |
| 217 | |
| 218 | #mac |
| 219 | "//third_party/skia/src/utils/mac/SkStream_mac.cpp", |
| 220 | |
| 221 | #pdfium |
| 222 | "//third_party/skia/src/ports/SkDiscardableMemory_none.cpp", |
| 223 | "//third_party/skia/src/ports/SkFontMgr_custom.cpp", |
Ben Wanger | 9d5fd1d | 2017-02-09 11:21:11 -0500 | [diff] [blame] | 224 | "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 225 | "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", |
| 226 | "//third_party/skia/src/ports/SkMemory_malloc.cpp", |
| 227 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 228 | |
| 229 | # This and skia_opts are really the same conceptual target so share headers. |
| 230 | allow_circular_includes_from = [ ":skia_opts" ] |
| 231 | |
| 232 | if (current_cpu == "arm") { |
| 233 | sources += [ "//third_party/skia/src/core/SkUtilsArm.cpp" ] |
| 234 | } |
| 235 | |
| 236 | # GPU |
| 237 | if (skia_support_gpu) { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 238 | sources += skia_gpu_sources |
| 239 | sources += skia_null_gpu_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Lei Zhang | 65a2192 | 2017-04-15 21:30:32 -0700 | [diff] [blame] | 242 | # Remove unused util files include in utils.gni |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 243 | sources -= [ |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 244 | "//third_party/skia/src/utils/SkCamera.cpp", |
| 245 | "//third_party/skia/src/utils/SkDumpCanvas.cpp", |
| 246 | "//third_party/skia/src/utils/SkFrontBufferedStream.cpp", |
| 247 | "//third_party/skia/src/utils/SkInterpolator.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 248 | "//third_party/skia/src/utils/SkParsePath.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 249 | ] |
| 250 | |
| 251 | if (is_win) { |
| 252 | sources -= [ |
| 253 | # Keeping _win.cpp |
| 254 | "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp", |
| 255 | ] |
| 256 | } else { |
| 257 | sources -= [ |
| 258 | # Keeping _pthread.cpp |
| 259 | "//third_party/skia/src/utils/SkThreadUtils_win.cpp", |
| 260 | ] |
| 261 | } |
| 262 | |
| 263 | # need separate win section to handle chromes auto gn filter |
| 264 | # (build/config/BUILDCONFIG.gn) |
| 265 | if (is_win) { |
| 266 | sources -= [ |
| 267 | #windows |
| 268 | "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp", |
| 269 | "//third_party/skia/src/utils/win/SkIStream.cpp", |
| 270 | "//third_party/skia/src/utils/win/SkWGL_win.cpp", |
| 271 | ] |
| 272 | } |
| 273 | |
| 274 | # Fixup skia library sources. |
| 275 | if (is_win) { |
| 276 | sources -= [ |
| 277 | "//third_party/skia/src/ports/SkOSFile_posix.cpp", |
| 278 | "//third_party/skia/src/ports/SkTLS_pthread.cpp", |
| 279 | ] |
| 280 | } else { |
| 281 | sources -= [ |
| 282 | "//third_party/skia/src/ports/SkFontHost_win.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 283 | "//third_party/skia/src/ports/SkOSFile_win.cpp", |
| 284 | "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp", |
| 285 | "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp", |
| 286 | "//third_party/skia/src/ports/SkTLS_win.cpp", |
| 287 | "//third_party/skia/src/ports/SkTypeface_win_dw.cpp", |
| 288 | ] |
| 289 | } |
| 290 | if (!is_android) { |
| 291 | sources -= [ |
| 292 | "//third_party/skia/src/ports/SkFontMgr_android.cpp", |
| 293 | "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp", |
| 294 | "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp", |
| 295 | ] |
| 296 | } |
caryclark | 8b30162 | 2016-07-21 06:12:33 -0700 | [diff] [blame] | 297 | if (!is_linux && !is_android && !is_win && !is_mac) { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 298 | sources -= [ |
| 299 | "//third_party/skia/src/ports/SkFontHost_FreeType.cpp", |
| 300 | "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp", |
weili | ca0bc7d | 2016-06-22 07:24:20 -0700 | [diff] [blame] | 301 | "//third_party/skia/src/ports/SkFontMgr_custom.cpp", |
| 302 | "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 303 | ] |
| 304 | } |
| 305 | |
| 306 | if (is_clang && !is_nacl) { |
| 307 | # Skia won't compile with some of the more strict clang warnings. |
| 308 | # e.g. it does: |
| 309 | # SkASSERT(!"sk_out_of_memory"); |
| 310 | configs -= [ "//build/config/clang:extra_warnings" ] |
| 311 | } |
| 312 | |
| 313 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 314 | configs += [ |
| 315 | ":skia_config", |
| 316 | ":skia_library_config", |
| 317 | "//build/config/compiler:no_chromium_code", |
| 318 | ] |
| 319 | public_configs = [ ":skia_config" ] |
| 320 | |
| 321 | deps = [ |
| 322 | ":skia_opts", |
Miklos Vajna | 2df760f | 2017-05-06 01:54:54 +0200 | [diff] [blame] | 323 | "../third_party:zlib", |
Lei Zhang | eb39cdb | 2017-03-31 12:26:15 -0700 | [diff] [blame] | 324 | "//:freetype_common", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 325 | ] |
| 326 | |
| 327 | if (is_linux) { |
caryclark | 72708b9 | 2016-06-13 06:08:25 -0700 | [diff] [blame] | 328 | deps += [ "//third_party/icu:icuuc" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | if (is_android) { |
| 332 | set_sources_assignment_filter([]) |
| 333 | set_sources_assignment_filter(sources_assignment_filter) |
| 334 | deps += [ |
| 335 | "//third_party/android_tools:cpu_features", |
| 336 | "//third_party/expat", |
| 337 | "//third_party/freetype-android:freetype", |
| 338 | ] |
| 339 | } |
| 340 | |
| 341 | if (skia_support_pdf) { |
| 342 | deps += [ "//third_party/sfntly" ] |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 343 | sources += skia_pdf_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 344 | } else { |
| 345 | sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ] |
| 346 | } |
| 347 | |
| 348 | if (is_android && !is_debug) { |
| 349 | configs -= [ "//build/config/compiler:default_optimization" ] |
| 350 | configs += [ "//build/config/compiler:optimize_max" ] |
| 351 | } |
| 352 | |
| 353 | if (is_ios) { |
| 354 | libs = [ "ImageIO.framework" ] |
| 355 | set_sources_assignment_filter([]) |
| 356 | sources += [ |
| 357 | "//third_party/skia/src/ports/SkFontHost_mac.cpp", |
| 358 | "//third_party/skia/src/utils/mac/SkCreateCGImageRef.cpp", |
| 359 | "//third_party/skia/src/utils/mac/SkStream_mac.cpp", |
| 360 | ] |
| 361 | set_sources_assignment_filter(sources_assignment_filter) |
| 362 | |
| 363 | # To disable warning "CGContextSelectFont' is deprecated" |
| 364 | cflags = [ "-Wno-deprecated-declarations" ] |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | # Separated out so it can be compiled with different flags for SSE. |
| 369 | if (current_cpu == "x86" || current_cpu == "x64") { |
| 370 | source_set("skia_opts_sse3") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 371 | sources = skia_opts.ssse3_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 372 | if (!is_win || is_clang) { |
| 373 | cflags = [ "-mssse3" ] |
| 374 | } |
| 375 | if (is_win) { |
| 376 | defines = [ "SK_CPU_SSE_LEVEL=31" ] |
| 377 | } |
| 378 | visibility = [ ":skia_opts" ] |
| 379 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 380 | configs += [ |
| 381 | ":skia_config", |
| 382 | ":skia_library_config", |
| 383 | "//build/config/compiler:no_chromium_code", |
| 384 | ] |
| 385 | } |
| 386 | source_set("skia_opts_sse41") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 387 | sources = skia_opts.sse41_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 388 | if (!is_win || is_clang) { |
| 389 | cflags = [ "-msse4.1" ] |
| 390 | } |
| 391 | if (is_win) { |
| 392 | defines = [ "SK_CPU_SSE_LEVEL=41" ] |
| 393 | } |
| 394 | visibility = [ ":skia_opts" ] |
| 395 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 396 | configs += [ |
| 397 | ":skia_config", |
| 398 | ":skia_library_config", |
| 399 | "//build/config/compiler:no_chromium_code", |
| 400 | ] |
| 401 | } |
| 402 | source_set("skia_opts_sse42") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 403 | sources = skia_opts.sse42_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 404 | if (!is_win || is_clang) { |
| 405 | cflags = [ "-msse4.2" ] |
| 406 | } |
| 407 | if (is_win) { |
| 408 | defines = [ "SK_CPU_SSE_LEVEL=42" ] |
| 409 | } |
| 410 | visibility = [ ":skia_opts" ] |
| 411 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 412 | configs += [ |
| 413 | ":skia_config", |
| 414 | ":skia_library_config", |
| 415 | "//build/config/compiler:no_chromium_code", |
| 416 | ] |
| 417 | } |
| 418 | source_set("skia_opts_avx") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 419 | sources = skia_opts.avx_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 420 | if (!is_win) { |
| 421 | cflags = [ "-mavx" ] |
| 422 | } |
| 423 | if (is_win) { |
| 424 | cflags = [ "/arch:AVX" ] |
| 425 | } |
| 426 | visibility = [ ":skia_opts" ] |
| 427 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 428 | configs += [ |
| 429 | ":skia_config", |
| 430 | ":skia_library_config", |
| 431 | "//build/config/compiler:no_chromium_code", |
| 432 | ] |
| 433 | } |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 434 | source_set("skia_opts_hsw") { |
| 435 | sources = skia_opts.hsw_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 436 | if (!is_win) { |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 437 | cflags = [ |
| 438 | "-mavx2", |
| 439 | "-mbmi", |
| 440 | "-mbmi2", |
| 441 | "-mf16c", |
| 442 | "-mfma", |
| 443 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 444 | } |
| 445 | if (is_win) { |
| 446 | cflags = [ "/arch:AVX2" ] |
| 447 | } |
| 448 | visibility = [ ":skia_opts" ] |
| 449 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 450 | configs += [ |
| 451 | ":skia_config", |
| 452 | ":skia_library_config", |
| 453 | "//build/config/compiler:no_chromium_code", |
| 454 | ] |
| 455 | } |
| 456 | } |
| 457 | source_set("skia_opts") { |
| 458 | cflags = [] |
| 459 | defines = [] |
| 460 | |
| 461 | if (current_cpu == "x86" || current_cpu == "x64") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 462 | sources = skia_opts.sse2_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 463 | deps = [ |
| 464 | ":skia_opts_avx", |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 465 | ":skia_opts_hsw", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 466 | ":skia_opts_sse3", |
| 467 | ":skia_opts_sse41", |
| 468 | ":skia_opts_sse42", |
| 469 | ] |
| 470 | } else if (current_cpu == "arm") { |
| 471 | # The assembly uses the frame pointer register (r7 in Thumb/r11 in |
| 472 | # ARM), the compiler doesn't like that. |
| 473 | cflags += [ "-fomit-frame-pointer" ] |
| 474 | |
| 475 | if (arm_version >= 7) { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 476 | sources = skia_opts.armv7_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 477 | if (arm_use_neon || arm_optionally_use_neon) { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 478 | sources += skia_opts.neon_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 479 | |
| 480 | # Root build config sets -mfpu=$arm_fpu, which we expect to be neon |
| 481 | # when running this. |
| 482 | if (!arm_use_neon) { |
| 483 | configs -= [ "//build/config/compiler:compiler_arm_fpu" ] |
| 484 | cflags += [ "-mfpu=neon" ] |
| 485 | } |
| 486 | } |
| 487 | } else { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 488 | sources = skia_opts.none_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 489 | } |
| 490 | } else if (current_cpu == "arm64") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 491 | sources = skia_opts.arm64_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 492 | } else if (current_cpu == "mipsel") { |
| 493 | cflags += [ "-fomit-frame-pointer" ] |
| 494 | |
| 495 | if (mips_dsp_rev >= 1) { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 496 | sources = skia_opts.mips_dsp_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 497 | } else { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 498 | sources = skia_opts.none_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 499 | } |
| 500 | } else if (current_cpu == "mips64el") { |
| 501 | cflags += [ "-fomit-frame-pointer" ] |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 502 | sources = skia_opts.none_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 503 | } else { |
Lei Zhang | 65a2192 | 2017-04-15 21:30:32 -0700 | [diff] [blame] | 504 | assert(false, "Need to port cpu specific stuff from gn/BUILDCONFIG.gn") |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | if (is_android && !is_debug) { |
| 508 | configs -= [ "//build/config/compiler:default_optimization" ] |
| 509 | configs += [ "//build/config/compiler:optimize_max" ] |
| 510 | } |
| 511 | |
| 512 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 513 | configs += [ |
| 514 | ":skia_config", |
| 515 | ":skia_library_config", |
| 516 | "//build/config/compiler:no_chromium_code", |
| 517 | ] |
| 518 | |
| 519 | visibility = [ ":skia" ] |
| 520 | } |