Use user set rate when reading math.
[chromium-blink-merge.git] / skia / BUILD.gn
blobeb54593088922dd0c1adc673afad52f3fe8e23e6
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")
10 if (is_android) {
11   import("//build/config/android/rules.gni")
14 skia_support_gpu = !is_ios
15 skia_support_pdf = !is_ios && (enable_basic_printing || enable_print_preview)
17 # The list of Skia defines that are to be set for blink.
18 gypi_blink_skia_defines =
19     exec_script("//build/gypi_to_gn.py",
20                 [
21                   rebase_path(
22                       "//third_party/WebKit/public/blink_skia_config.gypi"),
23                   "--replace=<(skia_include_path)=//third_party/skia/include",
24                   "--replace=<(skia_src_path)=//third_party/skia/src",
25                 ],
26                 "scope",
27                 [ "//third_party/WebKit/public/blink_skia_config.gypi" ])
29 # The list of Skia defines that are to be set for chromium.
30 gypi_skia_defines =
31     exec_script("//build/gypi_to_gn.py",
32                 [
33                   rebase_path(
34                       "//third_party/skia/gyp/skia_for_chromium_defines.gypi"),
35                   "--replace=<(skia_include_path)=//third_party/skia/include",
36                   "--replace=<(skia_src_path)=//third_party/skia/src",
37                 ],
38                 "scope",
39                 [ "//third_party/skia/gyp/skia_for_chromium_defines.gypi" ])
41 # The list of Skia core sources that are to be set for chromium.
42 gypi_skia_core =
43     exec_script("//build/gypi_to_gn.py",
44                 [
45                   rebase_path("//third_party/skia/gyp/core.gypi"),
46                   "--replace=<(skia_include_path)=//third_party/skia/include",
47                   "--replace=<(skia_src_path)=//third_party/skia/src",
48                 ],
49                 "scope",
50                 [ "//third_party/skia/gyp/core.gypi" ])
52 # The list of Skia gpu sources that are to be set for chromium.
53 gypi_skia_gpu =
54     exec_script("//build/gypi_to_gn.py",
55                 [
56                   rebase_path("//third_party/skia/gyp/gpu.gypi"),
57                   "--replace=<(skia_include_path)=//third_party/skia/include",
58                   "--replace=<(skia_src_path)=//third_party/skia/src",
59                 ],
60                 "scope",
61                 [ "//third_party/skia/gyp/gpu.gypi" ])
63 # The list of Skia pdf sources that are to be set for chromium.
64 gypi_skia_pdf =
65     exec_script("//build/gypi_to_gn.py",
66                 [
67                   rebase_path("//third_party/skia/gyp/pdf.gypi"),
68                   "--replace=<(skia_include_path)=//third_party/skia/include",
69                   "--replace=<(skia_src_path)=//third_party/skia/src",
70                 ],
71                 "scope",
72                 [ "//third_party/skia/gyp/pdf.gypi" ])
74 # The list of Skia effects that are to be set for chromium.
75 gypi_skia_effects =
76     exec_script("//build/gypi_to_gn.py",
77                 [
78                   rebase_path("//third_party/skia/gyp/effects.gypi"),
79                   "--replace=<(skia_include_path)=//third_party/skia/include",
80                   "--replace=<(skia_src_path)=//third_party/skia/src",
81                 ],
82                 "scope",
83                 [ "//third_party/skia/gyp/effects.gypi" ])
85 # The list of Skia utilss that are to be set for chromium.
86 gypi_skia_utils =
87     exec_script("//build/gypi_to_gn.py",
88                 [
89                   rebase_path("//third_party/skia/gyp/utils.gypi"),
90                   "--replace=<(skia_include_path)=//third_party/skia/include",
91                   "--replace=<(skia_src_path)=//third_party/skia/src",
92                 ],
93                 "scope",
94                 [ "//third_party/skia/gyp/utils.gypi" ])
96 # The list of Skia files is kept in skia_gn_files.gypi. Read it.
97 gypi_values =
98     exec_script("//build/gypi_to_gn.py",
99                 [
100                   rebase_path("skia_gn_files.gypi"),
101                   "--replace=<(skia_include_path)=//third_party/skia/include",
102                   "--replace=<(skia_src_path)=//third_party/skia/src",
103                 ],
104                 "scope",
105                 [ "skia_gn_files.gypi" ])
107 # External-facing config for dependent code.
108 config("skia_config") {
109   include_dirs = [
110     "config",
111     "ext",
112     "//third_party/skia/include/c",
113     "//third_party/skia/include/config",
114     "//third_party/skia/include/core",
115     "//third_party/skia/include/effects",
116     "//third_party/skia/include/images",
117     "//third_party/skia/include/lazy",
118     "//third_party/skia/include/pathops",
119     "//third_party/skia/include/pdf",
120     "//third_party/skia/include/pipe",
121     "//third_party/skia/include/ports",
122     "//third_party/skia/include/utils",
123     "//third_party/skia/src/core",
124     "//third_party/skia/src/image",
125     "//third_party/skia/src/opts",
126     "//third_party/skia/src/pdf",
127     "//third_party/skia/src/ports",
128     "//third_party/skia/src/sfnt",
129     "//third_party/skia/src/utils",
130     "//third_party/skia/src/lazy",
131   ]
133   defines = gypi_blink_skia_defines.blink_skia_defines
134   defines += gypi_skia_defines.skia_for_chromium_defines
136   defines += [
137     "SK_ENABLE_INST_COUNT=0",
138     "GR_GL_CUSTOM_SETUP_HEADER=\"GrGLConfig_chrome.h\"",
139     "SK_ENABLE_LEGACY_API_ALIASING=1",
140     "SK_ATTR_DEPRECATED=SK_NOTHING_ARG1",
141     "GR_GL_IGNORE_ES3_MSAA=0",
142     "SK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT",
143     "SK_SUPPORT_LEGACY_GETTOTALCLIP",
144   ]
146   if (component_mode == "shared_library") {
147     defines += [ "SKIA_DLL" ]
148   }
150   if (skia_support_gpu) {
151     include_dirs += [
152       "//third_party/skia/include/gpu",
153       "//third_party/skia/src/gpu",
154     ]
155     defines += [ "SK_SUPPORT_GPU=1" ]
156   } else {
157     defines += [ "SK_SUPPORT_GPU=0" ]
158   }
160   # For POSIX platforms, prefer the Mutex implementation provided by Skia
161   # since it does not generate static initializers.
162   if (is_posix) {
163     defines += [ "SK_USE_POSIX_THREADS" ]
164   }
166   if (is_android) {
167     defines += [
168       "SK_BUILD_FOR_ANDROID",
169       "USE_CHROMIUM_SKIA",
170     ]
171   }
173   if (is_mac) {
174     defines += [ "SK_BUILD_FOR_MAC" ]
175   }
178 # Internal-facing config for Skia library code.
179 config("skia_library_config") {
180   # These include directories are only included for Skia code and are not
181   # exported to dependents. It's not clear if this is on purpose, but this
182   # matches the GYP build.
183   include_dirs = []
184   if (is_mac || is_ios) {
185     include_dirs += [ "//third_party/skia/include/utils/mac" ]
186   }
187   if (is_mac) {
188     include_dirs += [ "//third_party/skia/include/utils/ios" ]
189   }
191   defines = [
192     #skia_export_defines ???) TODO
194     # skia uses static initializers to initialize the serialization logic
195     # of its "pictures" library. This is currently not used in chrome; if
196     # it ever gets used the processes that use it need to call
197     # SkGraphics::Init().
198     "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0",
200     # Forcing the unoptimized path for the offset image filter in skia until
201     # all filters used in Blink support the optimized path properly
202     "SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION",
203     "IGNORE_ROT_AA_RECT_OPT",
204     "SK_IGNORE_BLURRED_RRECT_OPT",
206     # this flag forces Skia not to use typographic metrics with GDI.
207     "SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS",
208     "SK_USE_DISCARDABLE_SCALEDIMAGECACHE",
209   ]
211   if (component_mode == "shared_library") {
212     defines += [ "SKIA_IMPLEMENTATION=1" ]
213   }
215   if (cpu_arch == "arm") {
216     if (arm_use_neon) {
217       defines += [ "SK_ARM_HAS_NEON" ]
218     }
219     if (arm_optionally_use_neon) {
220       defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
221     }
222   }
224   # Settings for text blitting, chosen to approximate the system browser.
225   if (is_linux) {
226     defines += [
227       "SK_GAMMA_EXPONENT=1.2",
228       "SK_GAMMA_CONTRAST=0.2",
229       "SK_HIGH_QUALITY_IS_LANCZOS",
230     ]
231   } else if (is_android) {
232     defines += [
233       "SK_GAMMA_APPLY_TO_A8",
234       "SK_GAMMA_EXPONENT=1.4",
235       "SK_GAMMA_CONTRAST=0.0",
236     ]
237   } else if (is_win) {
238     defines += [
239       "SK_GAMMA_SRGB",
240       "SK_GAMMA_CONTRAST=0.5",
241       "SK_HIGH_QUALITY_IS_LANCZOS",
242     ]
243   } else if (is_mac) {
244     defines += [
245       "SK_GAMMA_SRGB",
246       "SK_GAMMA_CONTRAST=0.0",
247       "SK_HIGH_QUALITY_IS_LANCZOS",
248     ]
249   }
251   if (is_android) {
252     defines += [
253       # Android devices are typically more memory constrained, so default to a
254       # smaller glyph cache (it may be overriden at runtime when the renderer
255       # starts up, depending on the actual device memory).
256       "SK_DEFAULT_FONT_CACHE_LIMIT=1048576",  # 1024 * 1024
257     ]
258   } else {
259     defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ]  # 20 * 1024 * 1024
260   }
262   if (is_win) {
263     include_dirs = [
264       "//third_party/skia/include/utils/win",
265       "//third_party/skia/src/utils/win",
266     ]
268     defines += [ "SK_FONTHOST_USES_FONTMGR" ]
270     cflags = [
271       "/wd4244",  # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
272       "/wd4267",  # conversion from 'size_t' (64 bit) to 'type'(32 bit).
273       "/wd4341",  # signed value is out of range for enum constant.
274       "/wd4345",  # Object is default-initialized if initialization is omitted.
275       "/wd4390",  # ';'empty statement found in looping;is it what was intended?
276       "/wd4554",  # 'operator' : check operator precedence for possible error
277       "/wd4748",  # compiler will disable optimizations if a function has inline
278                   # assembly code contains flow control(jmp or jcc) statements.
279       "/wd4800",  # forcing value to bool 'true/false'(assigning int to bool).
280     ]
281   }
284 component("skia") {
285   sources = [
286     # Chrome sources.
287     "config/SkUserConfig.h",
288     "ext/analysis_canvas.cc",
289     "ext/analysis_canvas.h",
290     "ext/benchmarking_canvas.cc",
291     "ext/benchmarking_canvas.h",
292     "ext/bitmap_platform_device.h",
293     "ext/convolver.cc",
294     "ext/convolver.h",
295     "ext/event_tracer_impl.cc",
296     "ext/event_tracer_impl.h",
297     "ext/fontmgr_default_win.cc",
298     "ext/fontmgr_default_win.h",
299     "ext/google_logging.cc",
300     "ext/image_operations.cc",
301     "ext/image_operations.h",
302     "ext/opacity_draw_filter.cc",
303     "ext/opacity_draw_filter.h",
304     "ext/pixel_ref_utils.cc",
305     "ext/pixel_ref_utils.h",
306     "ext/platform_canvas.cc",
307     "ext/platform_canvas.h",
308     "ext/platform_device.cc",
309     "ext/platform_device.h",
310     "ext/platform_device_linux.cc",
311     "ext/platform_device_mac.cc",
312     "ext/platform_device_win.cc",
313     "ext/recursive_gaussian_convolution.cc",
314     "ext/recursive_gaussian_convolution.h",
315     "ext/refptr.h",
316     "ext/SkDiscardableMemory_chrome.h",
317     "ext/SkDiscardableMemory_chrome.cc",
318     "ext/SkMemory_new_handler.cpp",
319     "ext/skia_utils_base.cc",
320     "ext/skia_utils_base.h",
321     "ext/skia_utils_ios.mm",
322     "ext/skia_utils_ios.h",
323     "ext/skia_utils_mac.mm",
324     "ext/skia_utils_mac.h",
325     "ext/skia_utils_win.cc",
326     "ext/skia_utils_win.h",
327     "ext/vector_canvas.h",
328     "ext/vector_platform_device_emf_win.cc",
329     "ext/vector_platform_device_emf_win.h",
330   ]
332   # The skia gypi values are relative to the skia_dir, so we need to rebase.
333   sources += gypi_skia_core.sources
334   sources += gypi_skia_effects.sources
335   sources += gypi_skia_utils.sources
336   sources += gypi_values.skia_library_sources
338   if (cpu_arch == "arm") {
339     sources += [
340       "//third_party/skia/src/core/SkUtilsArm.cpp",
341       "//third_party/skia/src/core/SkUtilsArm.h",
342     ]
343   }
345   # GPU
346   if (skia_support_gpu) {
347     sources += gypi_skia_gpu.skgpu_sources
348     sources += gypi_skia_gpu.skgpu_null_gl_sources
349   }
351   # Remove unused util files include in utils.gypi
352   sources -= [
353     "//third_party/skia/include/utils/SkBoundaryPatch.h",
354     "//third_party/skia/include/utils/SkFrontBufferedStream.h",
355     "//third_party/skia/include/utils/SkCamera.h",
356     "//third_party/skia/include/utils/SkCanvasStateUtils.h",
357     "//third_party/skia/include/utils/SkCubicInterval.h",
358     "//third_party/skia/include/utils/SkCullPoints.h",
359     "//third_party/skia/include/utils/SkDebugUtils.h",
360     "//third_party/skia/include/utils/SkDumpCanvas.h",
361     "//third_party/skia/include/utils/SkEventTracer.h",
362     "//third_party/skia/include/utils/SkInterpolator.h",
363     "//third_party/skia/include/utils/SkLayer.h",
364     "//third_party/skia/include/utils/SkMeshUtils.h",
365     "//third_party/skia/include/utils/SkNinePatch.h",
366     "//third_party/skia/include/utils/SkParse.h",
367     "//third_party/skia/include/utils/SkParsePaint.h",
368     "//third_party/skia/include/utils/SkParsePath.h",
369     "//third_party/skia/include/utils/SkRandom.h",
370     "//third_party/skia/src/utils/SkBitmapHasher.cpp",
371     "//third_party/skia/src/utils/SkBitmapHasher.h",
372     "//third_party/skia/src/utils/SkBoundaryPatch.cpp",
373     "//third_party/skia/src/utils/SkFrontBufferedStream.cpp",
374     "//third_party/skia/src/utils/SkCamera.cpp",
375     "//third_party/skia/src/utils/SkCanvasStack.h",
376     "//third_party/skia/src/utils/SkCubicInterval.cpp",
377     "//third_party/skia/src/utils/SkCullPoints.cpp",
378     "//third_party/skia/src/utils/SkDumpCanvas.cpp",
379     "//third_party/skia/src/utils/SkFloatUtils.h",
380     "//third_party/skia/src/utils/SkGatherPixelRefsAndRects.cpp",
381     "//third_party/skia/src/utils/SkGatherPixelRefsAndRects.h",
382     "//third_party/skia/src/utils/SkInterpolator.cpp",
383     "//third_party/skia/src/utils/SkLayer.cpp",
384     "//third_party/skia/src/utils/SkMD5.cpp",
385     "//third_party/skia/src/utils/SkMD5.h",
386     "//third_party/skia/src/utils/SkMeshUtils.cpp",
387     "//third_party/skia/src/utils/SkNinePatch.cpp",
388     "//third_party/skia/src/utils/SkOSFile.cpp",
389     "//third_party/skia/src/utils/SkParse.cpp",
390     "//third_party/skia/src/utils/SkParseColor.cpp",
391     "//third_party/skia/src/utils/SkParsePath.cpp",
392     "//third_party/skia/src/utils/SkPathUtils.cpp",
393     "//third_party/skia/src/utils/SkSHA1.cpp",
394     "//third_party/skia/src/utils/SkSHA1.h",
395     "//third_party/skia/src/utils/SkTFitsIn.h",
396     "//third_party/skia/src/utils/SkTLogic.h",
398     # We don't currently need to change thread affinity, so leave out this complexity for now.
399     "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
400     "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
402     #testing
403     "//third_party/skia/src/fonts/SkGScalerContext.cpp",
404     "//third_party/skia/src/fonts/SkGScalerContext.h",
405   ]
407   if (is_win) {
408     sources -= [
409       # Keeping _win.cpp
410       "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
411       "//third_party/skia/src/utils/SkThreadUtils_pthread_other.cpp",
412     ]
413   } else {
414     sources -= [
415       # Keeping _pthread.cpp and _pthread_other.cpp.
416       "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
417     ]
418   }
420   # need separate win section to handle chromes auto gn filter
421   # (build/config/BUILDCONFIG.gn)
422   if (is_win) {
423     sources -= [
424       #windows
425       "//third_party/skia/include/utils/win/SkAutoCoInitialize.h",
426       "//third_party/skia/include/utils/win/SkHRESULT.h",
427       "//third_party/skia/include/utils/win/SkIStream.h",
428       "//third_party/skia/include/utils/win/SkTScopedComPtr.h",
429       "//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
430       "//third_party/skia/src/utils/win/SkIStream.cpp",
431       "//third_party/skia/src/utils/win/SkWGL_win.cpp",
432     ]
433   }
435   if (is_android && (!enable_basic_printing && !enable_print_preview)) {
436     sources -= [ "ext/skia_utils_base.cc" ]
437   }
439   # Fixup skia library sources.
440   if (is_win) {
441     sources -= [
442       "//third_party/skia/src/ports/SkOSFile_posix.cpp",
443       "//third_party/skia/src/ports/SkTime_Unix.cpp",
444       "//third_party/skia/src/ports/SkTLS_pthread.cpp",
445     ]
446   } else {
447     sources -= [
448       "//third_party/skia/src/ports/SkFontHost_win.cpp",
449       "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
450       "//third_party/skia/src/ports/SkOSFile_win.cpp",
451       "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
452       "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
453       "//third_party/skia/src/ports/SkScalerContext_win_dw.h",
454       "//third_party/skia/src/ports/SkTLS_win.cpp",
455       "//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
456       "//third_party/skia/src/ports/SkTypeface_win_dw.h",
457     ]
458   }
459   if (!is_android) {
460     sources -= [
461       "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
462       "//third_party/skia/src/ports/SkFontMgr_android.cpp",
463     ]
464   }
465   if (!is_mac) {
466     sources -= [ "//third_party/skia/src/ports/SkFontHost_mac.cpp" ]
467   }
469   if (!is_linux) {
470     sources -= [
471       "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
472       "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
473       "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
474     ]
475   }
477   if (!is_linux && !is_android) {
478     sources -= [
479       "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
480       "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
481     ]
482   }
484   # Select the right BitmapPlatformDevice.
485   if (is_win) {
486     sources += [
487       "ext/bitmap_platform_device_win.cc",
488       "ext/bitmap_platform_device_win.h",
489     ]
490   } else if (is_mac) {
491     sources += [
492       "ext/bitmap_platform_device_mac.cc",
493       "ext/bitmap_platform_device_mac.h",
494     ]
495   } else if (use_cairo) {
496     sources += [
497       "ext/bitmap_platform_device_cairo.cc",
498       "ext/bitmap_platform_device_cairo.h",
499     ]
500   } else {
501     sources += [
502       "ext/bitmap_platform_device_skia.cc",
503       "ext/bitmap_platform_device_skia.h",
504     ]
505   }
507   if (is_clang) {
508     # Skia won't compile with some of the more strict clang warnings.
509     # e.g. it does:
510     #  SkASSERT(!"sk_out_of_memory");
511     configs -= [ "//build/config/clang:extra_warnings" ]
512   }
514   configs -= [ "//build/config/compiler:chromium_code" ]
515   configs += [
516     ":skia_library_config",
517     "//build/config/compiler:no_chromium_code",
518   ]
519   public_configs = [ ":skia_config" ]
521   deps = [
522     ":skia_opts",
523     "//base",
524     "//base/third_party/dynamic_annotations",
525     "//third_party/zlib",
526   ]
528   if (is_win) {
529     configs -= [
530       # Some files define WIN32_LEAN_AND_MEAN and we want to avoid a duplicate
531       # definition warning.
532       "//build/config/win:lean_and_mean",
533     ]
534   }
536   if (is_linux) {
537     configs += [
538       "//build/config/linux:fontconfig",
539       "//build/config/linux:freetype2",
540       "//build/config/linux:pangocairo",
541     ]
542     deps += [ "//third_party/icu:icuuc" ]
543   }
545   if (is_android) {
546     set_sources_assignment_filter([])
547     sources += [ "ext/platform_device_linux.cc" ]
548     set_sources_assignment_filter(sources_assignment_filter)
549     deps += [
550       "//third_party/expat",
551       "//third_party/freetype",
552       "//third_party/android_tools:cpu_features",
553     ]
554   }
556   if (skia_support_pdf) {
557     deps += [ "//third_party/sfntly" ]
558     sources += gypi_skia_pdf.sources
559   }
561   if (is_android && !is_debug) {
562     configs -= [ "//build/config/compiler:optimize" ]
563     configs += [ "//build/config/compiler:optimize_max" ]
564   }
567 # Separated out so it can be compiled with different flags for SSE.
568 source_set("skia_opts") {
569   cflags = []
570   defines = []
572   if (cpu_arch == "x86" || cpu_arch == "x64") {
573     sources = [
574       "//third_party/skia/src/opts/SkTextureCompression_opts_none.cpp",
576       # SSE 2
577       "//third_party/skia/src/opts/opts_check_x86.cpp",
578       "//third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp",
579       "//third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp",
580       "//third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp",
581       "//third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp",
582       "//third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp",
583       "//third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp",
584       "//third_party/skia/src/opts/SkUtils_opts_SSE2.cpp",
585       "//third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp",
587       # SSSE 3
588       "//third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp",
590       # SSE 4
591       "//third_party/skia/src/opts/SkBlurImage_opts_SSE4.cpp",
593       # Chrome-specific.
594       "ext/convolver_SSE2.cc",
596       # These are header files used by this target from the skia one above.
597       "ext/convolver.h",
598       "//third_party/skia/include/core/SkTypes.h",
599     ]
601     if (!is_win) {
602       # SSE 4
603       if (cpu_arch == "x86") {
604         sources += [ "//third_party/skia/src/opts/SkBlitRow_opts_SSE4_asm.S" ]
605       } else {  # x64
606         sources +=
607             [ "//third_party/skia/src/opts/SkBlitRow_opts_SSE4_x64_asm.S" ]
608       }
609     }
611     if (is_linux || is_mac) {
612       cflags += [ "-msse4.1" ]
613     }
614   } else if (cpu_arch == "arm") {
615     sources = [
616       "//third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp",
617     ]
619     # The assembly uses the frame pointer register (r7 in Thumb/r11 in
620     # ARM), the compiler doesn't like that.
621     cflags += [ "-fomit-frame-pointer" ]
623     if (arm_version >= 7) {
624       if (arm_use_neon || arm_optionally_use_neon) {
625         sources += [
626           "//third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp",
627           "//third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
628           "//third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h",
629           "//third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h",
630           "//third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp",
631           "//third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp",
632           "//third_party/skia/src/opts/SkBlurImage_opts_neon.cpp",
633           "//third_party/skia/src/opts/SkMorphology_opts_neon.cpp",
634           "//third_party/skia/src/opts/SkTextureCompression_opts_neon.cpp",
635           "//third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp",
636           "//third_party/skia/src/opts/memset16_neon.S",
637           "//third_party/skia/src/opts/memset32_neon.S",
638         ]
640         # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
641         # when running this.
642         if (!arm_use_neon) {
643           configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
644           cflags += [ "-mfpu=neon" ]
645         }
647         #ldflags = [
648         #  "-march=armv7-a",
649         #  "-Wl,--fix-cortex-a8",
650         #]
651       }
652     }
654     # Non-Neon ARM code.
655     if (arm_version < 7 || !arm_use_neon) {
656       sources += [ "//third_party/skia/src/opts/memset.arm.S" ]
657     }
659     if (arm_version < 6) {
660       sources += [
661         "//third_party/skia/src/opts/SkBlitMask_opts_none.cpp",
662         "//third_party/skia/src/opts/SkBlitRow_opts_none.cpp",
663         "//third_party/skia/src/opts/SkBlurImage_opts_none.cpp",
664         "//third_party/skia/src/opts/SkMorphology_opts_none.cpp",
665         "//third_party/skia/src/opts/SkTextureCompression_opts_none.cpp",
666         "//third_party/skia/src/opts/SkUtils_opts_none.cpp",
667         "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
668       ]
669     } else {
670       # arm version >= 6.
671       sources += [
672         "//third_party/skia/src/opts/SkBlitMask_opts_arm.cpp",
673         "//third_party/skia/src/opts/SkBlitRow_opts_arm.cpp",
674         "//third_party/skia/src/opts/SkBlitRow_opts_arm.h",
675         "//third_party/skia/src/opts/SkBlurImage_opts_arm.cpp",
676         "//third_party/skia/src/opts/SkMorphology_opts_arm.cpp",
677         "//third_party/skia/src/opts/SkTextureCompression_opts_arm.cpp",
678         "//third_party/skia/src/opts/SkUtils_opts_arm.cpp",
679         "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
680       ]
681     }
682   } else if (cpu_arch == "mipsel") {
683     cflags += [ "-fomit-frame-pointer" ]
684     sources = [
685       "//third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp",
686       "//third_party/skia/src/opts/SkBlitMask_opts_none.cpp",
687       "//third_party/skia/src/opts/SkBlitRow_opts_none.cpp",
688       "//third_party/skia/src/opts/SkBlurImage_opts_none.cpp",
689       "//third_party/skia/src/opts/SkMorphology_opts_none.cpp",
690       "//third_party/skia/src/opts/SkTextureCompression_opts_none.cpp",
691       "//third_party/skia/src/opts/SkUtils_opts_none.cpp",
692       "//third_party/skia/src/opts/SkXfermode_opts_none.cpp",
693     ]
694   } else {
695     assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp")
696   }
698   if (is_android && !is_debug) {
699     configs -= [ "//build/config/compiler:optimize" ]
700     configs += [ "//build/config/compiler:optimize_max" ]
701   }
703   configs -= [ "//build/config/compiler:chromium_code" ]
704   configs += [
705     ":skia_config",
706     ":skia_library_config",
707     "//build/config/compiler:no_chromium_code",
708   ]
710   deps = [
711     "//base",
712   ]
714   visibility = [ ":skia" ]
717 test("skia_unittests") {
718   sources = [
719     "ext/analysis_canvas_unittest.cc",
720     "ext/bitmap_platform_device_mac_unittest.cc",
721     "ext/convolver_unittest.cc",
722     "ext/image_operations_unittest.cc",
723     "ext/pixel_ref_utils_unittest.cc",
724     "ext/platform_canvas_unittest.cc",
725     "ext/recursive_gaussian_convolution_unittest.cc",
726     "ext/refptr_unittest.cc",
727     "ext/skia_utils_ios_unittest.mm",
728     "ext/skia_utils_mac_unittest.mm",
729     "ext/vector_canvas_unittest.cc",
730   ]
732   if (!is_win) {
733     sources -= [ "ext/vector_canvas_unittest.cc" ]
734   }
736   if (!is_win && !is_mac) {
737     sources -= [ "ext/platform_canvas_unittest.cc" ]
738   }
740   deps = [
741     ":skia",
742     "//base",
743     "//base/test:run_all_unittests",
744     "//testing/gtest",
745     "//ui/gfx",
746     "//ui/gfx/geometry",
747   ]
750 if (is_android) {
751   # GYP: //skia/skia_tests.gyp:skia_unittests_apk
752   unittest_apk("skia_unittests_apk") {
753     unittests_dep = ":skia_unittests"
754     deps = [
755       ":skia_unittests",
756     ]
757   }