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 (component_mode == "shared_library") {
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 # Internal-facing config for Skia library code.
175 config("skia_library_config") {
176 # These include directories are only included for Skia code and are not
177 # exported to dependents. It's not clear if this is on purpose, but this
178 # matches the GYP build.
180 "//third_party/skia/src/core",
181 "//third_party/skia/src/image",
182 "//third_party/skia/src/opts",
183 "//third_party/skia/src/pdf",
184 "//third_party/skia/src/ports",
185 "//third_party/skia/src/sfnt",
186 "//third_party/skia/src/utils",
187 "//third_party/skia/src/lazy",
189 if (is_mac || is_ios) {
190 include_dirs += [ "//third_party/skia/include/utils/mac" ]
193 include_dirs += [ "//third_party/skia/include/utils/ios" ]
198 if (component_mode == "shared_library") {
199 defines += [ "SKIA_IMPLEMENTATION=1" ]
202 if (current_cpu == "arm") {
204 defines += [ "SK_ARM_HAS_NEON" ]
206 if (arm_optionally_use_neon) {
207 defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
211 # Settings for text blitting, chosen to approximate the system browser.
214 "SK_GAMMA_EXPONENT=1.2",
215 "SK_GAMMA_CONTRAST=0.2",
216 "SK_HIGH_QUALITY_IS_LANCZOS",
218 } else if (is_android) {
220 "SK_GAMMA_APPLY_TO_A8",
221 "SK_GAMMA_EXPONENT=1.4",
222 "SK_GAMMA_CONTRAST=0.0",
227 "SK_GAMMA_CONTRAST=0.5",
228 "SK_HIGH_QUALITY_IS_LANCZOS",
233 "SK_GAMMA_CONTRAST=0.0",
234 "SK_HIGH_QUALITY_IS_LANCZOS",
240 # Android devices are typically more memory constrained, so default to a
241 # smaller glyph cache (it may be overriden at runtime when the renderer
242 # starts up, depending on the actual device memory).
243 "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
246 defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
251 "//third_party/skia/include/utils/win",
252 "//third_party/skia/src/utils/win",
256 # On windows, GDI handles are a scarse system-wide resource so we have to
257 # keep the glyph cache, which holds up to 4 GDI handles per entry, to a
258 # fairly small size. http://crbug.com/314387
259 "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
263 "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
264 "/wd4267", # conversion from 'size_t' (64 bit) to 'type'(32 bit).
265 "/wd4341", # signed value is out of range for enum constant.
266 "/wd4345", # Object is default-initialized if initialization is omitted.
267 "/wd4390", # ';'empty statement found in looping;is it what was intended?
268 "/wd4554", # 'operator' : check operator precedence for possible error
269 "/wd4748", # compiler will disable optimizations if a function has inline
270 # assembly code contains flow control(jmp or jcc) statements.
272 "/wd4800", # forcing value to bool 'true/false'(assigning int to bool).
280 "config/SkUserConfig.h",
281 "ext/SkDiscardableMemory_chrome.cc",
282 "ext/SkDiscardableMemory_chrome.h",
283 "ext/SkMemory_new_handler.cpp",
284 "ext/analysis_canvas.cc",
285 "ext/analysis_canvas.h",
286 "ext/benchmarking_canvas.cc",
287 "ext/benchmarking_canvas.h",
288 "ext/bitmap_platform_device.h",
291 "ext/event_tracer_impl.cc",
292 "ext/event_tracer_impl.h",
293 "ext/fontmgr_default_win.cc",
294 "ext/fontmgr_default_win.h",
295 "ext/google_logging.cc",
296 "ext/image_operations.cc",
297 "ext/image_operations.h",
298 "ext/opacity_draw_filter.cc",
299 "ext/opacity_draw_filter.h",
300 "ext/pixel_ref_utils.cc",
301 "ext/pixel_ref_utils.h",
302 "ext/platform_canvas.cc",
303 "ext/platform_canvas.h",
304 "ext/platform_device.cc",
305 "ext/platform_device.h",
306 "ext/platform_device_linux.cc",
307 "ext/platform_device_mac.cc",
308 "ext/platform_device_win.cc",
309 "ext/recursive_gaussian_convolution.cc",
310 "ext/recursive_gaussian_convolution.h",
312 "ext/skia_utils_base.cc",
313 "ext/skia_utils_base.h",
314 "ext/skia_utils_ios.h",
315 "ext/skia_utils_ios.mm",
316 "ext/skia_utils_mac.h",
317 "ext/skia_utils_mac.mm",
318 "ext/skia_utils_win.cc",
319 "ext/skia_utils_win.h",
322 # The skia gypi values are relative to the skia_dir, so we need to rebase.
323 sources += gypi_skia_core.sources
324 sources += gypi_skia_effects.sources
325 sources += gypi_skia_utils.sources
326 sources += gypi_values.skia_library_sources
328 # This and skia_opts are really the same conceptual target so share headers.
329 allow_circular_includes_from = [ ":skia_opts" ]
331 if (current_cpu == "arm") {
333 "//third_party/skia/src/core/SkUtilsArm.cpp",
334 "//third_party/skia/src/core/SkUtilsArm.h",
339 if (skia_support_gpu) {
340 sources += gypi_skia_gpu.skgpu_sources
341 sources += gypi_skia_gpu.skgpu_null_gl_sources
344 # Remove unused util files include in utils.gypi
346 "//third_party/skia/include/utils/SkBoundaryPatch.h",
347 "//third_party/skia/include/utils/SkCamera.h",
348 "//third_party/skia/include/utils/SkCanvasStateUtils.h",
349 "//third_party/skia/include/utils/SkCubicInterval.h",
350 "//third_party/skia/include/utils/SkCullPoints.h",
351 "//third_party/skia/include/utils/SkDebugUtils.h",
352 "//third_party/skia/include/utils/SkDumpCanvas.h",
353 "//third_party/skia/include/utils/SkEventTracer.h",
354 "//third_party/skia/include/utils/SkFrontBufferedStream.h",
355 "//third_party/skia/include/utils/SkInterpolator.h",
356 "//third_party/skia/include/utils/SkLayer.h",
357 "//third_party/skia/include/utils/SkMeshUtils.h",
358 "//third_party/skia/include/utils/SkNinePatch.h",
359 "//third_party/skia/include/utils/SkParsePaint.h",
360 "//third_party/skia/include/utils/SkParsePath.h",
361 "//third_party/skia/include/utils/SkRandom.h",
362 "//third_party/skia/src/utils/SkBitmapHasher.cpp",
363 "//third_party/skia/src/utils/SkBitmapHasher.h",
364 "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
365 "//third_party/skia/src/utils/SkCamera.cpp",
366 "//third_party/skia/src/utils/SkCanvasStack.h",
367 "//third_party/skia/src/utils/SkCubicInterval.cpp",
368 "//third_party/skia/src/utils/SkCullPoints.cpp",
369 "//third_party/skia/src/utils/SkDumpCanvas.cpp",
370 "//third_party/skia/src/utils/SkFloatUtils.h",
371 "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
372 "//third_party/skia/src/utils/SkInterpolator.cpp",
373 "//third_party/skia/src/utils/SkLayer.cpp",
374 "//third_party/skia/src/utils/SkMD5.cpp",
375 "//third_party/skia/src/utils/SkMD5.h",
376 "//third_party/skia/src/utils/SkMeshUtils.cpp",
377 "//third_party/skia/src/utils/SkNinePatch.cpp",
378 "//third_party/skia/src/utils/SkOSFile.cpp",
379 "//third_party/skia/src/utils/SkParsePath.cpp",
380 "//third_party/skia/src/utils/SkPathUtils.cpp",
381 "//third_party/skia/src/utils/SkSHA1.cpp",
382 "//third_party/skia/src/utils/SkSHA1.h",
383 "//third_party/skia/src/utils/SkTFitsIn.h",
384 "//third_party/skia/src/utils/SkTLogic.h",
386 # We don't currently need to change thread affinity, so leave out this complexity for now.
387 "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
388 "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
391 "//third_party/skia/src/fonts/SkGScalerContext.cpp",
392 "//third_party/skia/src/fonts/SkGScalerContext.h",
398 "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
399 "//third_party/skia/src/utils/SkThreadUtils_pthread_other.cpp",
403 # Keeping _pthread.cpp and _pthread_other.cpp.
404 "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
408 # need separate win section to handle chromes auto gn filter
409 # (build/config/BUILDCONFIG.gn)
413 "//third_party/skia/include/utils/win/SkAutoCoInitialize.h",
414 "//third_party/skia/include/utils/win/SkHRESULT.h",
415 "//third_party/skia/include/utils/win/SkIStream.h",
416 "//third_party/skia/include/utils/win/SkTScopedComPtr.h",
417 "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
418 "//third_party/skia/src/utils/win/SkIStream.cpp",
419 "//third_party/skia/src/utils/win/SkWGL_win.cpp",
423 if (is_android && (!enable_basic_printing && !enable_print_preview)) {
424 sources -= [ "ext/skia_utils_base.cc" ]
427 # Fixup skia library sources.
430 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
431 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
432 "//third_party/skia/src/ports/SkTime_Unix.cpp",
436 "//third_party/skia/src/ports/SkFontHost_win.cpp",
437 "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
438 "//third_party/skia/src/ports/SkOSFile_win.cpp",
439 "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
440 "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
441 "//third_party/skia/src/ports/SkScalerContext_win_dw.h",
442 "//third_party/skia/src/ports/SkTLS_win.cpp",
443 "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
444 "//third_party/skia/src/ports/SkTypeface_win_dw.h",
449 "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
450 "//third_party/skia/src/ports/SkFontMgr_android.cpp",
454 sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
459 "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
460 "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
461 "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
465 if (!is_linux && !is_android) {
467 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
468 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
472 # Select the right BitmapPlatformDevice.
475 "ext/bitmap_platform_device_win.cc",
476 "ext/bitmap_platform_device_win.h",
480 "ext/bitmap_platform_device_mac.cc",
481 "ext/bitmap_platform_device_mac.h",
483 } else if (use_cairo) {
485 "ext/bitmap_platform_device_cairo.cc",
486 "ext/bitmap_platform_device_cairo.h",
490 "ext/bitmap_platform_device_skia.cc",
491 "ext/bitmap_platform_device_skia.h",
496 # Skia won't compile with some of the more strict clang warnings.
498 # SkASSERT(!"sk_out_of_memory");
499 configs -= [ "//build/config/clang:extra_warnings" ]
502 configs -= [ "//build/config/compiler:chromium_code" ]
504 ":skia_library_config",
505 "//build/config/compiler:no_chromium_code",
507 public_configs = [ ":skia_config" ]
512 "//base/third_party/dynamic_annotations",
513 "//third_party/zlib",
518 "//build/config/linux:fontconfig",
519 "//build/config/linux:freetype2",
522 configs += [ "//build/config/linux:pangocairo" ]
524 deps += [ "//third_party/icu:icuuc" ]
528 set_sources_assignment_filter([])
529 sources += [ "ext/platform_device_linux.cc" ]
530 set_sources_assignment_filter(sources_assignment_filter)
532 "//third_party/expat",
533 "//third_party/freetype",
534 "//third_party/android_tools:cpu_features",
538 if (skia_support_pdf) {
539 deps += [ "//third_party/sfntly" ]
540 sources += gypi_skia_pdf.sources
543 if (is_android && !is_debug) {
544 configs -= [ "//build/config/compiler:optimize" ]
545 configs += [ "//build/config/compiler:optimize_max" ]
549 # Separated out so it can be compiled with different flags for SSE.
550 source_set("skia_opts") {
554 if (current_cpu == "x86" || current_cpu == "x64") {
555 sources = gypi_skia_opts.sse2_sources + gypi_skia_opts.ssse3_sources +
556 gypi_skia_opts.sse41_sources +
559 "ext/convolver_SSE2.cc",
560 "ext/convolver_SSE2.h",
563 if (is_linux || is_mac) {
564 cflags += [ "-msse4.1" ]
566 defines += [ "SK_CPU_SSE_LEVEL=41" ]
568 } else if (current_cpu == "arm") {
569 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
570 # ARM), the compiler doesn't like that.
571 cflags += [ "-fomit-frame-pointer" ]
573 if (arm_version >= 7) {
574 sources = gypi_skia_opts.armv7_sources
575 if (arm_use_neon || arm_optionally_use_neon) {
576 sources += gypi_skia_opts.neon_sources
578 # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
581 configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
582 cflags += [ "-mfpu=neon" ]
586 sources = gypi_skia_opts.none_sourcees
588 } else if (current_cpu == "mipsel") {
589 cflags += [ "-fomit-frame-pointer" ]
591 if (mips_dsp_rev >= 1) {
592 sources = gypi_skia_opts.mips_dsp_sources
593 if (mips_dsp_rev >= 2) {
596 "ext/convolver_mips_dspr2.cc",
597 "ext/convolver_mips_dspr2.h",
601 sources = gypi_skia_opts.none_sources
604 assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
607 if (is_android && !is_debug) {
608 configs -= [ "//build/config/compiler:optimize" ]
609 configs += [ "//build/config/compiler:optimize_max" ]
612 configs -= [ "//build/config/compiler:chromium_code" ]
615 ":skia_library_config",
616 "//build/config/compiler:no_chromium_code",
623 visibility = [ ":skia" ]
626 test("skia_unittests") {
628 "ext/analysis_canvas_unittest.cc",
629 "ext/bitmap_platform_device_mac_unittest.cc",
630 "ext/convolver_unittest.cc",
631 "ext/image_operations_unittest.cc",
632 "ext/pixel_ref_utils_unittest.cc",
633 "ext/platform_canvas_unittest.cc",
634 "ext/recursive_gaussian_convolution_unittest.cc",
635 "ext/refptr_unittest.cc",
636 "ext/skia_utils_ios_unittest.mm",
637 "ext/skia_utils_mac_unittest.mm",
640 if (!is_win && !is_mac) {
641 sources -= [ "ext/platform_canvas_unittest.cc" ]
647 "//base/test:run_all_unittests",
648 "//cc:test_support", # TODO: Fix this test to not depend on cc.
655 if (is_linux && !is_chromeos) {
656 # TODO(GYP): Figure out which of these work and are needed on other platforms.
657 executable("image_operations_bench") {
659 "ext/image_operations_bench.cc",
668 executable("filter_fuzz_stub") {
670 "tools/filter_fuzz_stub/filter_fuzz_stub.cc",