chromium/ui/gfx/BUILD.gn

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//gpu/vulkan/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")

if (is_ios) {
  import("//build/config/ios/bundle_data_from_filelist.gni")
}

if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

# Several targets want to include this header file, and some of them are
# child dependencies of "gfx". Therefore, we separate it out here so multiple
# targets can all have a dependency for header checking purposes without
# creating circular dependencies.
source_set("gfx_export") {
  sources = [ "gfx_export.h" ]
}

# Used for color generation at build time without importing all the gfx.
component("color_utils") {
  sources = [
    "color_palette.h",
    "color_utils.cc",
    "color_utils.h",
  ]
  defines = [ "GFX_IMPLEMENTATION" ]
  public_deps = [
    ":gfx_export",
    "//base",
    "//skia",
    "//ui/gfx/geometry",
  ]
}

component("gfx_skia") {
  sources = [
    "gfx_skia_export.h",
    "skia_util.cc",
    "skia_util.h",
  ]
  configs += [ "//build/config/compiler:wexit_time_destructors" ]
  public_deps = [
    "//base",
    "//skia",
  ]
  defines = [ "GFX_SKIA_IMPLEMENTATION" ]
}

if (is_win) {
  config("gfx_win_linker_flags") {
    # This is in a separate config so the flags can be applied to dependents.
    # ldflags in GN aren't automatically inherited.
    ldflags = [
      # Linking with OneCore.lib causes the following dlls to load.
      "/DELAYLOAD:api-ms-win-core-handle-l1-1-0.dll",
    ]
  }
}

component("gfx") {
  sources = [
    "break_list.h",
    "color_analysis.cc",
    "color_analysis.h",
    "color_conversions.cc",
    "color_conversions.h",
    "decorated_text.cc",
    "decorated_text.h",
    "delegated_ink_metadata.cc",
    "delegated_ink_metadata.h",
    "delegated_ink_point.cc",
    "delegated_ink_point.h",
    "extension_set.cc",
    "extension_set.h",
    "favicon_size.cc",
    "favicon_size.h",
    "font.cc",
    "font.h",
    "font_fallback.h",
    "font_list.cc",
    "font_list.h",
    "font_list_impl.cc",
    "font_list_impl.h",
    "font_render_params.cc",
    "font_render_params.h",
    "font_util.cc",
    "font_util.h",
    "frame_data.h",
    "gdi_util.cc",
    "gdi_util.h",
    "gpu_extra_info.cc",
    "gpu_extra_info.h",
    "half_float.cc",
    "half_float.h",
    "icon_util.cc",
    "icon_util.h",
    "image/buffer_w_stream.cc",
    "image/buffer_w_stream.h",
    "image/image.cc",
    "image/image.h",
    "image/image_family.cc",
    "image/image_family.h",
    "image/image_internal.h",
    "image/image_platform.h",
    "image/image_png_rep.cc",
    "image/image_png_rep.h",
    "image/image_skia.cc",
    "image/image_skia.h",
    "image/image_skia_rep.h",
    "image/image_skia_source.cc",
    "image/image_skia_source.h",
    "image/image_util.cc",
    "image/image_util.h",
    "interpolated_transform.cc",
    "interpolated_transform.h",
    "overlay_plane_data.cc",
    "overlay_plane_data.h",
    "overlay_transform_utils.cc",
    "overlay_transform_utils.h",
    "platform_font.cc",
    "platform_font.h",
    "scrollbar_size.cc",
    "scrollbar_size.h",
    "selection_model.cc",
    "selection_model.h",
    "sequential_id_generator.cc",
    "sequential_id_generator.h",
    "shadow_value.cc",
    "shadow_value.h",
    "skbitmap_operations.cc",
    "skbitmap_operations.h",
    "swap_result.cc",
    "sys_color_change_listener.cc",
    "sys_color_change_listener.h",
    "text_constants.h",
    "text_elider.cc",
    "text_elider.h",
    "text_utils.cc",
    "text_utils.h",
    "ubidi_deleter.h",
    "ui_gfx_exports.cc",
    "utf16_indexing.cc",
    "utf16_indexing.h",
    "vector_icon_types.h",
    "vector_icon_utils.cc",
    "vector_icon_utils.h",
    "video_types.h",
    "vsync_provider.cc",
    "vsync_provider.h",
  ]
  if (is_android) {
    sources += [
      "android/achoreographer_compat.cc",
      "android/achoreographer_compat.h",
      "android/android_surface_control_compat.cc",
      "android/android_surface_control_compat.h",
      "android/java_bitmap.cc",
      "android/java_bitmap.h",
      "android/view_configuration.cc",
      "android/view_configuration.h",
    ]
  }
  if (is_linux || is_chromeos) {
    sources += [
      "font_fallback_linux.cc",
      "font_fallback_linux.h",
      "font_render_params_linux.cc",
      "font_render_params_linux.h",
      "linux/fontconfig_util.cc",
      "linux/fontconfig_util.h",
    ]
  }
  if (is_mac) {
    sources += [
      "ca_layer_result.h",
      "decorated_text_mac.h",
      "decorated_text_mac.mm",
      "font_fallback_mac.mm",
      "image/image_mac.mm",
      "image/image_skia_util_mac.h",
      "image/image_skia_util_mac.mm",
      "image/image_util_mac.mm",
      "mac/coordinate_conversion.h",
      "mac/coordinate_conversion.mm",
      "mac/nswindow_frame_controls.h",
      "mac/nswindow_frame_controls.mm",
      "mac/scoped_cocoa_disable_screen_updates.h",
      "mac/scoped_cocoa_disable_screen_updates.mm",
      "platform_font_mac.h",
      "platform_font_mac.mm",
      "scoped_cg_context_save_gstate_mac.h",
      "scoped_ns_graphics_context_save_gstate_mac.h",
      "scoped_ns_graphics_context_save_gstate_mac.mm",
    ]
  }
  if (is_win) {
    sources += [
      "font_fallback_win.cc",
      "font_fallback_win.h",
      "font_render_params_win.cc",
      "font_util_win.cc",
      "font_util_win.h",
      "path_win.cc",
      "path_win.h",
      "system_fonts_win.cc",
      "system_fonts_win.h",
      "win/crash_id_helper.cc",
      "win/crash_id_helper.h",
      "win/d3d_shared_fence.cc",
      "win/d3d_shared_fence.h",
      "win/direct_write.cc",
      "win/direct_write.h",
      "win/hwnd_util.cc",
      "win/hwnd_util.h",
      "win/msg_util.h",
      "win/physical_size.cc",
      "win/physical_size.h",
      "win/rendering_window_manager.cc",
      "win/rendering_window_manager.h",
      "win/scoped_set_map_mode.h",
      "win/singleton_hwnd.cc",
      "win/singleton_hwnd.h",
      "win/singleton_hwnd_hot_key_observer.cc",
      "win/singleton_hwnd_hot_key_observer.h",
      "win/singleton_hwnd_observer.cc",
      "win/singleton_hwnd_observer.h",
      "win/text_analysis_source.cc",
      "win/text_analysis_source.h",
      "win/window_impl.cc",
      "win/window_impl.h",
    ]
  }
  if (is_apple) {
    sources += [ "font_render_params_mac.cc" ]
  }
  if (is_ios) {
    sources += [
      "image/image_ios.mm",
      "image/image_skia_util_ios.h",
      "image/image_skia_util_ios.mm",
      "image/image_util_ios.mm",
      "ios/NSString+CrStringDrawing.h",
      "ios/NSString+CrStringDrawing.mm",
      "platform_font_ios.h",
      "platform_font_ios.mm",
      "scoped_ui_graphics_push_context_ios.h",
      "scoped_ui_graphics_push_context_ios.mm",
      "text_utils_ios.mm",
    ]
    if (!use_blink) {
      sources += [
        "image/image_skia_rep_ios.cc",
        "image/image_skia_rep_ios.h",
      ]
    }
  }
  if (use_blink) {
    sources += [
      "blit.cc",
      "blit.h",
      "canvas.cc",
      "canvas.h",
      "canvas_skia.cc",
      "image/canvas_image_source.cc",
      "image/canvas_image_source.h",
      "image/image_generic.cc",
      "image/image_skia_operations.cc",
      "image/image_skia_operations.h",
      "image/image_skia_rep_default.cc",
      "image/image_skia_rep_default.h",
      "paint_throbber.cc",
      "paint_throbber.h",
      "scoped_canvas.cc",
      "scoped_canvas.h",
      "shadow_util.cc",
      "shadow_util.h",
      "skia_paint_util.cc",
      "skia_paint_util.h",
    ]
  }

  configs += [
    "//build/config:precompiled_headers",
    "//build/config/compiler:wexit_time_destructors",
  ]

  # This is part of the gfx component in the component build.
  defines = [ "GFX_IMPLEMENTATION" ]

  public_deps = [
    ":color_space",
    ":color_utils",
    ":gfx_skia",
    ":gfx_switches",
    ":memory_buffer_sources",
    ":native_widget_types_sources",
    ":resize_image_dimensions",
    ":selection_bound_sources",
    "//base",
    "//skia",
    "//skia:skcms",
    "//third_party/icu",
    "//ui/gfx/animation",
    "//ui/gfx/codec",
    "//ui/gfx/geometry",
    "//ui/gfx/geometry:geometry_skia",
    "//ui/gfx/range",
  ]
  deps = [
    ":gfx_export",
    "//base",
    "//base:base_static",
    "//base:i18n",
    "//build:blink_buildflags",
    "//build:chromeos_buildflags",
    "//device/vr/buildflags",
    "//mojo/public/cpp/bindings:struct_traits",
    "//skia",
    "//third_party/zlib",
    "//ui/base:ozone_buildflags",
    "//ui/base:ui_data_pack",
  ]

  if (!is_apple) {
    sources += [
      "platform_font_skia.cc",
      "platform_font_skia.h",
    ]
  }

  # iOS.
  if (is_ios) {
    sources += [ "scoped_cg_context_save_gstate_mac.h" ]
    public_deps += [ "//ui/gfx/ios:uikit_util" ]
  }

  if (use_blink) {
    public_deps += [ "//cc/paint" ]
    deps += [ "//third_party:freetype_harfbuzz" ]
  }

  # Android.
  if (is_android) {
    if (!is_debug) {
      configs -= [ "//build/config/compiler:default_optimization" ]
      configs += [ "//build/config/compiler:optimize_max" ]
    }

    deps += [ ":gfx_jni_headers" ]
    libs = [
      "android",
      "jnigraphics",
    ]
  }

  if (use_blink) {
    if (is_android || is_fuchsia || is_ios) {
      sources += [
        "font_fallback_skia.cc",
        "font_render_params_skia.cc",
      ]
    }

    if (is_android || is_fuchsia || is_win || is_apple) {
      sources += [
        "font_fallback_skia_impl.cc",
        "font_fallback_skia_impl.h",
      ]
    }

    sources += [
      "bidi_line_iterator.cc",
      "bidi_line_iterator.h",
      "harfbuzz_font_skia.cc",
      "harfbuzz_font_skia.h",
      "paint_vector_icon.cc",
      "paint_vector_icon.h",
      "render_text.cc",
      "render_text.h",
      "render_text_harfbuzz.cc",
      "render_text_harfbuzz.h",
      "text_utils_skia.cc",
    ]
  }

  # Windows.
  if (is_win) {
    deps += [ "//ui/base:features" ]
    libs = [
      "setupapi.lib",
      "dwmapi.lib",
      "dwrite.lib",
      "onecore.lib",
    ]

    all_dependent_configs = [ ":gfx_win_linker_flags" ]
    public_deps += [ "//components/crash/core/common" ]
  } else {
    sources -= [
      "gdi_util.cc",
      "gdi_util.h",
      "icon_util.cc",
      "icon_util.h",
      "sys_color_change_listener.cc",
      "sys_color_change_listener.h",
    ]
  }

  # Linux.
  if (is_linux) {
    deps += [ "//ui/linux:linux_ui" ]
  }
  if (is_linux || is_chromeos) {
    deps += [ "//third_party/fontconfig" ]
  }

  if (is_apple) {
    frameworks = [ "IOSurface.framework" ]
    deps += [ "//ui/base:features" ]
  }
  if (is_mac) {
    frameworks += [
      "AppKit.framework",
      "CoreFoundation.framework",
      "CoreGraphics.framework",
      "CoreText.framework",
    ]
  }

  if (use_aura || toolkit_views) {
    sources += [
      "nine_image_painter.cc",
      "nine_image_painter.h",
    ]
  }
}

component("color_space") {
  sources = [
    "color_conversion_sk_filter_cache.cc",
    "color_conversion_sk_filter_cache.h",
    "color_space.cc",
    "color_space.h",
    "color_space_export.h",
    "color_transform.cc",
    "color_transform.h",
    "display_color_spaces.cc",
    "display_color_spaces.h",
    "hdr_metadata.cc",
    "hdr_metadata.h",
    "hdr_static_metadata.cc",
    "hdr_static_metadata.h",
    "icc_profile.cc",
    "icc_profile.h",
    "skia_color_space_util.cc",
    "skia_color_space_util.h",
  ]
  if (is_win) {
    sources += [
      "color_space_win.cc",
      "color_space_win.h",
    ]
  }
  deps = [
    "//build:chromeos_buildflags",
    "//skia:skcms",
    "//ui/gfx:buffer_types",
    "//ui/gfx/geometry:geometry_skia",
  ]
  public_deps = [
    "//base",
    "//skia",
  ]

  if (is_apple && use_blink) {
    sources += [
      "hdr_metadata_mac.h",
      "hdr_metadata_mac.mm",
      "mac/color_space_util.h",
      "mac/color_space_util.mm",
    ]
    frameworks = [
      "CoreFoundation.framework",
      "CoreGraphics.framework",
      "CoreMedia.framework",
      "CoreVideo.framework",
    ]
    if (is_mac) {
      sources += [
        "mac/display_icc_profiles.cc",
        "mac/display_icc_profiles.h",
      ]
    }
  }
  defines = [ "COLOR_SPACE_IMPLEMENTATION" ]
}

# Depend on this to use image/resize_image_dimensions.h without pulling in
# all of gfx.
source_set("resize_image_dimensions") {
  sources = [ "image/resize_image_dimensions.h" ]
}

# Depend on this to use native_widget_types.h without pulling in all of gfx.
# The structure here allows native_widget_types to be part of the gfx component
# in the component build, but be a separate source set in a static build.
group("native_widget_types") {
  if (is_component_build) {
    public_deps = [ ":gfx" ]
  } else {
    public_deps = [ ":native_widget_types_sources" ]
  }
}

source_set("native_widget_types_sources") {
  visibility = [ ":*" ]  # Depend on through ":native_widget_types".

  public = [ "native_widget_types.h" ]

  public_deps = [
    ":gfx_export",
    "//base",
  ]

  deps = [ "//build:chromeos_buildflags" ]

  defines = [ "GFX_IMPLEMENTATION" ]

  if (is_mac) {
    sources = [ "native_widget_types_mac.mm" ]
    frameworks = [ "AppKit.framework" ]
  }
}

group("selection_bound") {
  if (is_component_build) {
    public_deps = [ ":gfx" ]
  } else {
    public_deps = [ ":selection_bound_sources" ]
  }
}

# Depend on this to use selection_bound.h without pulling in all of gfx.
# Cannot be a static_library in component builds due to exported functions
source_set("selection_bound_sources") {
  visibility = [ ":*" ]  # Depend on through ":selection_bound".

  sources = [
    "gfx_export.h",
    "selection_bound.cc",
    "selection_bound.h",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  defines = [ "GFX_IMPLEMENTATION" ]

  public_deps = [
    "//base",
    "//ui/gfx/geometry",
  ]
}

# Depend on this to use buffer_types.h without pulling in all of gfx.
source_set("buffer_types") {
  sources = [ "buffer_types.h" ]
}

# The GPU memory buffer stuff is separate from "gfx" to allow GPU-related
# things to use these files without pulling in all of gfx, which includes large
# things like Skia.
#
# The structure here allows the memory buffer to be part of the gfx component
# in the component build, but be a separate source set in a static build.
group("memory_buffer") {
  if (is_component_build) {
    public_deps = [ ":gfx" ]
  } else {
    public_deps = [ ":memory_buffer_sources" ]
  }
}

# Cannot be a static_library in component builds due to exported functions
source_set("memory_buffer_sources") {
  visibility = [ ":*" ]  # Depend on through ":memory_buffer".

  # TODO(brettw) refactor this so these sources are in a coherent directory
  # structure rather than random samplings of ui/gfx and ui/gfx/mac.
  sources = [
    "buffer_format_util.cc",
    "buffer_format_util.h",
    "buffer_usage_util.cc",
    "buffer_usage_util.h",
    "client_native_pixmap.h",
    "client_native_pixmap_factory.h",
    "generic_shared_memory_id.cc",
    "generic_shared_memory_id.h",
    "gfx_export.h",
    "gpu_fence.cc",
    "gpu_fence.h",
    "gpu_fence_handle.cc",
    "gpu_fence_handle.h",
    "overlay_priority_hint.h",
    "overlay_transform.h",
    "overlay_type.h",
    "surface_origin.h",
  ]

  if (!is_nacl) {
    sources += [ "native_pixmap.h" ]
  }

  if (use_blink) {
    sources += [
      "ca_layer_params.cc",
      "ca_layer_params.h",
      "gpu_memory_buffer.cc",
      "gpu_memory_buffer.h",
    ]
  }

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  defines = [ "GFX_IMPLEMENTATION" ]

  public_deps = [ ":buffer_types" ]

  deps = [
    ":gfx_switches",
    "//base",
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
    "//gpu/vulkan:buildflags",
    "//ui/gfx/geometry",
  ]

  if (!is_nacl) {
    deps += [ ":native_widget_types_sources" ]
  }

  if (is_linux || is_chromeos) {
    sources += [
      "linux/client_native_pixmap_dmabuf.cc",
      "linux/client_native_pixmap_dmabuf.h",
      "linux/client_native_pixmap_factory_dmabuf.cc",
      "linux/client_native_pixmap_factory_dmabuf.h",
      "linux/dmabuf_uapi.h",
      "linux/native_pixmap_dmabuf.cc",
      "linux/native_pixmap_dmabuf.h",
    ]

    deps += [ "//build/config/linux/libdrm" ]
  }

  if (is_linux || is_chromeos || is_android) {
    deps += [ "//third_party/libsync" ]
  }

  if (use_blink && is_apple) {
    sources += [
      "mac/io_surface.cc",
      "mac/io_surface.h",
    ]

    public_deps += [ "//ui/gfx:color_space" ]
  }

  if (is_win) {
    public_deps += [ "//ipc:message_support" ]
  }

  if ((is_linux || is_chromeos || use_ozone) && !is_nacl) {
    sources += [
      "native_pixmap_handle.cc",
      "native_pixmap_handle.h",
    ]
  }

  if (enable_vulkan) {
    public_deps += [ "//third_party/vulkan-headers/src:vulkan_headers" ]
  }
}

# TODO(ccameron): This can be moved into a separate source_set.
component("gfx_switches") {
  sources = [
    "switches.cc",
    "switches.h",
    "switches_export.h",
  ]

  defines = [ "GFX_SWITCHES_IMPLEMENTATION" ]

  deps = [ "//base" ]
}

static_library("test_support") {
  testonly = true
  sources = [
    "animation/animation_test_api.cc",
    "animation/animation_test_api.h",
    "animation/keyframe/test/animation_utils.cc",
    "animation/keyframe/test/animation_utils.h",
    "animation/test_animation_delegate.h",
    "geometry/test/geometry_util.cc",
    "geometry/test/geometry_util.h",
    "image/image_unittest_util.cc",
    "image/image_unittest_util.h",
    "test/font_fallback_test_data.cc",
    "test/font_fallback_test_data.h",
    "test/icc_profiles.cc",
    "test/icc_profiles.h",
    "test/scoped_default_font_description.h",
    "test/sk_color_eq.cc",
    "test/sk_color_eq.h",
    "test/sk_gmock_support.h",
  ]
  if (is_apple) {
    sources += [ "image/image_unittest_util_apple.mm" ]
  }
  if (use_fuzzing_engine) {
    sources += [
      "geometry/test/fuzzer_util.cc",
      "geometry/test/fuzzer_util.h",
    ]
  }

  public_deps = [ ":gfx" ]

  deps = [
    ":gfx_export",
    "//base",
    "//base/test:test_support",
    "//skia",
    "//testing/gtest",
    "//ui/base:ui_data_pack",
    "//ui/gfx/animation",
    "//ui/gfx/animation/keyframe",
    "//ui/gfx/geometry",
  ]

  if (use_blink) {
    sources += [ "render_text_test_api.h" ]

    deps += [ "//third_party:freetype_harfbuzz" ]
  }
}

test("gfx_unittests") {
  sources = [
    "animation/keyframe/keyframe_animation_unittest.cc",
    "animation/keyframe/keyframed_animation_curve_unittest.cc",
    "font_names_testing.h",
    "font_unittest.cc",
    "geometry/linear_gradient_unittest.cc",
    "geometry/mask_filter_info_unittest.cc",
    "geometry/rrect_f_unittest.cc",
    "geometry/sin_cos_degrees_unittest.cc",
    "geometry/transform_operations_unittest.cc",
    "geometry/transform_unittest.cc",
    "image/buffer_w_stream_unittest.cc",
    "image/image_family_unittest.cc",
    "image/image_skia_unittest.cc",
    "image/image_unittest.cc",
    "interpolated_transform_unittest.cc",
    "test/run_all_unittests.cc",
    "text_elider_unittest.cc",
    "text_utils_unittest.cc",
  ]
  if (is_linux) {
    sources += [ "font_render_params_linux_unittest.cc" ]
  }
  if (is_linux || is_chromeos) {
    sources += [ "font_fallback_linux_unittest.cc" ]
  }
  if (is_apple) {
    frameworks = [ "IOSurface.framework" ]
  }
  if (is_mac) {
    sources += [
      "font_fallback_mac_unittest.cc",
      "image/image_mac_unittest.mm",
      "mac/coordinate_conversion_unittest.mm",
      "mac/io_surface_unittest.cc",
      "platform_font_mac_unittest.mm",
      "range/range_mac_unittest.mm",
    ]
  }
  if (is_win) {
    sources += [ "font_fallback_win_unittest.cc" ]
  }
  if (is_ios) {
    sources += [
      "image/image_ios_unittest.mm",
      "ios/NSString+CrStringDrawing_unittest.mm",
      "ios/uikit_util_unittest.mm",
    ]
  }
  if (is_android) {
    sources += [ "android/android_surface_control_compat_unittest.cc" ]
  }

  include_dirs = [ "//third_party/skia/include/private" ]

  data = [ "test/data/" ]

  if (use_blink) {
    sources += [
      "animation/animation_container_unittest.cc",
      "animation/animation_runner_unittest.cc",
      "animation/animation_unittest.cc",
      "animation/multi_animation_unittest.cc",
      "animation/slide_animation_unittest.cc",
      "animation/tween_unittest.cc",
      "bidi_line_iterator_unittest.cc",
      "blit_unittest.cc",
      "break_list_unittest.cc",
      "canvas_unittest.cc",
      "codec/jpeg_codec_unittest.cc",
      "codec/png_codec_unittest.cc",
      "color_analysis_unittest.cc",
      "color_conversions_unittest.cc",
      "color_space_unittest.cc",
      "color_transform_unittest.cc",
      "color_utils_unittest.cc",
      "delegated_ink_unittest.cc",
      "font_fallback_unittest.cc",
      "font_list_unittest.cc",
      "geometry/axis_transform2d_unittest.cc",
      "geometry/box_unittest.cc",
      "geometry/cubic_bezier_unittest.cc",
      "geometry/insets_f_unittest.cc",
      "geometry/insets_unittest.cc",
      "geometry/matrix3_unittest.cc",
      "geometry/point3_f_unittest.cc",
      "geometry/point_f_unittest.cc",
      "geometry/point_unittest.cc",
      "geometry/quad_f_unittest.cc",
      "geometry/quaternion_unittest.cc",
      "geometry/rect_conversions_unittest.cc",
      "geometry/rect_f_unittest.cc",
      "geometry/rect_unittest.cc",
      "geometry/resize_utils_unittest.cc",
      "geometry/rounded_corners_f_unittest.cc",
      "geometry/size_f_unittest.cc",
      "geometry/size_unittest.cc",
      "geometry/skia_conversions_unittest.cc",
      "geometry/three_point_cubic_bezier_unittest.cc",
      "geometry/transform_util_unittest.cc",
      "geometry/triangle_unittest.cc",
      "geometry/vector2d_f_unittest.cc",
      "geometry/vector2d_unittest.cc",
      "geometry/vector3d_f_unittest.cc",
      "half_float_unittest.cc",
      "icc_profile_unittest.cc",
      "image/image_skia_operations_unittest.cc",
      "image/image_util_unittest.cc",
      "mojom/mojom_traits_unittest.cc",
      "overlay_transform_utils_unittest.cc",
      "paint_vector_icon_unittest.cc",
      "range/range_unittest.cc",
      "render_text_unittest.cc",
      "selection_bound_unittest.cc",
      "selection_model_unittest.cc",
      "sequential_id_generator_unittest.cc",
      "shadow_util_unittest.cc",
      "shadow_value_unittest.cc",
      "skbitmap_operations_unittest.cc",
      "skia_util_unittest.cc",
      "utf16_indexing_unittest.cc",
    ]
  }

  if (is_win) {
    sources += [ "system_fonts_win_unittest.cc" ]
  }

  if (is_linux || is_chromeos || is_android || is_fuchsia || is_win) {
    sources += [ "platform_font_skia_unittest.cc" ]
  }

  deps = [
    ":gfx",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//skia",
    "//skia:skcms",
    "//testing/gtest",
    "//third_party/icu:icuuc",
    "//third_party/libpng",
    "//third_party/zlib",
    "//ui/base",
    "//ui/gfx/animation",
    "//ui/gfx/animation/keyframe",
    "//ui/gfx/geometry",
    "//ui/gfx/range",
  ]

  if (use_blink) {
    deps += [ "//third_party:freetype_harfbuzz" ]
  }

  data_deps = [ "//ui/resources:ui_test_pak_data" ]

  if (is_apple) {
    deps += [ "//ui/resources:ui_test_pak_bundle_data" ]
  }

  if (is_android) {
    deps += [ "//ui/android:ui_java" ]
  }

  if (is_ios) {
    deps += [ "//ui/gfx:codec_tests_bundle_data" ]
  }

  if (is_android || is_fuchsia) {
    sources += [ "font_fallback_skia_unittest.cc" ]
  }

  if (use_aura || toolkit_views) {
    sources += [ "nine_image_painter_unittest.cc" ]
  }

  if (is_win) {
    sources += [
      "font_render_params_win_unittest.cc",
      "font_util_win.cc",
      "icon_util_unittest.cc",
      "icon_util_unittests.rc",
      "icon_util_unittests_resource.h",
      "path_win_unittest.cc",
      "win/crash_id_helper_unittest.cc",
      "win/direct_write_unittest.cc",
      "win/text_analysis_source_unittest.cc",
    ]

    ldflags = [
      "/DELAYLOAD:d2d1.dll",
      "/DELAYLOAD:d3d10_1.dll",
    ]

    libs = [
      "d2d1.lib",
      "d3d10_1.lib",
      "dwrite.lib",
      "imm32.lib",
      "oleacc.lib",
    ]
  }

  if (use_blink) {
    deps += [
      "//cc/paint",
      "//mojo/core/embedder",
      "//mojo/public/cpp/bindings",
      "//mojo/public/cpp/test_support:test_utils",
      "//ui/gfx/geometry/mojom:unit_test",
      "//ui/gfx/image/mojom:unit_test",
      "//ui/gfx/mojom:test_interfaces",
      "//ui/gfx/range/mojom:unit_test",
    ]
  }

  if (is_linux) {
    deps += [ "//ui/linux:test_support" ]
  }

  if (is_linux || is_chromeos) {
    sources += [
      "linux/fontconfig_util_unittest.cc",
      "linux/native_pixmap_dmabuf_unittest.cc",
    ]
    deps += [ "//third_party/fontconfig" ]
  }

  if (is_fuchsia) {
    deps += [ "//skia:test_fonts" ]
    additional_manifest_fragments =
        [ "//build/config/fuchsia/test/test_fonts.shard.test-cml" ]
  }
}

if (is_android) {
  generate_jni("gfx_jni_headers") {
    sources = [
      "../android/java/src/org/chromium/ui/gfx/Animation.java",
      "../android/java/src/org/chromium/ui/gfx/BitmapHelper.java",
      "../android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java",
    ]
  }
}

fuzzer_test("color_analysis_fuzzer") {
  sources = [ "color_analysis_fuzzer.cc" ]

  deps = [ ":gfx" ]
}

fuzzer_test("color_transform_fuzzer") {
  sources = [ "color_transform_fuzzer.cc" ]

  dict = "//testing/libfuzzer/fuzzers/dicts/icc.dict"

  deps = [ ":gfx" ]

  libfuzzer_options = [ "max_len=4194304" ]
}

fuzzer_test("render_text_fuzzer") {
  sources = [ "render_text_fuzzer.cc" ]

  deps = [
    ":gfx",
    "//base",
    "//base/test:test_support",
  ]

  dict = "test/data/render_text/unicode_text_fuzzer.dict"
}

fuzzer_test("render_text_api_fuzzer") {
  sources = [ "render_text_api_fuzzer.cc" ]

  deps = [
    ":gfx",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
  ]

  dict = "test/data/render_text/unicode_text_fuzzer.dict"
}

if (is_ios) {
  bundle_data_from_filelist("codec_tests_bundle_data") {
    testonly = true
    filelist_name = "test/data/codec/unit_tests_bundle_data.filelist"
  }
  bundle_data_from_filelist("compositor_tests_bundle_data") {
    testonly = true
    filelist_name = "test/data/compositor/unit_tests_bundle_data.filelist"
  }
}

if (is_android) {
  java_cpp_features("ui_gfx_switches_srcjar") {
    # External code should depend on ":ui_gfx_java" instead.
    visibility = [ ":*" ]
    sources = [ "switches.cc" ]
    template = "android/java/src/org/chromium/ui/gfx/GfxSwitches.java.tmpl"
  }

  android_library("ui_gfx_java") {
    # Right now, this only includes the Java features. But if we need more Java
    # files, they should be added here as necessary.
    srcjar_deps = [ ":ui_gfx_switches_srcjar" ]
  }
}