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.
5 import("//build/config/features.gni")
6 import("//build/config/ui.gni")
7 import("//testing/test.gni")
8 if (current_cpu == "arm") {
9 import("//build/config/arm.gni")
11 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
12 import("//build/config/mips.gni")
15 skia_support_gpu = !is_ios
16 skia_support_pdf = !is_ios && (enable_basic_printing || enable_print_preview)
18 # The list of Skia defines that are to be set for blink.
19 gypi_blink_skia_defines =
20 exec_script("//build/gypi_to_gn.py",
23 "//third_party/WebKit/public/blink_skia_config.gypi"),
24 "--replace=<(skia_include_path)=//third_party/skia/include",
25 "--replace=<(skia_src_path)=//third_party/skia/src",
28 [ "//third_party/WebKit/public/blink_skia_config.gypi" ])
30 # The list of Skia defines that are to be set for chromium.
32 exec_script("//build/gypi_to_gn.py",
35 "//third_party/skia/gyp/skia_for_chromium_defines.gypi"),
36 "--replace=<(skia_include_path)=//third_party/skia/include",
37 "--replace=<(skia_src_path)=//third_party/skia/src",
40 [ "//third_party/skia/gyp/skia_for_chromium_defines.gypi" ])
42 # The list of Skia core sources that are to be set for chromium.
44 exec_script("//build/gypi_to_gn.py",
46 rebase_path("//third_party/skia/gyp/core.gypi"),
47 "--replace=<(skia_include_path)=//third_party/skia/include",
48 "--replace=<(skia_src_path)=//third_party/skia/src",
51 [ "//third_party/skia/gyp/core.gypi" ])
53 # The list of Skia gpu sources that are to be set for chromium.
54 if (skia_support_gpu) {
56 exec_script("//build/gypi_to_gn.py",
58 rebase_path("//third_party/skia/gyp/gpu.gypi"),
59 "--replace=<(skia_include_path)=//third_party/skia/include",
60 "--replace=<(skia_src_path)=//third_party/skia/src",
63 [ "//third_party/skia/gyp/gpu.gypi" ])
66 # The list of Skia pdf sources that are to be set for chromium.
67 if (skia_support_pdf) {
69 exec_script("//build/gypi_to_gn.py",
71 rebase_path("//third_party/skia/gyp/pdf.gypi"),
72 "--replace=<(skia_include_path)=//third_party/skia/include",
73 "--replace=<(skia_src_path)=//third_party/skia/src",
76 [ "//third_party/skia/gyp/pdf.gypi" ])
79 # The list of Skia effects that are to be set for chromium.
81 exec_script("//build/gypi_to_gn.py",
83 rebase_path("//third_party/skia/gyp/effects.gypi"),
84 "--replace=<(skia_include_path)=//third_party/skia/include",
85 "--replace=<(skia_src_path)=//third_party/skia/src",
88 [ "//third_party/skia/gyp/effects.gypi" ])
90 # The list of Skia utils that are to be set for chromium.
92 exec_script("//build/gypi_to_gn.py",
94 rebase_path("//third_party/skia/gyp/utils.gypi"),
95 "--replace=<(skia_include_path)=//third_party/skia/include",
96 "--replace=<(skia_src_path)=//third_party/skia/src",
99 [ "//third_party/skia/gyp/utils.gypi" ])
102 exec_script("//build/gypi_to_gn.py",
104 rebase_path("//third_party/skia/gyp/opts.gypi"),
105 "--replace=<(skia_include_path)=//third_party/skia/include",
106 "--replace=<(skia_src_path)=//third_party/skia/src",
109 [ "//third_party/skia/gyp/opts.gypi" ])
111 # The list of Skia files is kept in skia_gn_files.gypi. Read it.
113 exec_script("//build/gypi_to_gn.py",
115 rebase_path("skia_gn_files.gypi"),
116 "--replace=<(skia_include_path)=//third_party/skia/include",
117 "--replace=<(skia_src_path)=//third_party/skia/src",
120 [ "skia_gn_files.gypi" ])
122 # External-facing config for dependent code.
123 config("skia_config") {
127 "//third_party/skia/include/c",
128 "//third_party/skia/include/config",
129 "//third_party/skia/include/core",
130 "//third_party/skia/include/effects",
131 "//third_party/skia/include/images",
132 "//third_party/skia/include/lazy",
133 "//third_party/skia/include/pathops",
134 "//third_party/skia/include/pdf",
135 "//third_party/skia/include/pipe",
136 "//third_party/skia/include/ports",
137 "//third_party/skia/include/utils",
140 defines = gypi_blink_skia_defines.blink_skia_defines
141 defines += gypi_skia_defines.skia_for_chromium_defines
145 if (is_component_build) {
148 "GR_GL_IGNORE_ES3_MSAA=0",
152 if (skia_support_gpu) {
154 "//third_party/skia/include/gpu",
155 "//third_party/skia/src/gpu",
157 defines += [ "SK_SUPPORT_GPU=1" ]
159 defines += [ "SK_SUPPORT_GPU=0" ]
164 "SK_BUILD_FOR_ANDROID",
170 defines += [ "SK_BUILD_FOR_MAC" ]
174 defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
178 # Internal-facing config for Skia library code.
179 config("skia_library_config") {
180 # These include directories are only included for Skia code and are not
181 # exported to dependents. It's not clear if this is on purpose, but this
182 # matches the GYP build.
184 "//third_party/skia/include/private",
185 "//third_party/skia/src/core",
186 "//third_party/skia/src/image",
187 "//third_party/skia/src/opts",
188 "//third_party/skia/src/pdf",
189 "//third_party/skia/src/ports",
190 "//third_party/skia/src/sfnt",
191 "//third_party/skia/src/utils",
192 "//third_party/skia/src/lazy",
194 if (is_mac || is_ios) {
195 include_dirs += [ "//third_party/skia/include/utils/mac" ]
198 include_dirs += [ "//third_party/skia/include/utils/ios" ]
203 if (is_component_build) {
204 defines += [ "SKIA_IMPLEMENTATION=1" ]
207 if (current_cpu == "arm") {
209 defines += [ "SK_ARM_HAS_NEON" ]
210 } else if (arm_optionally_use_neon) {
211 defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
215 # Settings for text blitting, chosen to approximate the system browser.
218 "SK_GAMMA_EXPONENT=1.2",
219 "SK_GAMMA_CONTRAST=0.2",
221 } else if (is_android) {
223 "SK_GAMMA_APPLY_TO_A8",
224 "SK_GAMMA_EXPONENT=1.4",
225 "SK_GAMMA_CONTRAST=0.0",
230 "SK_GAMMA_CONTRAST=0.5",
235 "SK_GAMMA_CONTRAST=0.0",
241 # Android devices are typically more memory constrained, so default to a
242 # smaller glyph cache (it may be overriden at runtime when the renderer
243 # starts up, depending on the actual device memory).
244 "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
247 defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
252 "//third_party/skia/include/utils/win",
253 "//third_party/skia/src/utils/win",
257 # On windows, GDI handles are a scarse system-wide resource so we have to
258 # keep the glyph cache, which holds up to 4 GDI handles per entry, to a
259 # fairly small size. http://crbug.com/314387
260 "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
264 "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
265 "/wd4267", # conversion from 'size_t' (64 bit) to 'type'(32 bit).
266 "/wd4341", # signed value is out of range for enum constant.
267 "/wd4345", # Object is default-initialized if initialization is omitted.
268 "/wd4390", # ';'empty statement found in looping;is it what was intended?
269 "/wd4554", # 'operator' : check operator precedence for possible error
270 "/wd4748", # compiler will disable optimizations if a function has inline
271 # assembly code contains flow control(jmp or jcc) statements.
273 "/wd4800", # forcing value to bool 'true/false'(assigning int to bool).
281 "ext/SkDiscardableMemory_chrome.cc",
282 "ext/SkMemory_new_handler.cpp",
283 "ext/analysis_canvas.cc",
284 "ext/benchmarking_canvas.cc",
286 "ext/event_tracer_impl.cc",
287 "ext/fontmgr_default_win.cc",
288 "ext/google_logging.cc",
289 "ext/image_operations.cc",
290 "ext/opacity_filter_canvas.cc",
291 "ext/pixel_ref_utils.cc",
292 "ext/platform_canvas.cc",
293 "ext/platform_device.cc",
294 "ext/platform_device_linux.cc",
295 "ext/platform_device_mac.cc",
296 "ext/platform_device_win.cc",
297 "ext/recursive_gaussian_convolution.cc",
298 "ext/skia_memory_dump_provider.cc",
299 "ext/skia_utils_base.cc",
300 "ext/skia_utils_ios.mm",
301 "ext/skia_utils_mac.mm",
302 "ext/skia_utils_win.cc",
305 if (current_cpu == "x86" || current_cpu == "x64") {
306 sources += [ "ext/convolver_SSE2.cc" ]
307 } else if (current_cpu == "mipsel" && mips_dsp_rev >= 2) {
308 sources += [ "ext/convolver_mips_dspr2.cc" ]
311 # The skia gypi values are relative to the skia_dir, so we need to rebase.
312 sources += gypi_skia_core.sources
313 sources += gypi_skia_effects.sources
314 sources += gypi_skia_utils.sources
315 sources += gypi_values.skia_library_sources
317 # This and skia_opts are really the same conceptual target so share headers.
318 allow_circular_includes_from = [ ":skia_opts" ]
320 if (current_cpu == "arm") {
321 sources += [ "//third_party/skia/src/core/SkUtilsArm.cpp" ]
325 if (skia_support_gpu) {
326 sources += gypi_skia_gpu.skgpu_sources
327 sources += gypi_skia_gpu.skgpu_null_gl_sources
330 # Remove unused util files include in utils.gypi
332 "//third_party/skia/src/utils/SkBitmapHasher.cpp",
333 "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
334 "//third_party/skia/src/utils/SkCamera.cpp",
335 "//third_party/skia/src/utils/SkCubicInterval.cpp",
336 "//third_party/skia/src/utils/SkCullPoints.cpp",
337 "//third_party/skia/src/utils/SkDumpCanvas.cpp",
338 "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
339 "//third_party/skia/src/utils/SkInterpolator.cpp",
340 "//third_party/skia/src/utils/SkLayer.cpp",
341 "//third_party/skia/src/utils/SkMD5.cpp",
342 "//third_party/skia/src/utils/SkMeshUtils.cpp",
343 "//third_party/skia/src/utils/SkNinePatch.cpp",
344 "//third_party/skia/src/utils/SkOSFile.cpp",
345 "//third_party/skia/src/utils/SkParsePath.cpp",
346 "//third_party/skia/src/utils/SkSHA1.cpp",
348 # We don't currently need to change thread affinity, so leave out this complexity for now.
349 "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
350 "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
353 "//third_party/skia/src/fonts/SkGScalerContext.cpp",
359 "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
360 "//third_party/skia/src/utils/SkThreadUtils_pthread_other.cpp",
364 # Keeping _pthread.cpp and _pthread_other.cpp.
365 "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
369 # need separate win section to handle chromes auto gn filter
370 # (build/config/BUILDCONFIG.gn)
374 "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
375 "//third_party/skia/src/utils/win/SkIStream.cpp",
376 "//third_party/skia/src/utils/win/SkWGL_win.cpp",
380 if (is_android && (!enable_basic_printing && !enable_print_preview)) {
381 sources -= [ "ext/skia_utils_base.cc" ]
384 # Fixup skia library sources.
387 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
388 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
389 "//third_party/skia/src/ports/SkTime_Unix.cpp",
393 "//third_party/skia/src/ports/SkFontHost_win.cpp",
394 "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
395 "//third_party/skia/src/ports/SkOSFile_win.cpp",
396 "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
397 "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
398 "//third_party/skia/src/ports/SkTLS_win.cpp",
399 "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
404 "//third_party/skia/src/ports/SkFontMgr_android.cpp",
405 "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
406 "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
410 sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
415 "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
416 "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
417 "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
421 if (!is_linux && !is_android) {
423 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
424 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
428 # Select the right BitmapPlatformDevice.
430 sources += [ "ext/bitmap_platform_device_win.cc" ]
432 sources += [ "ext/bitmap_platform_device_mac.cc" ]
433 } else if (use_cairo) {
434 sources += [ "ext/bitmap_platform_device_cairo.cc" ]
436 sources += [ "ext/bitmap_platform_device_skia.cc" ]
440 # Skia won't compile with some of the more strict clang warnings.
442 # SkASSERT(!"sk_out_of_memory");
443 configs -= [ "//build/config/clang:extra_warnings" ]
446 configs -= [ "//build/config/compiler:chromium_code" ]
448 ":skia_library_config",
449 "//build/config:precompiled_headers",
450 "//build/config/compiler:no_chromium_code",
452 public_configs = [ ":skia_config" ]
457 "//base/third_party/dynamic_annotations",
458 "//third_party/zlib",
463 "//build/config/linux:fontconfig",
464 "//build/config/linux:freetype2",
467 configs += [ "//build/config/linux:pangocairo" ]
469 deps += [ "//third_party/icu:icuuc" ]
473 set_sources_assignment_filter([])
474 sources += [ "ext/platform_device_linux.cc" ]
475 set_sources_assignment_filter(sources_assignment_filter)
477 "//third_party/expat",
478 "//third_party/freetype-android:freetype",
479 "//third_party/android_tools:cpu_features",
483 if (skia_support_pdf) {
484 deps += [ "//third_party/sfntly" ]
485 sources += gypi_skia_pdf.sources
488 if (is_android && !is_debug) {
489 configs -= [ "//build/config/compiler:optimize" ]
490 configs += [ "//build/config/compiler:optimize_max" ]
494 # Separated out so it can be compiled with different flags for SSE.
495 if (current_cpu == "x86" || current_cpu == "x64") {
496 source_set("skia_opts_sse3") {
497 sources = gypi_skia_opts.ssse3_sources
498 if (!is_win || is_clang) {
499 cflags = [ "-mssse3" ]
502 defines = [ "SK_CPU_SSE_LEVEL=31" ]
504 visibility = [ ":skia_opts" ]
505 configs -= [ "//build/config/compiler:chromium_code" ]
508 ":skia_library_config",
509 "//build/config/compiler:no_chromium_code",
512 source_set("skia_opts_sse4") {
513 sources = gypi_skia_opts.sse41_sources
514 if (!is_win || is_clang) {
515 cflags = [ "-msse4.1" ]
518 defines = [ "SK_CPU_SSE_LEVEL=41" ]
520 visibility = [ ":skia_opts" ]
521 configs -= [ "//build/config/compiler:chromium_code" ]
524 ":skia_library_config",
525 "//build/config/compiler:no_chromium_code",
529 source_set("skia_opts") {
537 if (current_cpu == "x86" || current_cpu == "x64") {
538 sources = gypi_skia_opts.sse2_sources
543 } else if (current_cpu == "arm") {
544 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
545 # ARM), the compiler doesn't like that.
546 cflags += [ "-fomit-frame-pointer" ]
548 if (arm_version >= 7) {
549 sources = gypi_skia_opts.armv7_sources
550 if (arm_use_neon || arm_optionally_use_neon) {
551 sources += gypi_skia_opts.neon_sources
553 # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
556 configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
557 cflags += [ "-mfpu=neon" ]
561 sources = gypi_skia_opts.none_sourcees
563 } else if (current_cpu == "mipsel") {
564 cflags += [ "-fomit-frame-pointer" ]
566 if (mips_dsp_rev >= 1) {
567 sources = gypi_skia_opts.mips_dsp_sources
569 sources = gypi_skia_opts.none_sources
572 assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
575 if (is_android && !is_debug) {
576 configs -= [ "//build/config/compiler:optimize" ]
577 configs += [ "//build/config/compiler:optimize_max" ]
580 configs -= [ "//build/config/compiler:chromium_code" ]
583 ":skia_library_config",
584 "//build/config/compiler:no_chromium_code",
587 visibility = [ ":skia" ]
590 # TODO(GYP): Delete this after we've converted everything to GN.
591 # The _run targets exist only for compatibility w/ GYP.
592 group("skia_unittests_run") {
599 test("skia_unittests") {
601 "ext/analysis_canvas_unittest.cc",
602 "ext/bitmap_platform_device_mac_unittest.cc",
603 "ext/convolver_unittest.cc",
604 "ext/image_operations_unittest.cc",
605 "ext/pixel_ref_utils_unittest.cc",
606 "ext/platform_canvas_unittest.cc",
607 "ext/recursive_gaussian_convolution_unittest.cc",
608 "ext/refptr_unittest.cc",
609 "ext/skia_memory_dump_provider_unittest.cc",
610 "ext/skia_utils_ios_unittest.mm",
611 "ext/skia_utils_mac_unittest.mm",
614 if (!is_win && !is_mac) {
615 sources -= [ "ext/platform_canvas_unittest.cc" ]
621 "//base/test:run_all_unittests",
622 "//cc:test_support", # TODO: Fix this test to not depend on cc.
629 if (is_linux && !is_chromeos) {
630 # TODO(GYP): Figure out which of these work and are needed on other platforms.
631 executable("image_operations_bench") {
633 "ext/image_operations_bench.cc",
642 executable("filter_fuzz_stub") {
645 "tools/filter_fuzz_stub/filter_fuzz_stub.cc",
651 "//base/test:test_support",