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 if (cpu_arch == "arm") {
8 import("//build/config/arm.gni")
11 skia_support_gpu = !is_ios
12 skia_support_pdf = !is_ios && enable_printing != 0
14 # The list of Skia defines that are to be set for chromium.
15 gypi_skia_defines = exec_script(
16 "//build/gypi_to_gn.py",
17 [ rebase_path("//third_party/skia/gyp/skia_for_chromium_defines.gypi"),
18 "--replace=<(skia_include_path)=//third_party/skia/include",
19 "--replace=<(skia_src_path)=//third_party/skia/src" ],
21 [ "//third_party/skia/gyp/skia_for_chromium_defines.gypi" ])
23 # The list of Skia core sources that are to be set for chromium.
24 gypi_skia_core = exec_script(
25 "//build/gypi_to_gn.py",
26 [ rebase_path("//third_party/skia/gyp/core.gypi"),
27 "--replace=<(skia_include_path)=//third_party/skia/include",
28 "--replace=<(skia_src_path)=//third_party/skia/src" ],
30 [ "//third_party/skia/gyp/core.gypi" ])
32 # The list of Skia gpu sources that are to be set for chromium.
33 gypi_skia_gpu = exec_script(
34 "//build/gypi_to_gn.py",
35 [ rebase_path("//third_party/skia/gyp/gpu.gypi"),
36 "--replace=<(skia_include_path)=//third_party/skia/include",
37 "--replace=<(skia_src_path)=//third_party/skia/src" ],
39 [ "//third_party/skia/gyp/gpu.gypi" ])
41 # The list of Skia pdf sources that are to be set for chromium.
42 gypi_skia_pdf = exec_script(
43 "//build/gypi_to_gn.py",
44 [ rebase_path("//third_party/skia/gyp/pdf.gypi"),
45 "--replace=<(skia_include_path)=//third_party/skia/include",
46 "--replace=<(skia_src_path)=//third_party/skia/src" ],
48 [ "//third_party/skia/gyp/pdf.gypi" ])
50 # The list of Skia effects that are to be set for chromium.
51 gypi_skia_effects = exec_script(
52 "//build/gypi_to_gn.py",
53 [ rebase_path("//third_party/skia/gyp/effects.gypi"),
54 "--replace=<(skia_include_path)=//third_party/skia/include",
55 "--replace=<(skia_src_path)=//third_party/skia/src" ],
57 [ "//third_party/skia/gyp/effects.gypi" ])
59 # The list of Skia utilss that are to be set for chromium.
60 gypi_skia_utils = exec_script(
61 "//build/gypi_to_gn.py",
62 [ rebase_path("//third_party/skia/gyp/utils.gypi"),
63 "--replace=<(skia_include_path)=//third_party/skia/include",
64 "--replace=<(skia_src_path)=//third_party/skia/src" ],
66 [ "//third_party/skia/gyp/utils.gypi" ])
68 # The list of Skia files is kept in skia_gn_files.gypi. Read it.
69 gypi_values = exec_script(
70 "//build/gypi_to_gn.py",
71 [ rebase_path("skia_gn_files.gypi"),
72 "--replace=<(skia_include_path)=//third_party/skia/include",
73 "--replace=<(skia_src_path)=//third_party/skia/src" ],
75 [ "skia_gn_files.gypi" ])
77 # External-facing config for dependent code.
78 config("skia_config") {
82 "//third_party/skia/include/config",
83 "//third_party/skia/include/core",
84 "//third_party/skia/include/effects",
85 "//third_party/skia/include/images",
86 "//third_party/skia/include/lazy",
87 "//third_party/skia/include/pathops",
88 "//third_party/skia/include/pdf",
89 "//third_party/skia/include/pipe",
90 "//third_party/skia/include/ports",
91 "//third_party/skia/include/utils",
92 "//third_party/skia/src/core",
93 "//third_party/skia/src/image",
94 "//third_party/skia/src/opts",
95 "//third_party/skia/src/ports",
96 "//third_party/skia/src/sfnt",
97 "//third_party/skia/src/utils",
98 "//third_party/skia/src/lazy",
101 defines = gypi_skia_defines.skia_for_chromium_defines
104 "SK_ENABLE_INST_COUNT=0",
105 "GR_GL_CUSTOM_SETUP_HEADER=\"GrGLConfig_chrome.h\"",
106 "SK_ENABLE_LEGACY_API_ALIASING=1",
107 "SK_ATTR_DEPRECATED=SK_NOTHING_ARG1",
108 "GR_GL_IGNORE_ES3_MSAA=0",
109 "SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT",
110 "SK_SUPPORT_LEGACY_GETTOTALCLIP",
113 if (component_mode == "shared_library") {
114 defines += [ "SKIA_DLL" ]
117 if (skia_support_gpu) {
119 "//third_party/skia/include/gpu",
120 "//third_party/skia/src/gpu",
122 defines += [ "SK_SUPPORT_GPU=1" ]
124 defines += [ "SK_SUPPORT_GPU=0" ]
127 # For POSIX platforms, prefer the Mutex implementation provided by Skia
128 # since it does not generate static initializers.
130 defines += [ "SK_USE_POSIX_THREADS" ]
135 "SK_BUILD_FOR_ANDROID",
141 # Internal-facing config for Skia library code.
142 config("skia_library_config") {
143 # These include directories are only included for Skia code and are not
144 # exported to dependents. It's not clear if this is on purpose, but this
145 # matches the GYP build.
147 if (is_mac || is_ios) {
148 include_dirs += [ "//third_party/skia/include/utils/mac" ]
151 include_dirs += [ "//third_party/skia/include/utils/ios" ]
155 #skia_export_defines ???) TODO
157 # skia uses static initializers to initialize the serialization logic
158 # of its "pictures" library. This is currently not used in chrome; if
159 # it ever gets used the processes that use it need to call
160 # SkGraphics::Init().
161 "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0",
163 # Forcing the unoptimized path for the offset image filter in skia until
164 # all filters used in Blink support the optimized path properly
165 "SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION",
167 # Disable this check because it is too strict for some Chromium-specific
168 # subclasses of SkPixelRef. See bug: crbug.com/171776.
169 "SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK",
171 "IGNORE_ROT_AA_RECT_OPT",
173 "SK_IGNORE_BLURRED_RRECT_OPT",
175 "SK_IGNORE_QUAD_RR_CORNERS_OPT",
177 # this flag forces Skia not to use typographic metrics with GDI.
178 "SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS",
180 "SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
183 # Settings for text blitting, chosen to approximate the system browser.
186 "SK_GAMMA_EXPONENT=1.2",
187 "SK_GAMMA_CONTRAST=0.2",
188 "SK_HIGH_QUALITY_IS_LANCZOS",
190 } else if (is_android) {
192 "SK_GAMMA_APPLY_TO_A8",
193 "SK_GAMMA_EXPONENT=1.4",
194 "SK_GAMMA_CONTRAST=0.0",
199 "SK_GAMMA_CONTRAST=0.5",
200 "SK_HIGH_QUALITY_IS_LANCZOS",
205 "SK_GAMMA_CONTRAST=0.0",
206 "SK_HIGH_QUALITY_IS_LANCZOS",
212 # Android devices are typically more memory constrained, so default to a
213 # smaller glyph cache (it may be overriden at runtime when the renderer
214 # starts up, depending on the actual device memory).
215 "SK_DEFAULT_FONT_CACHE_LIMIT=1048576" # 1024 * 1024
218 defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
223 "//third_party/skia/include/utils/win",
224 "//third_party/skia/src/utils/win",
227 defines += [ "SK_FONTHOST_USES_FONTMGR" ]
230 # TODO(brettw) comment what these are.
246 "ext/analysis_canvas.cc",
247 "ext/analysis_canvas.h",
248 "ext/benchmarking_canvas.cc",
249 "ext/benchmarking_canvas.h",
250 "ext/bitmap_platform_device.h",
251 "ext/bitmap_platform_device_cairo.cc",
252 "ext/bitmap_platform_device_cairo.h",
253 "ext/bitmap_platform_device_mac.cc",
254 "ext/bitmap_platform_device_mac.h",
255 #"ext/bitmap_platform_device_skia.cc",
256 #"ext/bitmap_platform_device_skia.h",
257 "ext/bitmap_platform_device_win.cc",
258 "ext/bitmap_platform_device_win.h",
261 "ext/event_tracer_impl.cc",
262 "ext/event_tracer_impl.h",
263 "ext/google_logging.cc",
264 "ext/image_operations.cc",
265 "ext/image_operations.h",
266 "ext/lazy_pixel_ref.cc",
267 "ext/lazy_pixel_ref.h",
268 "ext/SkThread_chrome.cc",
269 "ext/opacity_draw_filter.cc",
270 "ext/opacity_draw_filter.h",
271 "ext/paint_simplifier.cc",
272 "ext/paint_simplifier.h",
273 "ext/pixel_ref_utils.cc",
274 "ext/pixel_ref_utils.h",
275 "ext/platform_canvas.cc",
276 "ext/platform_canvas.h",
277 "ext/platform_device.cc",
278 "ext/platform_device.h",
279 "ext/platform_device_linux.cc",
280 "ext/platform_device_mac.cc",
281 "ext/platform_device_win.cc",
282 "ext/recursive_gaussian_convolution.cc",
283 "ext/recursive_gaussian_convolution.h",
285 "ext/SkDiscardableMemory_chrome.h",
286 "ext/SkDiscardableMemory_chrome.cc",
287 "ext/SkMemory_new_handler.cpp",
288 "ext/skia_trace_shim.h",
289 "ext/skia_utils_base.cc",
290 "ext/skia_utils_base.h",
291 "ext/skia_utils_ios.mm",
292 "ext/skia_utils_ios.h",
293 "ext/skia_utils_mac.mm",
294 "ext/skia_utils_mac.h",
295 "ext/skia_utils_win.cc",
296 "ext/skia_utils_win.h",
297 "ext/vector_canvas.h",
298 "ext/vector_platform_device_emf_win.cc",
299 "ext/vector_platform_device_emf_win.h",
300 "ext/vector_platform_device_skia.cc",
301 "ext/vector_platform_device_skia.h",
304 # The skia gypi values are relative to the skia_dir, so we need to rebase.
305 sources += gypi_skia_core.sources
306 sources += gypi_skia_effects.sources
307 sources += gypi_skia_utils.sources
308 sources += gypi_skia_pdf.sources
309 sources += gypi_values.skia_library_sources
312 if (skia_support_gpu) {
313 sources += gypi_skia_gpu.skgpu_sources
314 sources += gypi_skia_gpu.skgpu_null_gl_sources
317 # Remove unused util files include in utils.gypi
319 "//third_party/skia/include/utils/SkCondVar.h",
320 "//third_party/skia/include/utils/SkCountdown.h",
321 "//third_party/skia/include/utils/SkRunnable.h",
322 "//third_party/skia/include/utils/SkThreadPool.h",
323 "//third_party/skia/src/utils/SkCondVar.cpp",
324 "//third_party/skia/src/utils/SkCountdown.cpp",
326 "//third_party/skia/include/utils/SkBoundaryPatch.h",
327 "//third_party/skia/include/utils/SkFrontBufferedStream.h",
328 "//third_party/skia/include/utils/SkCamera.h",
329 "//third_party/skia/include/utils/SkCanvasStateUtils.h",
330 "//third_party/skia/include/utils/SkCubicInterval.h",
331 "//third_party/skia/include/utils/SkCullPoints.h",
332 "//third_party/skia/include/utils/SkDebugUtils.h",
333 "//third_party/skia/include/utils/SkDumpCanvas.h",
334 "//third_party/skia/include/utils/SkEventTracer.h",
335 "//third_party/skia/include/utils/SkInterpolator.h",
336 "//third_party/skia/include/utils/SkLayer.h",
337 "//third_party/skia/include/utils/SkMeshUtils.h",
338 "//third_party/skia/include/utils/SkNinePatch.h",
339 "//third_party/skia/include/utils/SkParse.h",
340 "//third_party/skia/include/utils/SkParsePaint.h",
341 "//third_party/skia/include/utils/SkParsePath.h",
342 "//third_party/skia/include/utils/SkRandom.h",
343 "//third_party/skia/include/utils/SkWGL.h",
345 "//third_party/skia/src/utils/SkBitmapHasher.cpp",
346 "//third_party/skia/src/utils/SkBitmapHasher.h",
347 "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
348 "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
349 "//third_party/skia/src/utils/SkCamera.cpp",
350 "//third_party/skia/src/utils/SkCanvasStack.h",
351 "//third_party/skia/src/utils/SkCubicInterval.cpp",
352 "//third_party/skia/src/utils/SkCullPoints.cpp",
353 "//third_party/skia/src/utils/SkDumpCanvas.cpp",
354 "//third_party/skia/src/utils/SkFloatUtils.h",
355 "//third_party/skia/src/utils/SkGatherPixelRefsAndRects.cpp",
356 "//third_party/skia/src/utils/SkGatherPixelRefsAndRects.h",
357 "//third_party/skia/src/utils/SkInterpolator.cpp",
358 "//third_party/skia/src/utils/SkLayer.cpp",
359 "//third_party/skia/src/utils/SkMD5.cpp",
360 "//third_party/skia/src/utils/SkMD5.h",
361 "//third_party/skia/src/utils/SkMeshUtils.cpp",
362 "//third_party/skia/src/utils/SkNinePatch.cpp",
363 "//third_party/skia/src/utils/SkOSFile.cpp",
364 "//third_party/skia/src/utils/SkParse.cpp",
365 "//third_party/skia/src/utils/SkParseColor.cpp",
366 "//third_party/skia/src/utils/SkParsePath.cpp",
367 "//third_party/skia/src/utils/SkPathUtils.cpp",
368 "//third_party/skia/src/utils/SkSHA1.cpp",
369 "//third_party/skia/src/utils/SkSHA1.h",
370 "//third_party/skia/src/utils/SkThreadUtils.h",
371 "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
372 "//third_party/skia/src/utils/SkThreadUtils_pthread.h",
373 "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
374 "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
375 "//third_party/skia/src/utils/SkThreadUtils_pthread_other.cpp",
376 "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
377 "//third_party/skia/src/utils/SkTFitsIn.h",
378 "//third_party/skia/src/utils/SkTLogic.h",
381 "//third_party/skia/src/fonts/SkGScalerContext.cpp",
382 "//third_party/skia/src/fonts/SkGScalerContext.h",
385 # need separate win section to handle chromes auto gn filter (build/config/BUILDCONFIG.gn)
388 "//third_party/skia/src/utils/SkThreadUtils_win.h",
391 "//third_party/skia/include/utils/win/SkAutoCoInitialize.h",
392 "//third_party/skia/include/utils/win/SkHRESULT.h",
393 "//third_party/skia/include/utils/win/SkIStream.h",
394 "//third_party/skia/include/utils/win/SkTScopedComPtr.h",
395 "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
396 "//third_party/skia/src/utils/win/SkIStream.cpp",
397 "//third_party/skia/src/utils/win/SkWGL_win.cpp",
401 # Fixup Chrome sources.
403 sources -= [ "ext/SkThread_chrome.cc" ]
406 sources -= [ "ext/vector_platform_device_skia.cc" ]
409 sources -= [ "ext/SkThread_chrome.cc" ]
411 if (is_android && enable_printing == 0) {
413 "ext/skia_utils_base.cc",
414 "ext/vector_platform_device_skia.cc"
418 # Fixup skia library sources.
421 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
422 "//third_party/skia/src/ports/SkTime_Unix.cpp",
423 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
427 "//third_party/skia/src/ports/SkFontHost_win.cpp",
428 "//third_party/skia/src/ports/SkFontMgr_default_gdi.cpp",
429 "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
430 "//third_party/skia/src/ports/SkOSFile_win.cpp",
431 "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
432 "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
433 "//third_party/skia/src/ports/SkScalerContext_win_dw.h",
434 "//third_party/skia/src/ports/SkTLS_win.cpp",
435 "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
436 "//third_party/skia/src/ports/SkTypeface_win_dw.h",
441 "//third_party/skia/src/ports/SkFontConfigInterface_android.cpp",
442 "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
447 "//third_party/skia/src/ports/SkFontHost_mac.cpp",
453 "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
454 "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
455 "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
456 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
457 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
463 "ext/bitmap_platform_device_cairo.cc",
464 "ext/bitmap_platform_device_cairo.h",
469 # Skia won't compile with some of the more strict clang warnings.
471 # SkASSERT(!"sk_out_of_memory");
472 configs -= [ "//build/config/clang:extra_warnings" ]
475 configs -= [ "//build/config/compiler:chromium_code" ]
477 ":skia_library_config",
478 "//build/config/compiler:no_chromium_code"
480 direct_dependent_configs = [ ":skia_config" ]
485 "//base/third_party/dynamic_annotations",
486 "//third_party/zlib",
489 if (component_mode == "shared_library") {
490 defines = [ "SKIA_IMPLEMENTATION=1" ]
495 # Some files define WIN32_LEAN_AND_MEAN and we want to avoid a duplicate
496 # definition warning.
497 "//build/config/win:lean_and_mean",
503 "//build/config/linux:fontconfig",
504 "//build/config/linux:freetype2",
505 "//build/config/linux:pangocairo",
508 "//third_party/icu:icuuc",
514 "//third_party/expat",
515 "//third_party/freetype",
519 if (skia_support_pdf) {
520 deps += [ "//third_party/sfntly" ]
524 # Separated out so it can be compiled with different flags for SSE.
525 source_set("skia_opts") {
529 if (cpu_arch == "x86" || cpu_arch == "x64") {
532 "//third_party/skia/src/opts/opts_check_x86.cpp",
533 "//third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp",
534 "//third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp",
535 "//third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp",
536 "//third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp",
537 "//third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp",
538 "//third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp",
539 "//third_party/skia/src/opts/SkUtils_opts_SSE2.cpp",
540 "//third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp",
543 "//third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp",
546 "ext/convolver_SSE2.cc",
548 # These are header files used by this target from the skia one above.
550 "//third_party/skia/include/core/SkTypes.h",
553 if (is_linux || is_mac) {
554 cflags += [ "-mssse3" ] # Note third 's'.
556 } else if (cpu_arch == "arm") {
558 "//third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp",
561 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
562 # ARM), the compiler doesn't like that.
563 cflags += [ "-fomit-frame-pointer" ]
565 if (arm_version >= 7) {
566 if (arm_use_neon || arm_optionally_use_neon) {
568 "//third_party/skia/src/opts/memset16_neon.S",
569 "//third_party/skia/src/opts/memset32_neon.S",
570 "//third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp",
571 "//third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
572 "//third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h",
573 "//third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h",
574 "//third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp",
575 "//third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp",
576 "//third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp",
577 "//third_party/skia/src/opts/SkBlurImage_opts_neon.cpp",
578 "//third_party/skia/src/opts/SkMorphology_opts_neon.cpp",
582 # The neon assembly contains conditional instructions which aren't
583 # enclosed in an IT block. The assembler complains without this
584 # option. See #86592.
585 "-Wa,-mimplicit-it=always",
588 # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
590 assert(arm_fpu == "neon")
594 # "-Wl,--fix-cortex-a8",
599 defines += [ "__ARM_HAVE_NEON" ]
601 if (arm_optionally_use_neon) {
602 defines += [ "__ARM_HAVE_OPTIONAL_NEON_SUPPORT" ]
607 if (arm_version < 7 || (!arm_use_neon && arm_optionally_use_neon)) {
608 sources += [ "//third_party/skia/src/opts/memset.arm.S" ]
611 if (arm_version < 6) {
613 "//third_party/skia/src/opts/SkBlitMask_opts_none.cpp",
614 "//third_party/skia/src/opts/SkBlitRow_opts_none.cpp",
615 "//third_party/skia/src/opts/SkUtils_opts_none.cpp",
616 "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
617 "//third_party/skia/src/opts/SkMorphology_opts_none.cpp",
618 "//third_party/skia/src/opts/SkBlurImage_opts_none.cpp",
623 "//third_party/skia/src/opts/SkBlitMask_opts_arm.cpp",
624 "//third_party/skia/src/opts/SkBlitRow_opts_arm.cpp",
625 "//third_party/skia/src/opts/SkBlitRow_opts_arm.h",
626 "//third_party/skia/src/opts/SkBlurImage_opts_arm.cpp",
627 "//third_party/skia/src/opts/SkMorphology_opts_arm.cpp",
628 "//third_party/skia/src/opts/SkUtils_opts_arm.cpp",
629 "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
635 assert(false, "Need to port MIPS stuff from skia_library_opts.gyp")
638 configs -= [ "//build/config/compiler:chromium_code" ]
641 "//build/config/compiler:no_chromium_code"