[android] Hide <select> dropdown on outside tap.
[chromium-blink-merge.git] / skia / BUILD.gn
blobc793e0b9e5c010d1c7ccc4438a8fef473ac4401b
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 (cpu_arch == "arm") {
9   import("//build/config/arm.gni")
12 skia_support_gpu = !is_ios
13 skia_support_pdf = !is_ios && (enable_basic_printing || enable_print_preview)
15 # The list of Skia defines that are to be set for blink.
16 gypi_blink_skia_defines =
17     exec_script("//build/gypi_to_gn.py",
18                 [
19                   rebase_path(
20                       "//third_party/WebKit/public/blink_skia_config.gypi"),
21                   "--replace=<(skia_include_path)=//third_party/skia/include",
22                   "--replace=<(skia_src_path)=//third_party/skia/src",
23                 ],
24                 "scope",
25                 [ "//third_party/WebKit/public/blink_skia_config.gypi" ])
27 # The list of Skia defines that are to be set for chromium.
28 gypi_skia_defines =
29     exec_script("//build/gypi_to_gn.py",
30                 [
31                   rebase_path(
32                       "//third_party/skia/gyp/skia_for_chromium_defines.gypi"),
33                   "--replace=<(skia_include_path)=//third_party/skia/include",
34                   "--replace=<(skia_src_path)=//third_party/skia/src",
35                 ],
36                 "scope",
37                 [ "//third_party/skia/gyp/skia_for_chromium_defines.gypi" ])
39 # The list of Skia core sources that are to be set for chromium.
40 gypi_skia_core =
41     exec_script("//build/gypi_to_gn.py",
42                 [
43                   rebase_path("//third_party/skia/gyp/core.gypi"),
44                   "--replace=<(skia_include_path)=//third_party/skia/include",
45                   "--replace=<(skia_src_path)=//third_party/skia/src",
46                 ],
47                 "scope",
48                 [ "//third_party/skia/gyp/core.gypi" ])
50 # The list of Skia gpu sources that are to be set for chromium.
51 gypi_skia_gpu =
52     exec_script("//build/gypi_to_gn.py",
53                 [
54                   rebase_path("//third_party/skia/gyp/gpu.gypi"),
55                   "--replace=<(skia_include_path)=//third_party/skia/include",
56                   "--replace=<(skia_src_path)=//third_party/skia/src",
57                 ],
58                 "scope",
59                 [ "//third_party/skia/gyp/gpu.gypi" ])
61 # The list of Skia pdf sources that are to be set for chromium.
62 gypi_skia_pdf =
63     exec_script("//build/gypi_to_gn.py",
64                 [
65                   rebase_path("//third_party/skia/gyp/pdf.gypi"),
66                   "--replace=<(skia_include_path)=//third_party/skia/include",
67                   "--replace=<(skia_src_path)=//third_party/skia/src",
68                 ],
69                 "scope",
70                 [ "//third_party/skia/gyp/pdf.gypi" ])
72 # The list of Skia effects that are to be set for chromium.
73 gypi_skia_effects =
74     exec_script("//build/gypi_to_gn.py",
75                 [
76                   rebase_path("//third_party/skia/gyp/effects.gypi"),
77                   "--replace=<(skia_include_path)=//third_party/skia/include",
78                   "--replace=<(skia_src_path)=//third_party/skia/src",
79                 ],
80                 "scope",
81                 [ "//third_party/skia/gyp/effects.gypi" ])
83 # The list of Skia utils that are to be set for chromium.
84 gypi_skia_utils =
85     exec_script("//build/gypi_to_gn.py",
86                 [
87                   rebase_path("//third_party/skia/gyp/utils.gypi"),
88                   "--replace=<(skia_include_path)=//third_party/skia/include",
89                   "--replace=<(skia_src_path)=//third_party/skia/src",
90                 ],
91                 "scope",
92                 [ "//third_party/skia/gyp/utils.gypi" ])
94 gypi_skia_opts =
95     exec_script("//build/gypi_to_gn.py",
96                 [
97                   rebase_path("//third_party/skia/gyp/opts.gypi"),
98                   "--replace=<(skia_include_path)=//third_party/skia/include",
99                   "--replace=<(skia_src_path)=//third_party/skia/src",
100                 ],
101                 "scope",
102                 [ "//third_party/skia/gyp/opts.gypi" ])
104 # The list of Skia files is kept in skia_gn_files.gypi. Read it.
105 gypi_values =
106     exec_script("//build/gypi_to_gn.py",
107                 [
108                   rebase_path("skia_gn_files.gypi"),
109                   "--replace=<(skia_include_path)=//third_party/skia/include",
110                   "--replace=<(skia_src_path)=//third_party/skia/src",
111                 ],
112                 "scope",
113                 [ "skia_gn_files.gypi" ])
115 # External-facing config for dependent code.
116 config("skia_config") {
117   include_dirs = [
118     "config",
119     "ext",
120     "//third_party/skia/include/c",
121     "//third_party/skia/include/config",
122     "//third_party/skia/include/core",
123     "//third_party/skia/include/effects",
124     "//third_party/skia/include/images",
125     "//third_party/skia/include/lazy",
126     "//third_party/skia/include/pathops",
127     "//third_party/skia/include/pdf",
128     "//third_party/skia/include/pipe",
129     "//third_party/skia/include/ports",
130     "//third_party/skia/include/utils",
132     # need to move this to internal. see crbug.com/457691
133     "//third_party/skia/src/core",
134   ]
136   defines = gypi_blink_skia_defines.blink_skia_defines
137   defines += gypi_skia_defines.skia_for_chromium_defines
139   defines += []
141   if (component_mode == "shared_library") {
142     defines += [ "SKIA_DLL" ]
143   }
145   if (skia_support_gpu) {
146     include_dirs += [
147       "//third_party/skia/include/gpu",
148       "//third_party/skia/src/gpu",
149     ]
150     defines += [ "SK_SUPPORT_GPU=1" ]
151   } else {
152     defines += [ "SK_SUPPORT_GPU=0" ]
153   }
155   if (is_android) {
156     defines += [
157       "SK_BUILD_FOR_ANDROID",
158       "USE_CHROMIUM_SKIA",
159     ]
160   }
162   if (is_mac) {
163     defines += [ "SK_BUILD_FOR_MAC" ]
164   }
167 # Internal-facing config for Skia library code.
168 config("skia_library_config") {
169   # These include directories are only included for Skia code and are not
170   # exported to dependents. It's not clear if this is on purpose, but this
171   # matches the GYP build.
172   include_dirs = [
173     "//third_party/skia/src/image",
174     "//third_party/skia/src/opts",
175     "//third_party/skia/src/pdf",
176     "//third_party/skia/src/ports",
177     "//third_party/skia/src/sfnt",
178     "//third_party/skia/src/utils",
179     "//third_party/skia/src/lazy",
180   ]
181   if (is_mac || is_ios) {
182     include_dirs += [ "//third_party/skia/include/utils/mac" ]
183   }
184   if (is_mac) {
185     include_dirs += [ "//third_party/skia/include/utils/ios" ]
186   }
188   defines = []
190   if (component_mode == "shared_library") {
191     defines += [ "SKIA_IMPLEMENTATION=1" ]
192   }
194   if (cpu_arch == "arm") {
195     if (arm_use_neon) {
196       defines += [ "SK_ARM_HAS_NEON" ]
197     }
198     if (arm_optionally_use_neon) {
199       defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
200     }
201   }
203   # Settings for text blitting, chosen to approximate the system browser.
204   if (is_linux) {
205     defines += [
206       "SK_GAMMA_EXPONENT=1.2",
207       "SK_GAMMA_CONTRAST=0.2",
208       "SK_HIGH_QUALITY_IS_LANCZOS",
209     ]
210   } else if (is_android) {
211     defines += [
212       "SK_GAMMA_APPLY_TO_A8",
213       "SK_GAMMA_EXPONENT=1.4",
214       "SK_GAMMA_CONTRAST=0.0",
215     ]
216   } else if (is_win) {
217     defines += [
218       "SK_GAMMA_SRGB",
219       "SK_GAMMA_CONTRAST=0.5",
220       "SK_HIGH_QUALITY_IS_LANCZOS",
221     ]
222   } else if (is_mac) {
223     defines += [
224       "SK_GAMMA_SRGB",
225       "SK_GAMMA_CONTRAST=0.0",
226       "SK_HIGH_QUALITY_IS_LANCZOS",
227     ]
228   }
230   if (is_android) {
231     defines += [
232       # Android devices are typically more memory constrained, so default to a
233       # smaller glyph cache (it may be overriden at runtime when the renderer
234       # starts up, depending on the actual device memory).
235       "SK_DEFAULT_FONT_CACHE_LIMIT=1048576",  # 1024 * 1024
236     ]
237   } else {
238     defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ]  # 20 * 1024 * 1024
239   }
241   if (is_win) {
242     include_dirs += [
243       "//third_party/skia/include/utils/win",
244       "//third_party/skia/src/utils/win",
245     ]
247     defines += [ "SK_FONTHOST_USES_FONTMGR" ]
249     cflags = [
250       "/wd4244",  # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
251       "/wd4267",  # conversion from 'size_t' (64 bit) to 'type'(32 bit).
252       "/wd4341",  # signed value is out of range for enum constant.
253       "/wd4345",  # Object is default-initialized if initialization is omitted.
254       "/wd4390",  # ';'empty statement found in looping;is it what was intended?
255       "/wd4554",  # 'operator' : check operator precedence for possible error
256       "/wd4748",  # compiler will disable optimizations if a function has inline
257                   # assembly code contains flow control(jmp or jcc) statements.
258       "/wd4800",  # forcing value to bool 'true/false'(assigning int to bool).
259     ]
260   }
263 component("skia") {
264   sources = [
265     # Chrome sources.
266     "config/SkUserConfig.h",
267     "ext/analysis_canvas.cc",
268     "ext/analysis_canvas.h",
269     "ext/benchmarking_canvas.cc",
270     "ext/benchmarking_canvas.h",
271     "ext/bitmap_platform_device.h",
272     "ext/convolver.cc",
273     "ext/convolver.h",
274     "ext/event_tracer_impl.cc",
275     "ext/event_tracer_impl.h",
276     "ext/fontmgr_default_win.cc",
277     "ext/fontmgr_default_win.h",
278     "ext/google_logging.cc",
279     "ext/image_operations.cc",
280     "ext/image_operations.h",
281     "ext/opacity_draw_filter.cc",
282     "ext/opacity_draw_filter.h",
283     "ext/pixel_ref_utils.cc",
284     "ext/pixel_ref_utils.h",
285     "ext/platform_canvas.cc",
286     "ext/platform_canvas.h",
287     "ext/platform_device.cc",
288     "ext/platform_device.h",
289     "ext/platform_device_linux.cc",
290     "ext/platform_device_mac.cc",
291     "ext/platform_device_win.cc",
292     "ext/recursive_gaussian_convolution.cc",
293     "ext/recursive_gaussian_convolution.h",
294     "ext/refptr.h",
295     "ext/SkDiscardableMemory_chrome.h",
296     "ext/SkDiscardableMemory_chrome.cc",
297     "ext/SkMemory_new_handler.cpp",
298     "ext/skia_utils_base.cc",
299     "ext/skia_utils_base.h",
300     "ext/skia_utils_ios.mm",
301     "ext/skia_utils_ios.h",
302     "ext/skia_utils_mac.mm",
303     "ext/skia_utils_mac.h",
304     "ext/skia_utils_win.cc",
305     "ext/skia_utils_win.h",
306   ]
308   # The skia gypi values are relative to the skia_dir, so we need to rebase.
309   sources += gypi_skia_core.sources
310   sources += gypi_skia_effects.sources
311   sources += gypi_skia_utils.sources
312   sources += gypi_values.skia_library_sources
314   if (cpu_arch == "arm") {
315     sources += [
316       "//third_party/skia/src/core/SkUtilsArm.cpp",
317       "//third_party/skia/src/core/SkUtilsArm.h",
318     ]
319   }
321   # GPU
322   if (skia_support_gpu) {
323     sources += gypi_skia_gpu.skgpu_sources
324     sources += gypi_skia_gpu.skgpu_null_gl_sources
325   }
327   # Remove unused util files include in utils.gypi
328   sources -= [
329     "//third_party/skia/include/utils/SkBoundaryPatch.h",
330     "//third_party/skia/include/utils/SkFrontBufferedStream.h",
331     "//third_party/skia/include/utils/SkCamera.h",
332     "//third_party/skia/include/utils/SkCanvasStateUtils.h",
333     "//third_party/skia/include/utils/SkCubicInterval.h",
334     "//third_party/skia/include/utils/SkCullPoints.h",
335     "//third_party/skia/include/utils/SkDebugUtils.h",
336     "//third_party/skia/include/utils/SkDumpCanvas.h",
337     "//third_party/skia/include/utils/SkEventTracer.h",
338     "//third_party/skia/include/utils/SkInterpolator.h",
339     "//third_party/skia/include/utils/SkLayer.h",
340     "//third_party/skia/include/utils/SkMeshUtils.h",
341     "//third_party/skia/include/utils/SkNinePatch.h",
342     "//third_party/skia/include/utils/SkParse.h",
343     "//third_party/skia/include/utils/SkParsePaint.h",
344     "//third_party/skia/include/utils/SkParsePath.h",
345     "//third_party/skia/include/utils/SkRandom.h",
346     "//third_party/skia/src/utils/SkBitmapHasher.cpp",
347     "//third_party/skia/src/utils/SkBitmapHasher.h",
348     "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
349     "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
350     "//third_party/skia/src/utils/SkCamera.cpp",
351     "//third_party/skia/src/utils/SkCanvasStack.h",
352     "//third_party/skia/src/utils/SkCubicInterval.cpp",
353     "//third_party/skia/src/utils/SkCullPoints.cpp",
354     "//third_party/skia/src/utils/SkDumpCanvas.cpp",
355     "//third_party/skia/src/utils/SkFloatUtils.h",
356     "//third_party/skia/src/utils/SkInterpolator.cpp",
357     "//third_party/skia/src/utils/SkLayer.cpp",
358     "//third_party/skia/src/utils/SkMD5.cpp",
359     "//third_party/skia/src/utils/SkMD5.h",
360     "//third_party/skia/src/utils/SkMeshUtils.cpp",
361     "//third_party/skia/src/utils/SkNinePatch.cpp",
362     "//third_party/skia/src/utils/SkOSFile.cpp",
363     "//third_party/skia/src/utils/SkParse.cpp",
364     "//third_party/skia/src/utils/SkParseColor.cpp",
365     "//third_party/skia/src/utils/SkParsePath.cpp",
366     "//third_party/skia/src/utils/SkPathUtils.cpp",
367     "//third_party/skia/src/utils/SkSHA1.cpp",
368     "//third_party/skia/src/utils/SkSHA1.h",
369     "//third_party/skia/src/utils/SkTFitsIn.h",
370     "//third_party/skia/src/utils/SkTLogic.h",
372     # We don't currently need to change thread affinity, so leave out this complexity for now.
373     "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
374     "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
376     #testing
377     "//third_party/skia/src/fonts/SkGScalerContext.cpp",
378     "//third_party/skia/src/fonts/SkGScalerContext.h",
379   ]
381   if (is_win) {
382     sources -= [
383       # Keeping _win.cpp
384       "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
385       "//third_party/skia/src/utils/SkThreadUtils_pthread_other.cpp",
386     ]
387   } else {
388     sources -= [
389       # Keeping _pthread.cpp and _pthread_other.cpp.
390       "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
391     ]
392   }
394   # need separate win section to handle chromes auto gn filter
395   # (build/config/BUILDCONFIG.gn)
396   if (is_win) {
397     sources -= [
398       #windows
399       "//third_party/skia/include/utils/win/SkAutoCoInitialize.h",
400       "//third_party/skia/include/utils/win/SkHRESULT.h",
401       "//third_party/skia/include/utils/win/SkIStream.h",
402       "//third_party/skia/include/utils/win/SkTScopedComPtr.h",
403       "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
404       "//third_party/skia/src/utils/win/SkIStream.cpp",
405       "//third_party/skia/src/utils/win/SkWGL_win.cpp",
406     ]
407   }
409   if (is_android && (!enable_basic_printing && !enable_print_preview)) {
410     sources -= [ "ext/skia_utils_base.cc" ]
411   }
413   # Fixup skia library sources.
414   if (is_win) {
415     sources -= [
416       "//third_party/skia/src/ports/SkOSFile_posix.cpp",
417       "//third_party/skia/src/ports/SkTime_Unix.cpp",
418       "//third_party/skia/src/ports/SkTLS_pthread.cpp",
419     ]
420   } else {
421     sources -= [
422       "//third_party/skia/src/ports/SkFontHost_win.cpp",
423       "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
424       "//third_party/skia/src/ports/SkOSFile_win.cpp",
425       "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
426       "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
427       "//third_party/skia/src/ports/SkScalerContext_win_dw.h",
428       "//third_party/skia/src/ports/SkTLS_win.cpp",
429       "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
430       "//third_party/skia/src/ports/SkTypeface_win_dw.h",
431     ]
432   }
433   if (!is_android) {
434     sources -= [
435       "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
436       "//third_party/skia/src/ports/SkFontMgr_android.cpp",
437     ]
438   }
439   if (!is_mac) {
440     sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
441   }
443   if (!is_linux) {
444     sources -= [
445       "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
446       "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
447       "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
448     ]
449   }
451   if (!is_linux && !is_android) {
452     sources -= [
453       "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
454       "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
455     ]
456   }
458   # Select the right BitmapPlatformDevice.
459   if (is_win) {
460     sources += [
461       "ext/bitmap_platform_device_win.cc",
462       "ext/bitmap_platform_device_win.h",
463     ]
464   } else if (is_mac) {
465     sources += [
466       "ext/bitmap_platform_device_mac.cc",
467       "ext/bitmap_platform_device_mac.h",
468     ]
469   } else if (use_cairo) {
470     sources += [
471       "ext/bitmap_platform_device_cairo.cc",
472       "ext/bitmap_platform_device_cairo.h",
473     ]
474   } else {
475     sources += [
476       "ext/bitmap_platform_device_skia.cc",
477       "ext/bitmap_platform_device_skia.h",
478     ]
479   }
481   if (is_clang) {
482     # Skia won't compile with some of the more strict clang warnings.
483     # e.g. it does:
484     #  SkASSERT(!"sk_out_of_memory");
485     configs -= [ "//build/config/clang:extra_warnings" ]
486   }
488   configs -= [ "//build/config/compiler:chromium_code" ]
489   configs += [
490     ":skia_library_config",
491     "//build/config/compiler:no_chromium_code",
492   ]
493   public_configs = [ ":skia_config" ]
495   deps = [
496     ":skia_opts",
497     "//base",
498     "//base/third_party/dynamic_annotations",
499     "//third_party/zlib",
500   ]
502   if (is_win) {
503     configs -= [
504       # Some files define WIN32_LEAN_AND_MEAN and we want to avoid a duplicate
505       # definition warning.
506       "//build/config/win:lean_and_mean",
507     ]
508   }
510   if (is_linux) {
511     configs += [
512       "//build/config/linux:fontconfig",
513       "//build/config/linux:freetype2",
514     ]
515     if (use_pango) {
516       configs += [ "//build/config/linux:pangocairo" ]
517     }
518     deps += [ "//third_party/icu:icuuc" ]
519   }
521   if (is_android) {
522     set_sources_assignment_filter([])
523     sources += [ "ext/platform_device_linux.cc" ]
524     set_sources_assignment_filter(sources_assignment_filter)
525     deps += [
526       "//third_party/expat",
527       "//third_party/freetype",
528       "//third_party/android_tools:cpu_features",
529     ]
530   }
532   if (skia_support_pdf) {
533     deps += [ "//third_party/sfntly" ]
534     sources += gypi_skia_pdf.sources
535   }
537   if (is_android && !is_debug) {
538     configs -= [ "//build/config/compiler:optimize" ]
539     configs += [ "//build/config/compiler:optimize_max" ]
540   }
543 # Separated out so it can be compiled with different flags for SSE.
544 source_set("skia_opts") {
545   cflags = []
546   defines = []
548   if (cpu_arch == "x86" || cpu_arch == "x64") {
549     sources = gypi_skia_opts.sse2_sources + gypi_skia_opts.ssse3_sources +
550               gypi_skia_opts.sse41_sources +
551               [
552                 # Chrome-specific.
553                 "ext/convolver_SSE2.cc",
554               ]
556     if (is_linux || is_mac) {
557       cflags += [ "-msse4.1" ]
558     }
559   } else if (cpu_arch == "arm") {
560     # The assembly uses the frame pointer register (r7 in Thumb/r11 in
561     # ARM), the compiler doesn't like that.
562     cflags += [ "-fomit-frame-pointer" ]
564     if (arm_version >= 7) {
565       sources = gypi_skia_opts.armv7_sources
566       if (arm_use_neon || arm_optionally_use_neon) {
567         sources += gypi_skia_opts.neon_sources
569         # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
570         # when running this.
571         if (!arm_use_neon) {
572           configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
573           cflags += [ "-mfpu=neon" ]
574         }
575       }
576     } else {
577       sources = gypi_skia_opts.none_sourcees
578     }
579   } else if (cpu_arch == "mipsel") {
580     cflags += [ "-fomit-frame-pointer" ]
581     sources = gypi_skia_opts.none_sources
582   } else {
583     assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
584   }
586   if (is_android && !is_debug) {
587     configs -= [ "//build/config/compiler:optimize" ]
588     configs += [ "//build/config/compiler:optimize_max" ]
589   }
591   configs -= [ "//build/config/compiler:chromium_code" ]
592   configs += [
593     ":skia_config",
594     ":skia_library_config",
595     "//build/config/compiler:no_chromium_code",
596   ]
598   deps = [
599     "//base",
600   ]
602   visibility = [ ":skia" ]
605 test("skia_unittests") {
606   sources = [
607     "ext/analysis_canvas_unittest.cc",
608     "ext/bitmap_platform_device_mac_unittest.cc",
609     "ext/convolver_unittest.cc",
610     "ext/image_operations_unittest.cc",
611     "ext/pixel_ref_utils_unittest.cc",
612     "ext/platform_canvas_unittest.cc",
613     "ext/recursive_gaussian_convolution_unittest.cc",
614     "ext/refptr_unittest.cc",
615     "ext/skia_utils_ios_unittest.mm",
616     "ext/skia_utils_mac_unittest.mm",
617   ]
619   if (!is_win && !is_mac) {
620     sources -= [ "ext/platform_canvas_unittest.cc" ]
621   }
623   deps = [
624     ":skia",
625     "//base",
626     "//base/test:run_all_unittests",
627     "//testing/gtest",
628     "//ui/gfx",
629     "//ui/gfx/geometry",
630   ]