Consolidate content fling implementations
[chromium-blink-merge.git] / ui / gfx / BUILD.gn
blob350b82c6c84fc7da63a39a0d531c2d1e20abaeca
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")
7 if (is_android) {
8   import("//build/config/android/config.gni")
9   import("//build/config/android/rules.gni")
12 # Several targets want to include this header file, and some of them are
13 # child dependencies of "gfx". Therefore, we separate it out here so multiple
14 # targets can all have a dependency for header checking purposes without
15 # creating circular dependencies.
16 source_set("gfx_export") {
17   sources = [
18     "gfx_export.h",
19   ]
22 component("gfx") {
23   sources = [
24     "android/device_display_info.cc",
25     "android/device_display_info.h",
26     "android/gfx_jni_registrar.cc",
27     "android/gfx_jni_registrar.h",
28     "android/java_bitmap.cc",
29     "android/java_bitmap.h",
30     "android/shared_device_display_info.cc",
31     "android/shared_device_display_info.h",
32     "android/view_configuration.cc",
33     "android/view_configuration.h",
34     "animation/animation.cc",
35     "animation/animation.h",
36     "animation/animation_container.cc",
37     "animation/animation_container.h",
38     "animation/animation_container_element.h",
39     "animation/animation_container_observer.h",
40     "animation/animation_delegate.h",
41     "animation/linear_animation.cc",
42     "animation/linear_animation.h",
43     "animation/multi_animation.cc",
44     "animation/multi_animation.h",
45     "animation/slide_animation.cc",
46     "animation/slide_animation.h",
47     "animation/throb_animation.cc",
48     "animation/throb_animation.h",
49     "animation/tween.cc",
50     "animation/tween.h",
51     "blit.cc",
52     "blit.h",
53     "break_list.h",
54     "canvas.cc",
55     "canvas.h",
56     "canvas_notimplemented.cc",
57     "canvas_paint_mac.h",
58     "canvas_paint_mac.mm",
59     "canvas_paint_win.cc",
60     "canvas_paint_win.h",
61     "canvas_skia.cc",
62     "canvas_skia_paint.h",
63     "codec/jpeg_codec.cc",
64     "codec/jpeg_codec.h",
65     "codec/png_codec.cc",
66     "codec/png_codec.h",
67     "color_analysis.cc",
68     "color_analysis.h",
69     "color_profile.cc",
70     "color_profile.h",
71     "color_profile_mac.mm",
72     "color_profile_win.cc",
73     "color_utils.cc",
74     "color_utils.h",
75     "display.cc",
76     "display.h",
77     "display_change_notifier.cc",
78     "display_change_notifier.h",
79     "display_observer.cc",
80     "display_observer.h",
81     "favicon_size.cc",
82     "favicon_size.h",
83     "font.cc",
84     "font.h",
85     "font_fallback.h",
86     "font_fallback_linux.cc",
87     "font_fallback_mac.cc",
88     "font_fallback_win.cc",
89     "font_fallback_win.h",
90     "font_list.cc",
91     "font_list.h",
92     "font_list_impl.cc",
93     "font_list_impl.h",
94     "font_render_params.cc",
95     "font_render_params.h",
96     "font_render_params_android.cc",
97     "font_render_params_linux.cc",
98     "font_render_params_mac.cc",
99     "font_render_params_win.cc",
100     "frame_time.h",
101     "gdi_util.cc",
102     "gdi_util.h",
103     "gfx_paths.cc",
104     "gfx_paths.h",
105     "gpu_memory_buffer.cc",
106     "gpu_memory_buffer.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/scoped_ns_disable_screen_updates.h",
140     "native_widget_types.h",
141     "nine_image_painter.cc",
142     "nine_image_painter.h",
143     "path.cc",
144     "path.h",
145     "path_aura.cc",
146     "path_win.cc",
147     "path_win.h",
148     "path_x11.cc",
149     "path_x11.h",
150     "platform_font.h",
151     "platform_font_android.cc",
152     "platform_font_ios.h",
153     "platform_font_ios.mm",
154     "platform_font_mac.h",
155     "platform_font_mac.mm",
156     "platform_font_win.cc",
157     "platform_font_win.h",
158     "range/range.cc",
159     "range/range.h",
160     "range/range_mac.mm",
161     "range/range_win.cc",
162     "scoped_canvas.h",
163     "scoped_cg_context_save_gstate_mac.h",
164     "scoped_ns_graphics_context_save_gstate_mac.h",
165     "scoped_ns_graphics_context_save_gstate_mac.mm",
166     "scoped_ui_graphics_push_context_ios.h",
167     "scoped_ui_graphics_push_context_ios.mm",
168     "screen.cc",
169     "screen.h",
170     "screen_android.cc",
171     "screen_aura.cc",
172     "screen_ios.mm",
173     "screen_mac.mm",
174     "screen_win.cc",
175     "screen_win.h",
176     "scrollbar_size.cc",
177     "scrollbar_size.h",
178     "selection_model.cc",
179     "selection_model.h",
180     "sequential_id_generator.cc",
181     "sequential_id_generator.h",
182     "shadow_value.cc",
183     "shadow_value.h",
184     "skbitmap_operations.cc",
185     "skbitmap_operations.h",
186     "skia_util.cc",
187     "skia_util.h",
188     "switches.cc",
189     "switches.h",
190     "sys_color_change_listener.cc",
191     "sys_color_change_listener.h",
192     "text_constants.h",
193     "text_elider.cc",
194     "text_elider.h",
195     "text_utils.cc",
196     "text_utils.h",
197     "text_utils_android.cc",
198     "text_utils_ios.mm",
199     "transform.cc",
200     "transform.h",
201     "transform_util.cc",
202     "transform_util.h",
203     "ui_gfx_exports.cc",
204     "utf16_indexing.cc",
205     "utf16_indexing.h",
206     "vsync_provider.h",
207     "win/dpi.cc",
208     "win/dpi.h",
209     "win/hwnd_util.cc",
210     "win/hwnd_util.h",
211     "win/scoped_set_map_mode.h",
212     "win/singleton_hwnd.cc",
213     "win/singleton_hwnd.h",
214     "win/window_impl.cc",
215     "win/window_impl.h",
216   ]
218   defines = [ "GFX_IMPLEMENTATION" ]
220   deps = [
221     ":gfx_export",
222     "//base:i18n",
223     "//base:base_static",
224     "//base/third_party/dynamic_annotations",
225     "//skia",
226     "//third_party/harfbuzz-ng",
227     "//third_party/libpng",
228     "//third_party/zlib",
229     "//ui/gfx/geometry",
230   ]
231   public_deps = [
232     "//base",
233     "//skia",
234     "//third_party/icu",
235   ]
237   # Text rendering conditions (complicated so separated out).
238   if (is_android || is_ios) {
239     # We don't support RenderText on these platforms.
240   } else {
241     # These text rendering files are supported everywhere text rendering is.
242     sources += [
243       "render_text.cc",
244       "render_text.h",
245       "render_text_harfbuzz.cc",
246       "render_text_harfbuzz.h",
247       "text_utils_skia.cc",
248     ]
249     # These are the "native" rendering routines, only one should apply.
250     if (is_win) {
251       sources += [ "render_text_win.cc" ]
252     } else if (is_mac) {
253       sources += [ "render_text_mac.cc" ]
254     } else if (use_pango) {
255       sources += [ "render_text_pango.cc" ]
256     } else if (use_ozone) {
257       sources += [ "render_text_ozone.cc" ]
258     }
259   }
261   # iOS.
262   if (is_ios) {
263     sources -= [
264       "codec/jpeg_codec.cc",
265       "codec/jpeg_codec.h",
266     ]
267   } else {
268     deps += [ "//third_party:jpeg" ]
269   }
271   # Android.
272   if (is_android) {
273     sources -= [
274       "animation/throb_animation.cc",
275       "canvas_skia.cc",
276       "display_observer.cc",
277       "selection_model.cc",
278     ]
280     if (use_aura) {
281       sources -= [ "screen_android.cc" ]
282     } else {
283       sources -= [ "path.cc" ]
284     }
286     # TODO(GYP) re-enable when base_java exists.
287     #if (!is_android_webview_build) {
288     #  deps += [ "//base:base_java" ]
289     #}
291     # TODO(jdduke): Revisit optimization after gauging benefit, crbug/419051.
292     if (!is_debug) {
293       configs -= [ "//build/config/compiler:optimize" ]
294       configs += [ "//build/config/compiler:optimize_max" ]
295     }
297     deps += [ ":gfx_jni_headers" ]
298     libs = [
299       "android",
300       "jnigraphics",
301     ]
302   } else {
303     sources -= [ "canvas_notimplemented.cc" ]
304   }
306   # Windows.
307   if (is_win) {
308     cflags = [
309       "/wd4267",  # TODO(jschuh): C4267: http://crbug.com/167187 size_t -> int.
310       "/wd4324",  # Structure was padded due to __declspec(align()), which is
311                   # uninteresting.
312     ]
313   } else {
314     sources -= [
315       "gdi_util.cc",
316       "gdi_util.h",
317       "icon_util.cc",
318       "icon_util.h",
319     ]
320   }
322   # Linux.
323   if (is_linux) {
324     configs += [ "//build/config/linux:fontconfig" ]
325   }
327   # Ozone stuff.
328   if (use_ozone) {
329     sources += [
330       "platform_font_ozone.cc",
331     ]
332   }
334   if (!use_aura) {
335     sources -= [
336       "nine_image_painter.cc",
337       "nine_image_painter.h",
338       "path_aura.cc",
339       "screen_aura.cc",
340     ]
341   }
343   if (use_x11) {
344     deps += [
345       "//ui/gfx/x",
346     ]
347   } else {
348     sources -= [
349       "path_x11.cc",
350     ]
351   }
353   if (use_pango) {
354     sources += [
355       "pango_util.cc",
356       "pango_util.h",
357       "platform_font_pango.cc",
358       "platform_font_pango.h",
359     ]
360     configs += [ "//build/config/linux:pangocairo" ]
361   }
362   if (use_pango && use_ozone) {
363     sources -= [
364       "platform_font_ozone.cc",
365     ]
366   }
369 # Looking for gfx_geometry? It's //ui/gfx/geometry:geometry
371 source_set("test_support") {
372   testonly = true
373   sources = [
374     "image/image_unittest_util.cc",
375     "image/image_unittest_util.h",
376     "image/image_unittest_util_ios.mm",
377     "image/image_unittest_util_mac.mm",
378     "test/fontconfig_util_linux.cc",
379     "test/fontconfig_util_linux.h",
380     "test/gfx_util.cc",
381     "test/gfx_util.h",
382     "test/ui_cocoa_test_helper.h",
383     "test/ui_cocoa_test_helper.mm",
384   ]
386   public_deps = [
387     ":gfx",
388   ]
390   deps = [
391     "//base",
392     "//base/test:test_support",
393     "//skia",
394     "//testing/gtest",
395     "//ui/gfx/geometry",
396   ]
398   if (is_ios) {
399     # The cocoa files don't apply to iOS.
400     sources -= [
401       "test/ui_cocoa_test_helper.h",
402       "test/ui_cocoa_test_helper.mm",
403     ]
404   }
405   if (is_linux) {
406     configs += [ "//build/config/linux:fontconfig" ]
407   }
410 test("gfx_unittests") {
411   sources = [
412     "font_unittest.cc",
413     "image/image_skia_unittest.cc",
414     "image/image_unittest.cc",
415     "screen_unittest.cc",
416     "test/run_all_unittests.cc",
417     "text_elider_unittest.cc",
418     "text_utils_unittest.cc",
419   ]
421   if (!is_ios) {
422     sources += [
423       "animation/animation_container_unittest.cc",
424       "animation/animation_unittest.cc",
425       "animation/multi_animation_unittest.cc",
426       "animation/slide_animation_unittest.cc",
427       "animation/tween_unittest.cc",
428       "blit_unittest.cc",
429       "break_list_unittest.cc",
430       "canvas_unittest.cc",
431       "canvas_unittest_mac.mm",
432       "codec/jpeg_codec_unittest.cc",
433       "codec/png_codec_unittest.cc",
434       "color_analysis_unittest.cc",
435       "color_utils_unittest.cc",
436       "display_change_notifier_unittest.cc",
437       "display_unittest.cc",
438       "font_list_unittest.cc",
439       "geometry/box_unittest.cc",
440       "geometry/cubic_bezier_unittest.cc",
441       "geometry/insets_unittest.cc",
442       "geometry/matrix3_unittest.cc",
443       "geometry/point_unittest.cc",
444       "geometry/point3_unittest.cc",
445       "geometry/quad_unittest.cc",
446       "geometry/r_tree_unittest.cc",
447       "geometry/rect_unittest.cc",
448       "geometry/safe_integer_conversions_unittest.cc",
449       "geometry/scroll_offset_unittest.cc",
450       "geometry/size_unittest.cc",
451       "geometry/vector2d_unittest.cc",
452       "geometry/vector3d_unittest.cc",
453       "mac/coordinate_conversion_unittest.mm",
454       "platform_font_mac_unittest.mm",
455       "range/range_mac_unittest.mm",
456       "range/range_unittest.cc",
457       "range/range_win_unittest.cc",
458       "render_text_unittest.cc",
459       "sequential_id_generator_unittest.cc",
460       "shadow_value_unittest.cc",
461       "skbitmap_operations_unittest.cc",
462       "skrect_conversion_unittest.cc",
463       "transform_util_unittest.cc",
464       "utf16_indexing_unittest.cc",
465     ]
466   }
468   deps = [
469     ":gfx",
470     ":test_support",
471     "//base",
472     "//base/test:test_support",
473     "//skia",
474     "//third_party/icu:icuuc",
475     "//third_party/libpng",
476     "//third_party/zlib",
477     "//testing/gtest",
478     "//ui/base",
479     "//ui/gfx/geometry",
480     "//ui/resources:ui_test_pak",
481   ]
483   if (use_pango) {
484     sources += [
485       "font_render_params_linux_unittest.cc",
486       "platform_font_pango_unittest.cc",
487     ]
488     configs += [
489       "//build/config/linux:pangocairo",
490       "//build/config/linux:pangoft2",
491     ]
492   }
494   if (!is_mac && !is_ios) {
495     sources += [
496       "transform_unittest.cc",
497       "interpolated_transform_unittest.cc",
498     ]
499   }
501   if (use_ozone && !use_pango) {
502     sources -= [
503       "canvas_unittest.cc",
504       "font_list_unittest.cc",
505       "font_unittest.cc",
506       "render_text_unittest.cc",
507       "text_elider_unittest.cc",
508     ]
509   }
511   if (is_android) {
512     sources -= [
513       # Do not run display_change_notifier_unittest.cc on Android because it
514       # does not compile display_observer.cc
515       "display_change_notifier_unittest.cc",
516     ]
518     deps += [
519       #'../../testing/android/native_test.gyp:native_test_native_code', TODO(GYP)
520     ]
521   }
523   if (is_android || is_ios) {
524     sources -= [
525       "render_text_unittest.cc",
526     ]
527   }
529   if (use_aura) {
530     sources -= [
531       "screen_unittest.cc",
532     ]
533   }
535   if (is_win) {
536     sources += [
537       "color_profile_win_unittest.cc",
538       "font_fallback_win_unittest.cc",
539       "icon_util_unittest.cc",
540       "icon_util_unittests.rc",
541       "platform_font_win_unittest.cc",
542     ]
544     ldflags = [
545       "/DELAYLOAD:d2d1.dll",
546       "/DELAYLOAD:d3d10_1.dll",
547     ]
549     libs = [
550       "d2d1.lib",
551       "d3d10_1.lib",
552       "imm32.lib",
553       "oleacc.lib",
554     ]
556     # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
557     cflags = [ "/wd4267" ]
558   }
561 if (is_android) {
562   generate_jni("gfx_jni_headers") {
563     sources = [
564       "../android/java/src/org/chromium/ui/gfx/BitmapHelper.java",
565       "../android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java",
566       "../android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java",
567     ]
568     jni_package = "gfx"
569   }