Roll src/third_party/skia 591a2ca:b3fe1b8
[chromium-blink-merge.git] / ui / gfx / BUILD.gn
blobb6468d932b82c282852a281d4cf715123f88d8d2
1 # Copyright 2014 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/ui.gni")
6 import("//testing/test.gni")
8 if (is_android) {
9   import("//build/config/android/config.gni")
10   import("//build/config/android/rules.gni")
13 # Several targets want to include this header file, and some of them are
14 # child dependencies of "gfx". Therefore, we separate it out here so multiple
15 # targets can all have a dependency for header checking purposes without
16 # creating circular dependencies.
17 source_set("gfx_export") {
18   sources = [
19     "gfx_export.h",
20   ]
23 component("gfx") {
24   sources = [
25     "android/device_display_info.cc",
26     "android/device_display_info.h",
27     "android/gfx_jni_registrar.cc",
28     "android/gfx_jni_registrar.h",
29     "android/java_bitmap.cc",
30     "android/java_bitmap.h",
31     "android/shared_device_display_info.cc",
32     "android/shared_device_display_info.h",
33     "android/view_configuration.cc",
34     "android/view_configuration.h",
35     "animation/animation.cc",
36     "animation/animation.h",
37     "animation/animation_container.cc",
38     "animation/animation_container.h",
39     "animation/animation_container_element.h",
40     "animation/animation_container_observer.h",
41     "animation/animation_delegate.h",
42     "animation/linear_animation.cc",
43     "animation/linear_animation.h",
44     "animation/multi_animation.cc",
45     "animation/multi_animation.h",
46     "animation/slide_animation.cc",
47     "animation/slide_animation.h",
48     "animation/throb_animation.cc",
49     "animation/throb_animation.h",
50     "animation/tween.cc",
51     "animation/tween.h",
52     "blit.cc",
53     "blit.h",
54     "break_list.h",
55     "canvas.cc",
56     "canvas.h",
57     "canvas_notimplemented.cc",
58     "canvas_paint_mac.h",
59     "canvas_paint_mac.mm",
60     "canvas_skia.cc",
61     "canvas_skia_paint.h",
62     "codec/jpeg_codec.cc",
63     "codec/jpeg_codec.h",
64     "codec/png_codec.cc",
65     "codec/png_codec.h",
66     "color_analysis.cc",
67     "color_analysis.h",
68     "color_profile.cc",
69     "color_profile.h",
70     "color_profile_mac.mm",
71     "color_profile_win.cc",
72     "color_utils.cc",
73     "color_utils.h",
74     "display.cc",
75     "display.h",
76     "display_change_notifier.cc",
77     "display_change_notifier.h",
78     "display_observer.cc",
79     "display_observer.h",
80     "favicon_size.cc",
81     "favicon_size.h",
82     "font.cc",
83     "font.h",
84     "font_fallback.h",
85     "font_fallback_linux.cc",
86     "font_fallback_mac.mm",
87     "font_fallback_win.cc",
88     "font_fallback_win.h",
89     "font_list.cc",
90     "font_list.h",
91     "font_list_impl.cc",
92     "font_list_impl.h",
93     "font_render_params.cc",
94     "font_render_params.h",
95     "font_render_params_android.cc",
96     "font_render_params_linux.cc",
97     "font_render_params_mac.cc",
98     "font_render_params_win.cc",
99     "gdi_util.cc",
100     "gdi_util.h",
101     "gfx_paths.cc",
102     "gfx_paths.h",
103     "gpu_memory_buffer.cc",
104     "gpu_memory_buffer.h",
105     "hud_font.cc",
106     "hud_font.h",
107     "icon_util.cc",
108     "icon_util.h",
109     "image/canvas_image_source.cc",
110     "image/canvas_image_source.h",
111     "image/image.cc",
112     "image/image.h",
113     "image/image_family.cc",
114     "image/image_family.h",
115     "image/image_ios.mm",
116     "image/image_mac.mm",
117     "image/image_png_rep.cc",
118     "image/image_png_rep.h",
119     "image/image_skia.cc",
120     "image/image_skia.h",
121     "image/image_skia_operations.cc",
122     "image/image_skia_operations.h",
123     "image/image_skia_rep.cc",
124     "image/image_skia_rep.h",
125     "image/image_skia_source.h",
126     "image/image_skia_util_ios.h",
127     "image/image_skia_util_ios.mm",
128     "image/image_skia_util_mac.h",
129     "image/image_skia_util_mac.mm",
130     "image/image_util.cc",
131     "image/image_util.h",
132     "image/image_util_ios.mm",
133     "interpolated_transform.cc",
134     "interpolated_transform.h",
135     "linux_font_delegate.cc",
136     "linux_font_delegate.h",
137     "mac/coordinate_conversion.h",
138     "mac/coordinate_conversion.mm",
139     "mac/nswindow_frame_controls.h",
140     "mac/nswindow_frame_controls.mm",
141     "mac/scoped_ns_disable_screen_updates.h",
142     "native_widget_types.h",
143     "nine_image_painter.cc",
144     "nine_image_painter.h",
145     "paint_throbber.cc",
146     "paint_throbber.h",
147     "path.cc",
148     "path.h",
149     "path_win.cc",
150     "path_win.h",
151     "path_x11.cc",
152     "path_x11.h",
153     "platform_font.h",
154     "platform_font_android.cc",
155     "platform_font_ios.h",
156     "platform_font_ios.mm",
157     "platform_font_linux.cc",
158     "platform_font_linux.h",
159     "platform_font_mac.h",
160     "platform_font_mac.mm",
161     "platform_font_win.cc",
162     "platform_font_win.h",
163     "range/range.cc",
164     "range/range.h",
165     "range/range_f.cc",
166     "range/range_f.h",
167     "range/range_mac.mm",
168     "range/range_win.cc",
169     "scoped_canvas.h",
170     "scoped_cg_context_save_gstate_mac.h",
171     "scoped_ns_graphics_context_save_gstate_mac.h",
172     "scoped_ns_graphics_context_save_gstate_mac.mm",
173     "scoped_ui_graphics_push_context_ios.h",
174     "scoped_ui_graphics_push_context_ios.mm",
175     "screen.cc",
176     "screen.h",
177     "screen_android.cc",
178     "screen_aura.cc",
179     "screen_ios.mm",
180     "screen_mac.mm",
181     "screen_win.cc",
182     "screen_win.h",
183     "scrollbar_size.cc",
184     "scrollbar_size.h",
185     "selection_model.cc",
186     "selection_model.h",
187     "sequential_id_generator.cc",
188     "sequential_id_generator.h",
189     "shadow_value.cc",
190     "shadow_value.h",
191     "skbitmap_operations.cc",
192     "skbitmap_operations.h",
193     "skia_util.cc",
194     "skia_util.h",
195     "switches.cc",
196     "switches.h",
197     "sys_color_change_listener.cc",
198     "sys_color_change_listener.h",
199     "text_constants.h",
200     "text_elider.cc",
201     "text_elider.h",
202     "text_utils.cc",
203     "text_utils.h",
204     "text_utils_android.cc",
205     "text_utils_ios.mm",
206     "transform.cc",
207     "transform.h",
208     "transform_util.cc",
209     "transform_util.h",
210     "ui_gfx_exports.cc",
211     "utf16_indexing.cc",
212     "utf16_indexing.h",
213     "vsync_provider.h",
214     "win/direct_write.cc",
215     "win/direct_write.h",
216     "win/dpi.cc",
217     "win/dpi.h",
218     "win/hwnd_util.cc",
219     "win/hwnd_util.h",
220     "win/scoped_set_map_mode.h",
221     "win/singleton_hwnd.cc",
222     "win/singleton_hwnd.h",
223     "win/singleton_hwnd_observer.cc",
224     "win/singleton_hwnd_observer.h",
225     "win/window_impl.cc",
226     "win/window_impl.h",
227   ]
229   # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
230   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
232   defines = [ "GFX_IMPLEMENTATION" ]
234   deps = [
235     ":gfx_export",
236     "//base",
237     "//base:i18n",
238     "//base:base_static",
239     "//base/third_party/dynamic_annotations",
240     "//skia",
241     "//third_party/harfbuzz-ng",
242     "//third_party/libpng",
243     "//third_party/zlib",
244     "//ui/gfx/geometry",
245   ]
246   public_deps = [
247     "//base",
248     "//skia",
249     "//third_party/icu",
250   ]
252   # Text rendering conditions (complicated so separated out).
253   if (use_aura || is_mac) {
254     # Mac doesn't use RenderTextHarfBuzz by default yet.
255     sources += [
256       "harfbuzz_font_skia.cc",
257       "harfbuzz_font_skia.h",
258       "render_text.cc",
259       "render_text.h",
260       "render_text_harfbuzz.cc",
261       "render_text_harfbuzz.h",
262       "render_text_mac.cc",
263       "render_text_mac.h",
264       "text_utils_skia.cc",
265     ]
266   } else {
267     # We don't support RenderText on these platforms.
268   }
270   if (is_android && use_aura) {
271     sources -= [
272       "platform_font_android.cc",
273       "text_utils_android.cc",
274     ]
275     set_sources_assignment_filter([])
276     sources += [ "platform_font_linux.cc" ]
277     set_sources_assignment_filter(sources_assignment_filter)
278   }
280   # iOS.
281   if (is_ios) {
282     sources -= [
283       "codec/jpeg_codec.cc",
284       "codec/jpeg_codec.h",
285     ]
286   } else {
287     deps += [ "//third_party:jpeg" ]
288   }
290   # Android.
291   if (is_android) {
292     if (use_aura) {
293       sources -= [
294         "canvas_notimplemented.cc",
295         "screen_android.cc",
296       ]
297       sources += [ "font_fallback_android.cc" ]
298     } else {
299       sources -= [
300         "animation/throb_animation.cc",
301         "canvas_skia.cc",
302         "path.cc",
303         "selection_model.cc",
304       ]
305     }
307     if (!is_debug) {
308       configs -= [ "//build/config/compiler:optimize" ]
309       configs += [ "//build/config/compiler:optimize_max" ]
310     }
312     deps += [
313       ":gfx_jni_headers",
314       "//base:base_java",
315     ]
316     libs = [
317       "android",
318       "jnigraphics",
319     ]
320   } else {
321     sources -= [ "canvas_notimplemented.cc" ]
322   }
324   # Windows.
325   if (is_win) {
326     cflags = [ "/wd4324" ]  # Structure was padded due to __declspec(align()), which is
327                             # uninteresting.
328   } else {
329     sources -= [
330       "gdi_util.cc",
331       "gdi_util.h",
332       "icon_util.cc",
333       "icon_util.h",
334     ]
335   }
337   # Linux.
338   if (is_linux) {
339     configs += [ "//build/config/linux:fontconfig" ]
340   }
342   # Chrome OS
343   if (is_chromeos) {
344     # Robust JPEG decoding for the login screen.
345     sources += [
346       "chromeos/codec/jpeg_codec_robust_slow.cc",
347       "chromeos/codec/jpeg_codec_robust_slow.h",
348     ]
349     deps += [ "//third_party/libjpeg" ]
350   }
352   if (!use_aura) {
353     sources -= [ "screen_aura.cc" ]
354     if (!toolkit_views) {
355       sources -= [
356         "nine_image_painter.cc",
357         "nine_image_painter.h",
358       ]
359     }
360   }
362   if (use_x11) {
363     deps += [ "//ui/gfx/x" ]
364     configs += [ "//build/config/linux:x11" ]
365   } else {
366     sources -= [ "path_x11.cc" ]
367   }
369   if (use_cairo) {
370     configs += [ "//build/config/linux:pangocairo" ]
371   }
374 # Looking for gfx_geometry? It's //ui/gfx/geometry:geometry
376 source_set("test_support") {
377   testonly = true
378   sources = [
379     "image/image_unittest_util.cc",
380     "image/image_unittest_util.h",
381     "image/image_unittest_util_ios.mm",
382     "image/image_unittest_util_mac.mm",
383     "test/fontconfig_util_linux.cc",
384     "test/fontconfig_util_linux.h",
385     "test/gfx_util.cc",
386     "test/gfx_util.h",
387     "test/ui_cocoa_test_helper.h",
388     "test/ui_cocoa_test_helper.mm",
389   ]
391   public_deps = [
392     ":gfx",
393   ]
395   deps = [
396     "//base",
397     "//base/test:test_support",
398     "//skia",
399     "//testing/gtest",
400     "//ui/gfx/geometry",
401   ]
403   if (is_ios) {
404     # The cocoa files don't apply to iOS.
405     sources -= [
406       "test/ui_cocoa_test_helper.h",
407       "test/ui_cocoa_test_helper.mm",
408     ]
409   }
410   if (is_linux) {
411     configs += [ "//build/config/linux:fontconfig" ]
412   }
415 test("gfx_unittests") {
416   sources = [
417     "font_render_params_linux_unittest.cc",
418     "font_unittest.cc",
419     "image/image_family_unittest.cc",
420     "image/image_ios_unittest.mm",
421     "image/image_skia_unittest.cc",
422     "image/image_unittest.cc",
423     "platform_font_linux_unittest.cc",
424     "screen_unittest.cc",
425     "test/run_all_unittests.cc",
426     "text_elider_unittest.cc",
427     "text_utils_unittest.cc",
428   ]
430   if (!is_ios) {
431     sources += [
432       "animation/animation_container_unittest.cc",
433       "animation/animation_unittest.cc",
434       "animation/multi_animation_unittest.cc",
435       "animation/slide_animation_unittest.cc",
436       "animation/tween_unittest.cc",
437       "blit_unittest.cc",
438       "break_list_unittest.cc",
439       "canvas_unittest.cc",
440       "canvas_unittest_mac.mm",
441       "codec/jpeg_codec_unittest.cc",
442       "codec/png_codec_unittest.cc",
443       "color_analysis_unittest.cc",
444       "color_utils_unittest.cc",
445       "display_change_notifier_unittest.cc",
446       "display_unittest.cc",
447       "font_fallback_mac_unittest.cc",
448       "font_list_unittest.cc",
449       "geometry/box_unittest.cc",
450       "geometry/cubic_bezier_unittest.cc",
451       "geometry/insets_unittest.cc",
452       "geometry/matrix3_unittest.cc",
453       "geometry/point3_unittest.cc",
454       "geometry/point_unittest.cc",
455       "geometry/quad_unittest.cc",
456       "geometry/rect_unittest.cc",
457       "geometry/safe_integer_conversions_unittest.cc",
458       "geometry/scroll_offset_unittest.cc",
459       "geometry/size_unittest.cc",
460       "geometry/vector2d_unittest.cc",
461       "geometry/vector3d_unittest.cc",
462       "image/image_mac_unittest.mm",
463       "image/image_util_unittest.cc",
464       "mac/coordinate_conversion_unittest.mm",
465       "nine_image_painter_unittest.cc",
466       "platform_font_mac_unittest.mm",
467       "range/range_mac_unittest.mm",
468       "range/range_unittest.cc",
469       "range/range_win_unittest.cc",
470       "render_text_unittest.cc",
471       "sequential_id_generator_unittest.cc",
472       "shadow_value_unittest.cc",
473       "skbitmap_operations_unittest.cc",
474       "skrect_conversion_unittest.cc",
475       "transform_util_unittest.cc",
476       "utf16_indexing_unittest.cc",
477     ]
478   }
480   # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
481   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
483   deps = [
484     ":gfx",
485     ":test_support",
486     "//base",
487     "//base/test:test_support",
488     "//skia",
489     "//third_party/icu:icuuc",
490     "//third_party/libpng",
491     "//third_party/zlib",
492     "//testing/gtest",
493     "//ui/base",
494     "//ui/gfx/geometry",
495     "//ui/resources:ui_test_pak",
496   ]
498   if (!is_mac && !is_ios) {
499     sources += [
500       "interpolated_transform_unittest.cc",
501       "transform_unittest.cc",
502     ]
503   }
505   if (is_android) {
506     sources -= [
507       # Do not run display_change_notifier_unittest.cc on Android because it
508       # does not compile display_observer.cc
509       "display_change_notifier_unittest.cc",
510     ]
511   }
513   if (is_android || is_ios) {
514     sources -= [ "render_text_unittest.cc" ]
515   }
517   if (use_aura) {
518     sources -= [ "screen_unittest.cc" ]
519   } else {
520     sources -= [ "nine_image_painter_unittest.cc" ]
521   }
523   if (is_chromeos) {
524     sources += [ "chromeos/codec/jpeg_codec_robust_slow_unittest.cc" ]
525   }
527   if (is_win) {
528     sources += [
529       "font_fallback_win_unittest.cc",
530       "icon_util_unittest.cc",
531       "icon_util_unittests.rc",
532       "path_win_unittest.cc",
533       "platform_font_win_unittest.cc",
534     ]
536     ldflags = [
537       "/DELAYLOAD:d2d1.dll",
538       "/DELAYLOAD:d3d10_1.dll",
539     ]
541     libs = [
542       "d2d1.lib",
543       "d3d10_1.lib",
544       "imm32.lib",
545       "oleacc.lib",
546     ]
547   }
550 if (is_android) {
551   generate_jni("gfx_jni_headers") {
552     sources = [
553       "../android/java/src/org/chromium/ui/gfx/BitmapHelper.java",
554       "../android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java",
555       "../android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java",
556     ]
557     jni_package = "gfx"
558   }