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