Make RendererMediaPlayerManager a RenderFrameObserver.
[chromium-blink-merge.git] / skia / BUILD.gn
blob9bd47061ad1bc812c02c6af0cf9f36194bebc398
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" ],
20     "scope",
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" ],
29     "scope",
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" ],
38     "scope",
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" ],
47     "scope",
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" ],
56     "scope",
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" ],
65     "scope",
66     [ "skia_gn_files.gypi" ])
68 # External-facing config for dependent code.
69 config("skia_config") {
70   include_dirs = [
71     "config",
72     "ext",
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",
90   ]
92   defines = gypi_skia_defines.skia_for_chromium_defines
94   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",
102   ]
104   if (component_mode == "shared_library") {
105     defines += [ "SKIA_DLL" ]
106   }
108   if (skia_support_gpu) {
109     include_dirs += [
110       "//third_party/skia/include/gpu",
111       "//third_party/skia/src/gpu",
112     ]
113     defines += [ "SK_SUPPORT_GPU=1" ]
114   } else {
115     defines += [ "SK_SUPPORT_GPU=0" ]
116   }
118   # For POSIX platforms, prefer the Mutex implementation provided by Skia
119   # since it does not generate static initializers.
120   if (is_posix) {
121     defines += [ "SK_USE_POSIX_THREADS" ]
122   }
124   if (is_android) {
125     defines += [
126       "SK_BUILD_FOR_ANDROID",
127       "USE_CHROMIUM_SKIA",
128     ]
129   }
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.
137   include_dirs = []
138   if (is_mac || is_ios) {
139     include_dirs += [ "//third_party/skia/include/utils/mac" ]
140   }
141   if (is_mac) {
142     include_dirs += [ "//third_party/skia/include/utils/ios" ]
143   }
145   defines = [
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",
172   ]
174   # Settings for text blitting, chosen to approximate the system browser.
175   if (is_linux) {
176     defines += [
177       "SK_GAMMA_EXPONENT=1.2",
178       "SK_GAMMA_CONTRAST=0.2",
179       "SK_HIGH_QUALITY_IS_LANCZOS",
180     ]
181   } else if (is_android) {
182     defines += [
183       "SK_GAMMA_APPLY_TO_A8",
184       "SK_GAMMA_EXPONENT=1.4",
185       "SK_GAMMA_CONTRAST=0.0",
186     ]
187   } else if (is_win) {
188     defines += [
189       "SK_GAMMA_SRGB",
190       "SK_GAMMA_CONTRAST=0.5",
191       "SK_HIGH_QUALITY_IS_LANCZOS",
192     ]
193   } else if (is_mac) {
194     defines += [
195       "SK_GAMMA_SRGB",
196       "SK_GAMMA_CONTRAST=0.0",
197       "SK_HIGH_QUALITY_IS_LANCZOS",
198     ]
199   }
201   if (is_android) {
202     defines += [
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
207     ]
208   } else {
209     defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ]  # 20 * 1024 * 1024
210   }
212   if (is_win) {
213     include_dirs = [
214       "//third_party/skia/include/utils/win",
215       "//third_party/skia/src/utils/win",
216     ]
218     defines += [ "SK_FONTHOST_USES_FONTMGR" ]
220     cflags = [
221       # TODO(brettw) comment what these are.
222       "/wd4244",
223       "/wd4267",
224       "/wd4341",
225       "/wd4345",
226       "/wd4390",
227       "/wd4554",
228       "/wd4748",
229       "/wd4800",
230     ]
231   }
234 component("skia") {
235   sources = [
236     # Chrome sources.
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",
250     "ext/convolver.cc",
251     "ext/convolver.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",
275     "ext/refptr.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",
293   ]
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
301   # GPU
302   if (skia_support_gpu) {
303     sources += gypi_skia_gpu.skgpu_sources
304     sources += gypi_skia_gpu.skgpu_null_gl_sources
305   }
307   # Fixup Chrome sources.
308   if (is_posix) {
309     sources -= [ "ext/SkThread_chrome.cc" ]
310   }
311   if (is_ios) {
312     sources -= [ "ext/vector_platform_device_skia.cc" ]
313   }
314   if (is_win) {
315     sources -= [ "ext/SkThread_chrome.cc" ]
316   }
317   if (is_android && enable_printing == 0) {
318     sources -= [
319       "ext/skia_utils_base.cc",
320       "ext/vector_platform_device_skia.cc"
321     ]
322   }
324   # Fixup skia library sources.
325   if (is_win) {
326     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",
330     ]
331   } else {
332     sources -= [
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",
339     ]
340   }
341   if (!is_android) {
342     sources -= [
343       "//third_party/skia/src/ports/SkFontConfigInterface_android.cpp",
344       "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
345     ]
346   }
347   if (!is_mac) {
348     sources -= [
349       "//third_party/skia/src/ports/SkFontHost_mac.cpp",
350       "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
351     ]
352   }
353   if (!is_linux) {
354     sources -= [
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",
362     ]
363   } else if (!is_android) {
364     sources -= [
365       "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
366       "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
367     ]
368   }
369   if (!is_posix) {
370     sources -= [
371       "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
372     ]
373   }
375   sources -= [
376     # This file is a stub for systems that use pthreads but aren't covered by
377     # one of the more specific pthread files. We don't support any such
378     # systems.
379     "//third_party/skia/src/utils/SkThreadUtils_pthread_other.cpp",
380   ]
382   if (!use_cairo) {
383     sources -= [
384       "ext/bitmap_platform_device_cairo.cc",
385       "ext/bitmap_platform_device_cairo.h",
386     ]
387   }
389   if (is_clang) {
390     # Skia won't compile with some of the more strict clang warnings.
391     # e.g. it does:
392     #  SkASSERT(!"sk_out_of_memory");
393     configs -= [ "//build/config/clang:extra_warnings" ]
394   }
396   configs -= [ "//build/config/compiler:chromium_code" ]
397   configs += [
398     ":skia_library_config",
399     "//build/config/compiler:no_chromium_code"
400   ]
401   direct_dependent_configs = [ ":skia_config" ]
403   deps = [
404     ":skia_opts",
405     "//base",
406     "//base/third_party/dynamic_annotations",
407     "//third_party/zlib",
408   ]
410   if (component_mode == "shared_library") {
411     defines = [ "SKIA_IMPLEMENTATION=1" ]
412   }
414   if (is_win) {
415     configs -= [
416       # Some files define WIN32_LEAN_AND_MEAN and we want to avoid a duplicate
417       # definition warning.
418       "//build/config/win:lean_and_mean",
419     ]
420   }
422   if (is_linux) {
423     configs += [
424       "//build/config/linux:fontconfig",
425       "//build/config/linux:freetype2",
426       "//build/config/linux:pangocairo",
427     ]
428     deps += [
429       "//third_party/icu:icuuc",
430     ]
431   }
433   if (is_android) {
434     deps += [
435       "//third_party/expat",
436       "//third_party/freetype",
437     ]
438   }
440   if (skia_support_pdf) {
441     deps += [ "//third_party/sfntly" ]
442   }
445 # Separated out so it can be compiled with different flags for SSE.
446 source_set("skia_opts") {
447   cflags = []
448   defines = []
450   if (cpu_arch == "x86" || cpu_arch == "x64") {
451     sources = [
452       # SSE 2
453       "//third_party/skia/src/opts/opts_check_x86.cpp",
454       "//third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp",
455       "//third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp",
456       "//third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp",
457       "//third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp",
458       "//third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp",
459       "//third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp",
460       "//third_party/skia/src/opts/SkUtils_opts_SSE2.cpp",
461       "//third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp",
463       # SSE 3
464       "//third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp",
466       # Chrome-specific.
467       "ext/convolver_SSE2.cc",
469       # These are header files used by this target from the skia one above.
470       "ext/convolver.h",
471       "//third_party/skia/include/core/SkTypes.h",
472     ]
474     if (is_linux || is_mac) {
475       cflags += [ "-mssse3" ]  # Note third 's'.
476     }
477   } else if (cpu_arch == "arm") {
478     sources = [
479       "//third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp",
480     ]
482     # The assembly uses the frame pointer register (r7 in Thumb/r11 in
483     # ARM), the compiler doesn't like that.
484     cflags += [ "-fomit-frame-pointer" ]
486     if (arm_version >= 7) {
487       if (arm_use_neon || arm_optionally_use_neon) {
488         sources += [
489           "//third_party/skia/src/opts/memset16_neon.S",
490           "//third_party/skia/src/opts/memset32_neon.S",
491           "//third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp",
492           "//third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
493           "//third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h",
494           "//third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h",
495           "//third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp",
496           "//third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp",
497           "//third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp",
498           "//third_party/skia/src/opts/SkBlurImage_opts_neon.cpp",
499           "//third_party/skia/src/opts/SkMorphology_opts_neon.cpp",
500         ]
502         cflags += [
503           # The neon assembly contains conditional instructions which aren't
504           # enclosed in an IT block. The assembler complains without this
505           # option. See #86592.
506           "-Wa,-mimplicit-it=always",
507         ]
509         # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
510         # when running this.
511         assert(arm_fpu == "neon")
513         #ldflags = [
514         #  "-march=armv7-a",
515         #  "-Wl,--fix-cortex-a8",
516         #]
517       }
519       if (arm_use_neon) {
520         defines += [ "__ARM_HAVE_NEON" ]
521       }
522       if (arm_optionally_use_neon) {
523         defines += [ "__ARM_HAVE_OPTIONAL_NEON_SUPPORT" ]
524       }
525     }
527     # Non-Neon ARM code.
528     if (arm_version < 7 || (!arm_use_neon && arm_optionally_use_neon)) {
529       sources += [ "//third_party/skia/src/opts/memset.arm.S" ]
530     }
532     if (arm_version < 6) {
533       sources += [
534         "//third_party/skia/src/opts/SkBlitMask_opts_none.cpp",
535         "//third_party/skia/src/opts/SkBlitRow_opts_none.cpp",
536         "//third_party/skia/src/opts/SkUtils_opts_none.cpp",
537         "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
538         "//third_party/skia/src/opts/SkMorphology_opts_none.cpp",
539         "//third_party/skia/src/opts/SkBlurImage_opts_none.cpp",
540       ]
541     } else {
542       # arm version >= 6.
543       sources += [
544         "//third_party/skia/src/opts/SkBlitMask_opts_arm.cpp",
545         "//third_party/skia/src/opts/SkBlitRow_opts_arm.cpp",
546         "//third_party/skia/src/opts/SkBlitRow_opts_arm.h",
547         "//third_party/skia/src/opts/SkBlurImage_opts_arm.cpp",
548         "//third_party/skia/src/opts/SkMorphology_opts_arm.cpp",
549         "//third_party/skia/src/opts/SkUtils_opts_arm.cpp",
550         "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
551       ]
552     }
555   } else {
556     assert(false, "Need to port MIPS stuff from skia_library_opts.gyp")
557   }
559   configs -= [ "//build/config/compiler:chromium_code" ]
560   configs += [
561     ":skia_config",
562     "//build/config/compiler:no_chromium_code"
563   ]
565   deps = [
566     "//base",
567   ]
569   visibility = ":skia"