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 files is kept in skia_gn_files.gypi. Read it.
60 gypi_values = exec_script(
61 "//build/gypi_to_gn.py",
62 [ rebase_path("skia_gn_files.gypi"),
63 "--replace=<(skia_include_path)=//third_party/skia/include",
64 "--replace=<(skia_src_path)=//third_party/skia/src" ],
66 [ "skia_gn_files.gypi" ])
68 # External-facing config for dependent code.
69 config("skia_config") {
73 "//third_party/skia/include/config",
74 "//third_party/skia/include/core",
75 "//third_party/skia/include/effects",
76 "//third_party/skia/include/images",
77 "//third_party/skia/include/lazy",
78 "//third_party/skia/include/pathops",
79 "//third_party/skia/include/pdf",
80 "//third_party/skia/include/pipe",
81 "//third_party/skia/include/ports",
82 "//third_party/skia/include/utils",
83 "//third_party/skia/src/core",
84 "//third_party/skia/src/image",
85 "//third_party/skia/src/opts",
86 "//third_party/skia/src/ports",
87 "//third_party/skia/src/sfnt",
88 "//third_party/skia/src/utils",
89 "//third_party/skia/src/lazy",
92 defines = gypi_skia_defines.skia_for_chromium_defines
95 "SK_ENABLE_INST_COUNT=0",
96 "GR_GL_CUSTOM_SETUP_HEADER=\"GrGLConfig_chrome.h\"",
97 "SK_ENABLE_LEGACY_API_ALIASING=1",
98 "SK_ATTR_DEPRECATED=SK_NOTHING_ARG1",
99 "GR_GL_IGNORE_ES3_MSAA=0",
100 "SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT",
101 "SK_SUPPORT_LEGACY_GETTOTALCLIP",
104 if (component_mode == "shared_library") {
105 defines += [ "SKIA_DLL" ]
108 if (skia_support_gpu) {
110 "//third_party/skia/include/gpu",
111 "//third_party/skia/src/gpu",
113 defines += [ "SK_SUPPORT_GPU=1" ]
115 defines += [ "SK_SUPPORT_GPU=0" ]
118 # For POSIX platforms, prefer the Mutex implementation provided by Skia
119 # since it does not generate static initializers.
121 defines += [ "SK_USE_POSIX_THREADS" ]
126 "SK_BUILD_FOR_ANDROID",
132 # Internal-facing config for Skia library code.
133 config("skia_library_config") {
134 # These include directories are only included for Skia code and are not
135 # exported to dependents. It's not clear if this is on purpose, but this
136 # matches the GYP build.
138 if (is_mac || is_ios) {
139 include_dirs += [ "//third_party/skia/include/utils/mac" ]
142 include_dirs += [ "//third_party/skia/include/utils/ios" ]
146 #skia_export_defines ???) TODO
148 # skia uses static initializers to initialize the serialization logic
149 # of its "pictures" library. This is currently not used in chrome; if
150 # it ever gets used the processes that use it need to call
151 # SkGraphics::Init().
152 "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0",
154 # Forcing the unoptimized path for the offset image filter in skia until
155 # all filters used in Blink support the optimized path properly
156 "SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION",
158 # Disable this check because it is too strict for some Chromium-specific
159 # subclasses of SkPixelRef. See bug: crbug.com/171776.
160 "SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK",
162 "IGNORE_ROT_AA_RECT_OPT",
164 "SK_IGNORE_BLURRED_RRECT_OPT",
166 "SK_IGNORE_QUAD_RR_CORNERS_OPT",
168 # this flag forces Skia not to use typographic metrics with GDI.
169 "SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS",
171 "SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
174 # Settings for text blitting, chosen to approximate the system browser.
177 "SK_GAMMA_EXPONENT=1.2",
178 "SK_GAMMA_CONTRAST=0.2",
179 "SK_HIGH_QUALITY_IS_LANCZOS",
181 } else if (is_android) {
183 "SK_GAMMA_APPLY_TO_A8",
184 "SK_GAMMA_EXPONENT=1.4",
185 "SK_GAMMA_CONTRAST=0.0",
190 "SK_GAMMA_CONTRAST=0.5",
191 "SK_HIGH_QUALITY_IS_LANCZOS",
196 "SK_GAMMA_CONTRAST=0.0",
197 "SK_HIGH_QUALITY_IS_LANCZOS",
203 # Android devices are typically more memory constrained, so default to a
204 # smaller glyph cache (it may be overriden at runtime when the renderer
205 # starts up, depending on the actual device memory).
206 "SK_DEFAULT_FONT_CACHE_LIMIT=1048576" # 1024 * 1024
209 defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
214 "//third_party/skia/include/utils/win",
215 "//third_party/skia/src/utils/win",
218 defines += [ "SK_FONTHOST_USES_FONTMGR" ]
221 # TODO(brettw) comment what these are.
237 "ext/analysis_canvas.cc",
238 "ext/analysis_canvas.h",
239 "ext/benchmarking_canvas.cc",
240 "ext/benchmarking_canvas.h",
241 "ext/bitmap_platform_device.h",
242 "ext/bitmap_platform_device_cairo.cc",
243 "ext/bitmap_platform_device_cairo.h",
244 "ext/bitmap_platform_device_mac.cc",
245 "ext/bitmap_platform_device_mac.h",
246 #"ext/bitmap_platform_device_skia.cc",
247 #"ext/bitmap_platform_device_skia.h",
248 "ext/bitmap_platform_device_win.cc",
249 "ext/bitmap_platform_device_win.h",
252 "ext/event_tracer_impl.cc",
253 "ext/event_tracer_impl.h",
254 "ext/google_logging.cc",
255 "ext/image_operations.cc",
256 "ext/image_operations.h",
257 "ext/lazy_pixel_ref.cc",
258 "ext/lazy_pixel_ref.h",
259 "ext/SkThread_chrome.cc",
260 "ext/opacity_draw_filter.cc",
261 "ext/opacity_draw_filter.h",
262 "ext/paint_simplifier.cc",
263 "ext/paint_simplifier.h",
264 "ext/pixel_ref_utils.cc",
265 "ext/pixel_ref_utils.h",
266 "ext/platform_canvas.cc",
267 "ext/platform_canvas.h",
268 "ext/platform_device.cc",
269 "ext/platform_device.h",
270 "ext/platform_device_linux.cc",
271 "ext/platform_device_mac.cc",
272 "ext/platform_device_win.cc",
273 "ext/recursive_gaussian_convolution.cc",
274 "ext/recursive_gaussian_convolution.h",
276 "ext/SkDiscardableMemory_chrome.h",
277 "ext/SkDiscardableMemory_chrome.cc",
278 "ext/SkMemory_new_handler.cpp",
279 "ext/skia_trace_shim.h",
280 "ext/skia_utils_base.cc",
281 "ext/skia_utils_base.h",
282 "ext/skia_utils_ios.mm",
283 "ext/skia_utils_ios.h",
284 "ext/skia_utils_mac.mm",
285 "ext/skia_utils_mac.h",
286 "ext/skia_utils_win.cc",
287 "ext/skia_utils_win.h",
288 "ext/vector_canvas.h",
289 "ext/vector_platform_device_emf_win.cc",
290 "ext/vector_platform_device_emf_win.h",
291 "ext/vector_platform_device_skia.cc",
292 "ext/vector_platform_device_skia.h",
295 # The skia gypi values are relative to the skia_dir, so we need to rebase.
296 sources += gypi_skia_core.sources
297 sources += gypi_skia_effects.sources
298 sources += gypi_skia_pdf.sources
299 sources += gypi_values.skia_library_sources
302 if (skia_support_gpu) {
303 sources += gypi_skia_gpu.skgpu_sources
304 sources += gypi_skia_gpu.skgpu_null_gl_sources
307 # Fixup Chrome sources.
309 sources -= [ "ext/SkThread_chrome.cc" ]
312 sources -= [ "ext/vector_platform_device_skia.cc" ]
315 sources -= [ "ext/SkThread_chrome.cc" ]
317 if (is_android && enable_printing == 0) {
319 "ext/skia_utils_base.cc",
320 "ext/vector_platform_device_skia.cc"
324 # Fixup skia library sources.
327 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
328 "//third_party/skia/src/ports/SkTime_Unix.cpp",
329 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
333 "//third_party/skia/src/ports/SkFontHost_win.cpp",
334 "//third_party/skia/src/ports/SkFontHost_win_dw.cpp",
335 "//third_party/skia/src/ports/SkFontMgr_default_gdi.cpp",
336 "//third_party/skia/src/ports/SkOSFile_win.cpp",
337 "//third_party/skia/src/ports/SkTLS_win.cpp",
338 "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
343 "//third_party/skia/src/ports/SkFontConfigInterface_android.cpp",
344 "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
349 "//third_party/skia/src/ports/SkFontHost_mac.cpp",
350 "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
355 "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
356 "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
357 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
358 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
359 "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
360 "//third_party/skia/src/ports/SkFontHost_linux.cpp",
361 "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
363 } else if (!is_android) {
365 "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
366 "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
371 "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
377 "ext/bitmap_platform_device_cairo.cc",
378 "ext/bitmap_platform_device_cairo.h",
383 # Skia won't compile with some of the more strict clang warnings.
385 # SkASSERT(!"sk_out_of_memory");
386 configs -= [ "//build/config/clang:extra_warnings" ]
389 configs -= [ "//build/config/compiler:chromium_code" ]
391 ":skia_library_config",
392 "//build/config/compiler:no_chromium_code"
394 direct_dependent_configs = [ ":skia_config" ]
399 "//base/third_party/dynamic_annotations",
400 "//third_party/zlib",
403 if (component_mode == "shared_library") {
404 defines = [ "SKIA_IMPLEMENTATION=1" ]
409 "//build/config/linux:fontconfig",
410 "//build/config/linux:freetype2",
411 "//build/config/linux:pangocairo",
414 "//third_party/icu:icuuc",
420 "//third_party/expat",
421 "//third_party/freetype",
425 if (skia_support_pdf) {
426 deps += [ "//third_party/sfntly" ]
430 # Separated out so it can be compiled with different flags for SSE.
431 source_set("skia_opts") {
435 if (cpu_arch == "x86" || cpu_arch == "x64") {
438 "//third_party/skia/src/opts/opts_check_x86.cpp",
439 "//third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp",
440 "//third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp",
441 "//third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp",
442 "//third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp",
443 "//third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp",
444 "//third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp",
445 "//third_party/skia/src/opts/SkUtils_opts_SSE2.cpp",
446 "//third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp",
449 "//third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp",
452 "ext/convolver_SSE2.cc",
454 # These are header files used by this target from the skia one above.
456 "//third_party/skia/include/core/SkTypes.h",
459 if (is_linux || is_mac) {
460 cflags += [ "-mssse3" ] # Note third 's'.
462 } else if (cpu_arch == "arm") {
464 "//third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp",
467 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
468 # ARM), the compiler doesn't like that.
469 cflags += [ "-fomit-frame-pointer" ]
471 if (arm_version >= 7) {
472 if (arm_use_neon || arm_optionally_use_neon) {
474 "//third_party/skia/src/opts/memset16_neon.S",
475 "//third_party/skia/src/opts/memset32_neon.S",
476 "//third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp",
477 "//third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
478 "//third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h",
479 "//third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h",
480 "//third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp",
481 "//third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp",
482 "//third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp",
483 "//third_party/skia/src/opts/SkBlurImage_opts_neon.cpp",
484 "//third_party/skia/src/opts/SkMorphology_opts_neon.cpp",
488 # The neon assembly contains conditional instructions which aren't
489 # enclosed in an IT block. The assembler complains without this
490 # option. See #86592.
491 "-Wa,-mimplicit-it=always",
494 # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
496 assert(arm_fpu == "neon")
500 # "-Wl,--fix-cortex-a8",
505 defines += [ "__ARM_HAVE_NEON" ]
507 if (arm_optionally_use_neon) {
508 defines += [ "__ARM_HAVE_OPTIONAL_NEON_SUPPORT" ]
513 if (arm_version < 7 || (!arm_use_neon && arm_optionally_use_neon)) {
514 sources += [ "//third_party/skia/src/opts/memset.arm.S" ]
517 if (arm_version < 6) {
519 "//third_party/skia/src/opts/SkBlitMask_opts_none.cpp",
520 "//third_party/skia/src/opts/SkBlitRow_opts_none.cpp",
521 "//third_party/skia/src/opts/SkUtils_opts_none.cpp",
522 "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
523 "//third_party/skia/src/opts/SkMorphology_opts_none.cpp",
524 "//third_party/skia/src/opts/SkBlurImage_opts_none.cpp",
529 "//third_party/skia/src/opts/SkBlitMask_opts_arm.cpp",
530 "//third_party/skia/src/opts/SkBlitRow_opts_arm.cpp",
531 "//third_party/skia/src/opts/SkBlitRow_opts_arm.h",
532 "//third_party/skia/src/opts/SkBlurImage_opts_arm.cpp",
533 "//third_party/skia/src/opts/SkMorphology_opts_arm.cpp",
534 "//third_party/skia/src/opts/SkUtils_opts_arm.cpp",
535 "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
541 assert(false, "Need to port MIPS stuff from skia_library_opts.gyp")
544 configs -= [ "//build/config/compiler:chromium_code" ]
547 "//build/config/compiler:no_chromium_code"