blob: 61790ebab3c7bb2304a3b2cd579194b6fd09128a [file] [log] [blame]
dsinclair11988d72016-05-04 10:17:00 -07001# 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.
4
5import("//build/config/features.gni")
6import("//build/config/ui.gni")
7import("//testing/test.gni")
brettw784548a2016-09-06 11:39:46 -07008import("//third_party/skia/gn/shared_sources.gni")
dsinclair11988d72016-05-04 10:17:00 -07009
10if (current_cpu == "arm") {
11 import("//build/config/arm.gni")
12}
13if (current_cpu == "mipsel" || current_cpu == "mips64el") {
14 import("//build/config/mips.gni")
15}
16
17skia_support_gpu = !is_ios
18skia_support_pdf = false #!is_ios && (enable_basic_printing || enable_print_preview)
19
dsinclair11988d72016-05-04 10:17:00 -070020# External-facing config for dependent code.
21config("skia_config") {
22 include_dirs = [
23 "config",
24 "ext",
25 "//third_party/skia/include/c",
26 "//third_party/skia/include/config",
27 "//third_party/skia/include/core",
28 "//third_party/skia/include/effects",
29 "//third_party/skia/include/images",
30 "//third_party/skia/include/lazy",
31 "//third_party/skia/include/pathops",
32 "//third_party/skia/include/pdf",
33 "//third_party/skia/include/pipe",
34 "//third_party/skia/include/ports",
35 "//third_party/skia/include/utils",
caryclark72708b92016-06-13 06:08:25 -070036
thestig19ea3092016-05-13 11:24:26 -070037 # TODO(dsinclair): Right way to use //third_party/freetype?
38 "//third_party/freetype/include",
dsinclair11988d72016-05-04 10:17:00 -070039 ]
40
41 defines = []
42
43 if (skia_support_gpu) {
44 include_dirs += [
45 "//third_party/skia/include/gpu",
46 "//third_party/skia/src/gpu",
47 ]
48 defines += [ "SK_SUPPORT_GPU=1" ]
49 } else {
50 defines += [ "SK_SUPPORT_GPU=0" ]
51 }
52
53 if (is_android) {
54 defines += [
55 "SK_BUILD_FOR_ANDROID",
56 "USE_CHROMIUM_SKIA",
57 ]
58 }
59
60 if (is_mac) {
61 defines += [ "SK_BUILD_FOR_MAC" ]
62 }
63
64 if (is_win) {
65 defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
66 }
67}
68
69# Internal-facing config for Skia library code.
70config("skia_library_config") {
71 # These include directories are only included for Skia code and are not
72 # exported to dependents. It's not clear if this is on purpose, but this
73 # matches the GYP build.
74 include_dirs = [
75 "//third_party/skia/include/private",
76 "//third_party/skia/include/client/android",
77 "//third_party/skia/src/core",
78 "//third_party/skia/src/image",
79 "//third_party/skia/src/opts",
80 "//third_party/skia/src/pdf",
81 "//third_party/skia/src/ports",
82 "//third_party/skia/src/sfnt",
83 "//third_party/skia/src/utils",
84 "//third_party/skia/src/lazy",
85 ]
86 if (is_mac || is_ios) {
87 include_dirs += [ "//third_party/skia/include/utils/mac" ]
88 }
89 if (is_mac) {
90 include_dirs += [ "//third_party/skia/include/utils/ios" ]
91 }
92
93 defines = []
94
95 if (current_cpu == "arm") {
96 if (arm_use_neon) {
97 defines += [ "SK_ARM_HAS_NEON" ]
98 } else if (arm_optionally_use_neon) {
99 defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
100 }
101 }
102
103 # Settings for text blitting, chosen to approximate the system browser.
104 if (is_linux) {
105 defines += [
106 "SK_GAMMA_EXPONENT=1.2",
107 "SK_GAMMA_CONTRAST=0.2",
108 ]
109 } else if (is_android) {
110 defines += [
111 "SK_GAMMA_APPLY_TO_A8",
112 "SK_GAMMA_EXPONENT=1.4",
113 "SK_GAMMA_CONTRAST=0.0",
114 ]
115 } else if (is_win) {
116 defines += [
117 "SK_GAMMA_SRGB",
118 "SK_GAMMA_CONTRAST=0.5",
119 ]
120 } else if (is_mac) {
121 defines += [
122 "SK_GAMMA_SRGB",
123 "SK_GAMMA_CONTRAST=0.0",
124 ]
125 }
126
127 if (is_android) {
128 defines += [
129 # Android devices are typically more memory constrained, so default to a
130 # smaller glyph cache (it may be overriden at runtime when the renderer
131 # starts up, depending on the actual device memory).
132 "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
133 ]
134 } else {
135 defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
136 }
137
138 if (is_win) {
139 include_dirs += [
140 "//third_party/skia/include/utils/win",
141 "//third_party/skia/src/utils/win",
142 ]
143
144 defines += [
145 # On windows, GDI handles are a scarse system-wide resource so we have to
146 # keep the glyph cache, which holds up to 4 GDI handles per entry, to a
147 # fairly small size. http://crbug.com/314387
148 "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
149 ]
150
151 cflags = [
152 "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
153 "/wd4267", # conversion from 'size_t' (64 bit) to 'type'(32 bit).
154 "/wd4341", # signed value is out of range for enum constant.
155 "/wd4345", # Object is default-initialized if initialization is omitted.
156 "/wd4390", # ';'empty statement found in looping;is it what was intended?
157 "/wd4554", # 'operator' : check operator precedence for possible error
158 "/wd4748", # compiler will disable optimizations if a function has inline
159 # assembly code contains flow control(jmp or jcc) statements.
160
161 "/wd4800", # forcing value to bool 'true/false'(assigning int to bool).
162 ]
163 }
164}
165
166component("skia") {
167 sources = [
thestig19ea3092016-05-13 11:24:26 -0700168 # PDFium sources.
dsinclair11988d72016-05-04 10:17:00 -0700169 "config/SkUserConfig.h",
170 "ext/google_logging.cc",
171 ]
172
173 # The skia gypi values are relative to the skia_dir, so we need to rebase.
brettw784548a2016-09-06 11:39:46 -0700174 sources += skia_core_sources
175 sources += skia_effects_sources
176 sources += skia_utils_sources
177 sources += [
178 "//third_party/skia/src/ports/SkImageGenerator_none.cpp",
179
180 "//third_party/skia/src/fonts/SkFontMgr_indirect.cpp",
181 "//third_party/skia/src/fonts/SkRemotableFontMgr.cpp",
182 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
183 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
184 "//third_party/skia/src/ports/SkFontHost_win.cpp",
185 "//third_party/skia/src/ports/SkFontMgr_android.cpp",
186 "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
187 "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
188 "//third_party/skia/src/ports/SkGlobalInitialization_default.cpp",
189 "//third_party/skia/src/ports/SkImageEncoder_none.cpp",
190 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
191 "//third_party/skia/src/ports/SkOSFile_stdio.cpp",
192 "//third_party/skia/src/ports/SkOSFile_win.cpp",
193 "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
194 "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
195 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
196 "//third_party/skia/src/ports/SkTLS_win.cpp",
197 "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
198 "//third_party/skia/src/sfnt/SkOTTable_name.cpp",
199 "//third_party/skia/src/sfnt/SkOTUtils.cpp",
200
201 #mac
202 "//third_party/skia/src/utils/mac/SkStream_mac.cpp",
203
204 #pdfium
205 "//third_party/skia/src/ports/SkDiscardableMemory_none.cpp",
206 "//third_party/skia/src/ports/SkFontMgr_custom.cpp",
207 "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp",
208 "//third_party/skia/src/ports/SkMemory_malloc.cpp",
209 ]
dsinclair11988d72016-05-04 10:17:00 -0700210
211 # This and skia_opts are really the same conceptual target so share headers.
212 allow_circular_includes_from = [ ":skia_opts" ]
213
214 if (current_cpu == "arm") {
215 sources += [ "//third_party/skia/src/core/SkUtilsArm.cpp" ]
216 }
217
218 # GPU
219 if (skia_support_gpu) {
brettw784548a2016-09-06 11:39:46 -0700220 sources += skia_gpu_sources
221 sources += skia_null_gpu_sources
dsinclair11988d72016-05-04 10:17:00 -0700222 }
223
224 # Remove unused util files include in utils.gypi
225 sources -= [
226 "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
227 "//third_party/skia/src/utils/SkCamera.cpp",
228 "//third_party/skia/src/utils/SkDumpCanvas.cpp",
229 "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
230 "//third_party/skia/src/utils/SkInterpolator.cpp",
231 "//third_party/skia/src/utils/SkLayer.cpp",
232 "//third_party/skia/src/utils/SkMeshUtils.cpp",
dsinclair11988d72016-05-04 10:17:00 -0700233 "//third_party/skia/src/utils/SkParsePath.cpp",
dsinclair11988d72016-05-04 10:17:00 -0700234 ]
235
236 if (is_win) {
237 sources -= [
238 # Keeping _win.cpp
239 "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
240 ]
241 } else {
242 sources -= [
243 # Keeping _pthread.cpp
244 "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
245 ]
246 }
247
248 # need separate win section to handle chromes auto gn filter
249 # (build/config/BUILDCONFIG.gn)
250 if (is_win) {
251 sources -= [
252 #windows
253 "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
254 "//third_party/skia/src/utils/win/SkIStream.cpp",
255 "//third_party/skia/src/utils/win/SkWGL_win.cpp",
256 ]
257 }
258
259 # Fixup skia library sources.
260 if (is_win) {
261 sources -= [
262 "//third_party/skia/src/ports/SkOSFile_posix.cpp",
263 "//third_party/skia/src/ports/SkTLS_pthread.cpp",
264 ]
265 } else {
266 sources -= [
267 "//third_party/skia/src/ports/SkFontHost_win.cpp",
dsinclair11988d72016-05-04 10:17:00 -0700268 "//third_party/skia/src/ports/SkOSFile_win.cpp",
269 "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
270 "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
271 "//third_party/skia/src/ports/SkTLS_win.cpp",
272 "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
273 ]
274 }
275 if (!is_android) {
276 sources -= [
277 "//third_party/skia/src/ports/SkFontMgr_android.cpp",
278 "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
279 "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
280 ]
281 }
caryclark8b301622016-07-21 06:12:33 -0700282 if (!is_linux && !is_android && !is_win && !is_mac) {
dsinclair11988d72016-05-04 10:17:00 -0700283 sources -= [
284 "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
285 "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
weilica0bc7d2016-06-22 07:24:20 -0700286 "//third_party/skia/src/ports/SkFontMgr_custom.cpp",
287 "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp",
dsinclair11988d72016-05-04 10:17:00 -0700288 ]
289 }
290
291 if (is_clang && !is_nacl) {
292 # Skia won't compile with some of the more strict clang warnings.
293 # e.g. it does:
294 # SkASSERT(!"sk_out_of_memory");
295 configs -= [ "//build/config/clang:extra_warnings" ]
296 }
297
298 configs -= [ "//build/config/compiler:chromium_code" ]
299 configs += [
300 ":skia_config",
301 ":skia_library_config",
302 "//build/config/compiler:no_chromium_code",
303 ]
304 public_configs = [ ":skia_config" ]
305
306 deps = [
307 ":skia_opts",
308 "../third_party:fx_zlib",
309 ]
310
311 if (is_linux) {
caryclark72708b92016-06-13 06:08:25 -0700312 deps += [ "//third_party/icu:icuuc" ]
dsinclair11988d72016-05-04 10:17:00 -0700313 }
314
315 if (is_android) {
316 set_sources_assignment_filter([])
317 set_sources_assignment_filter(sources_assignment_filter)
318 deps += [
319 "//third_party/android_tools:cpu_features",
320 "//third_party/expat",
321 "//third_party/freetype-android:freetype",
322 ]
323 }
324
325 if (skia_support_pdf) {
326 deps += [ "//third_party/sfntly" ]
brettw784548a2016-09-06 11:39:46 -0700327 sources += skia_pdf_sources
dsinclair11988d72016-05-04 10:17:00 -0700328 } else {
329 sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ]
330 }
331
332 if (is_android && !is_debug) {
333 configs -= [ "//build/config/compiler:default_optimization" ]
334 configs += [ "//build/config/compiler:optimize_max" ]
335 }
336
337 if (is_ios) {
338 libs = [ "ImageIO.framework" ]
339 set_sources_assignment_filter([])
340 sources += [
341 "//third_party/skia/src/ports/SkFontHost_mac.cpp",
342 "//third_party/skia/src/utils/mac/SkCreateCGImageRef.cpp",
343 "//third_party/skia/src/utils/mac/SkStream_mac.cpp",
344 ]
345 set_sources_assignment_filter(sources_assignment_filter)
346
347 # To disable warning "CGContextSelectFont' is deprecated"
348 cflags = [ "-Wno-deprecated-declarations" ]
349 }
350}
351
352# Separated out so it can be compiled with different flags for SSE.
353if (current_cpu == "x86" || current_cpu == "x64") {
354 source_set("skia_opts_sse3") {
brettw784548a2016-09-06 11:39:46 -0700355 sources = skia_opts.ssse3_sources
dsinclair11988d72016-05-04 10:17:00 -0700356 if (!is_win || is_clang) {
357 cflags = [ "-mssse3" ]
358 }
359 if (is_win) {
360 defines = [ "SK_CPU_SSE_LEVEL=31" ]
361 }
362 visibility = [ ":skia_opts" ]
363 configs -= [ "//build/config/compiler:chromium_code" ]
364 configs += [
365 ":skia_config",
366 ":skia_library_config",
367 "//build/config/compiler:no_chromium_code",
368 ]
369 }
370 source_set("skia_opts_sse41") {
brettw784548a2016-09-06 11:39:46 -0700371 sources = skia_opts.sse41_sources
dsinclair11988d72016-05-04 10:17:00 -0700372 if (!is_win || is_clang) {
373 cflags = [ "-msse4.1" ]
374 }
375 if (is_win) {
376 defines = [ "SK_CPU_SSE_LEVEL=41" ]
377 }
378 visibility = [ ":skia_opts" ]
379 configs -= [ "//build/config/compiler:chromium_code" ]
380 configs += [
381 ":skia_config",
382 ":skia_library_config",
383 "//build/config/compiler:no_chromium_code",
384 ]
385 }
386 source_set("skia_opts_sse42") {
brettw784548a2016-09-06 11:39:46 -0700387 sources = skia_opts.sse42_sources
dsinclair11988d72016-05-04 10:17:00 -0700388 if (!is_win || is_clang) {
389 cflags = [ "-msse4.2" ]
390 }
391 if (is_win) {
392 defines = [ "SK_CPU_SSE_LEVEL=42" ]
393 }
394 visibility = [ ":skia_opts" ]
395 configs -= [ "//build/config/compiler:chromium_code" ]
396 configs += [
397 ":skia_config",
398 ":skia_library_config",
399 "//build/config/compiler:no_chromium_code",
400 ]
401 }
402 source_set("skia_opts_avx") {
brettw784548a2016-09-06 11:39:46 -0700403 sources = skia_opts.avx_sources
dsinclair11988d72016-05-04 10:17:00 -0700404 if (!is_win) {
405 cflags = [ "-mavx" ]
406 }
407 if (is_win) {
408 cflags = [ "/arch:AVX" ]
409 }
410 visibility = [ ":skia_opts" ]
411 configs -= [ "//build/config/compiler:chromium_code" ]
412 configs += [
413 ":skia_config",
414 ":skia_library_config",
415 "//build/config/compiler:no_chromium_code",
416 ]
417 }
418 source_set("skia_opts_avx2") {
brettw784548a2016-09-06 11:39:46 -0700419 sources = skia_opts.avx2_sources
dsinclair11988d72016-05-04 10:17:00 -0700420 if (!is_win) {
421 cflags = [ "-mavx2" ]
422 }
423 if (is_win) {
424 cflags = [ "/arch:AVX2" ]
425 }
426 visibility = [ ":skia_opts" ]
427 configs -= [ "//build/config/compiler:chromium_code" ]
428 configs += [
429 ":skia_config",
430 ":skia_library_config",
431 "//build/config/compiler:no_chromium_code",
432 ]
433 }
434}
435source_set("skia_opts") {
436 cflags = []
437 defines = []
438
439 if (current_cpu == "x86" || current_cpu == "x64") {
brettw784548a2016-09-06 11:39:46 -0700440 sources = skia_opts.sse2_sources
dsinclair11988d72016-05-04 10:17:00 -0700441 deps = [
442 ":skia_opts_avx",
443 ":skia_opts_avx2",
444 ":skia_opts_sse3",
445 ":skia_opts_sse41",
446 ":skia_opts_sse42",
447 ]
448 } else if (current_cpu == "arm") {
449 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
450 # ARM), the compiler doesn't like that.
451 cflags += [ "-fomit-frame-pointer" ]
452
453 if (arm_version >= 7) {
brettw784548a2016-09-06 11:39:46 -0700454 sources = skia_opts.armv7_sources
dsinclair11988d72016-05-04 10:17:00 -0700455 if (arm_use_neon || arm_optionally_use_neon) {
brettw784548a2016-09-06 11:39:46 -0700456 sources += skia_opts.neon_sources
dsinclair11988d72016-05-04 10:17:00 -0700457
458 # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
459 # when running this.
460 if (!arm_use_neon) {
461 configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
462 cflags += [ "-mfpu=neon" ]
463 }
464 }
465 } else {
brettw784548a2016-09-06 11:39:46 -0700466 sources = skia_opts.none_sources
dsinclair11988d72016-05-04 10:17:00 -0700467 }
468 } else if (current_cpu == "arm64") {
brettw784548a2016-09-06 11:39:46 -0700469 sources = skia_opts.arm64_sources
dsinclair11988d72016-05-04 10:17:00 -0700470 } else if (current_cpu == "mipsel") {
471 cflags += [ "-fomit-frame-pointer" ]
472
473 if (mips_dsp_rev >= 1) {
brettw784548a2016-09-06 11:39:46 -0700474 sources = skia_opts.mips_dsp_sources
dsinclair11988d72016-05-04 10:17:00 -0700475 } else {
brettw784548a2016-09-06 11:39:46 -0700476 sources = skia_opts.none_sources
dsinclair11988d72016-05-04 10:17:00 -0700477 }
478 } else if (current_cpu == "mips64el") {
479 cflags += [ "-fomit-frame-pointer" ]
brettw784548a2016-09-06 11:39:46 -0700480 sources = skia_opts.none_sources
dsinclair11988d72016-05-04 10:17:00 -0700481 } else {
482 assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
483 }
484
485 if (is_android && !is_debug) {
486 configs -= [ "//build/config/compiler:default_optimization" ]
487 configs += [ "//build/config/compiler:optimize_max" ]
488 }
489
490 configs -= [ "//build/config/compiler:chromium_code" ]
491 configs += [
492 ":skia_config",
493 ":skia_library_config",
494 "//build/config/compiler:no_chromium_code",
495 ]
496
497 visibility = [ ":skia" ]
498}