chromium/components/viz/service/BUILD.gn

# Copyright 2017 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/chromeos/ui_mode.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")
import("//components/viz/viz.gni")
import("//gpu/vulkan/features.gni")
import("//media/gpu/args.gni")
import("//skia/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/jni_zero/jni_zero.gni")

config("viz_service_implementation") {
}

source_set("viz_service_export") {
  sources = [ "viz_service_export.h" ]
}

static_library("viz_debugger") {
  sources = [
    "debugger/rwlock.cc",
    "debugger/rwlock.h",
    "debugger/viz_debugger.cc",
    "debugger/viz_debugger.h",
  ]

  defines = [ "VIZ_SERVICE_IMPLEMENTATION" ]

  deps = [
    ":viz_service_export",
    "//base",
    "//components/viz/common:buildflags",
    "//components/viz/service/debugger/mojom",
    "//mojo/public/cpp/bindings",
    "//skia",
    "//skia:skia_core_public_headers",
    "//ui/gfx/geometry",
  ]
}

viz_component("service") {
  sources = [
    "display/aggregated_frame.cc",
    "display/aggregated_frame.h",
    "display/bsp_tree.cc",
    "display/bsp_tree.h",
    "display/bsp_walk_action.cc",
    "display/bsp_walk_action.h",
    "display/damage_frame_annotator.cc",
    "display/damage_frame_annotator.h",
    "display/delegated_ink_handler.cc",
    "display/delegated_ink_handler.h",
    "display/delegated_ink_point_renderer_base.cc",
    "display/delegated_ink_point_renderer_base.h",
    "display/delegated_ink_point_renderer_skia.cc",
    "display/delegated_ink_point_renderer_skia.h",
    "display/delegated_ink_trail_data.cc",
    "display/delegated_ink_trail_data.h",
    "display/direct_renderer.cc",
    "display/direct_renderer.h",
    "display/display.cc",
    "display/display.h",
    "display/display_client.h",
    "display/display_compositor_memory_and_task_controller.cc",
    "display/display_compositor_memory_and_task_controller.h",
    "display/display_damage_tracker.cc",
    "display/display_damage_tracker.h",
    "display/display_resource_provider.cc",
    "display/display_resource_provider.h",
    "display/display_resource_provider_null.cc",
    "display/display_resource_provider_null.h",
    "display/display_resource_provider_skia.cc",
    "display/display_resource_provider_skia.h",
    "display/display_resource_provider_software.cc",
    "display/display_resource_provider_software.h",
    "display/display_scheduler.cc",
    "display/display_scheduler.h",
    "display/display_scheduler_base.cc",
    "display/display_scheduler_base.h",
    "display/display_utils.cc",
    "display/display_utils.h",
    "display/draw_polygon.cc",
    "display/draw_polygon.h",
    "display/external_use_client.cc",
    "display/external_use_client.h",
    "display/frame_interval_decider.cc",
    "display/frame_interval_decider.h",
    "display/frame_interval_matchers.cc",
    "display/frame_interval_matchers.h",
    "display/frame_rate_decider.cc",
    "display/frame_rate_decider.h",
    "display/null_renderer.cc",
    "display/null_renderer.h",
    "display/occlusion_culler.cc",
    "display/occlusion_culler.h",
    "display/output_surface.cc",
    "display/output_surface.h",
    "display/output_surface_client.h",
    "display/output_surface_frame.cc",
    "display/output_surface_frame.h",
    "display/overdraw_tracker.cc",
    "display/overdraw_tracker.h",
    "display/overlay_candidate.cc",
    "display/overlay_candidate.h",
    "display/overlay_candidate_factory.cc",
    "display/overlay_candidate_factory.h",
    "display/overlay_candidate_temporal_tracker.cc",
    "display/overlay_candidate_temporal_tracker.h",
    "display/overlay_processor_interface.cc",
    "display/overlay_processor_interface.h",
    "display/overlay_processor_on_gpu.cc",
    "display/overlay_processor_on_gpu.h",
    "display/overlay_processor_stub.cc",
    "display/overlay_processor_stub.h",
    "display/pending_swap_params.cc",
    "display/pending_swap_params.h",
    "display/render_pass_alpha_type.h",
    "display/renderer_utils.cc",
    "display/renderer_utils.h",
    "display/resolved_frame_data.cc",
    "display/resolved_frame_data.h",
    "display/resource_fence.cc",
    "display/resource_fence.h",
    "display/shared_bitmap_manager.h",
    "display/skia_output_surface.cc",
    "display/skia_output_surface.h",
    "display/skia_renderer.cc",
    "display/skia_renderer.h",
    "display/software_output_device.cc",
    "display/software_output_device.h",
    "display/software_renderer.cc",
    "display/software_renderer.h",
    "display/surface_aggregator.cc",
    "display/surface_aggregator.h",
    "display_embedder/buffer_queue.cc",
    "display_embedder/buffer_queue.h",
    "display_embedder/compositor_gpu_thread.cc",
    "display_embedder/compositor_gpu_thread.h",
    "display_embedder/image_context_impl.cc",
    "display_embedder/image_context_impl.h",
    "display_embedder/in_process_gpu_memory_buffer_manager.cc",
    "display_embedder/in_process_gpu_memory_buffer_manager.h",
    "display_embedder/output_presenter.h",
    "display_embedder/output_presenter_gl.cc",
    "display_embedder/output_presenter_gl.h",
    "display_embedder/output_surface_provider.h",
    "display_embedder/output_surface_provider_impl.cc",
    "display_embedder/output_surface_provider_impl.h",
    "display_embedder/server_shared_bitmap_manager.cc",
    "display_embedder/server_shared_bitmap_manager.h",
    "display_embedder/skia_output_device.cc",
    "display_embedder/skia_output_device.h",
    "display_embedder/skia_output_device_buffer_queue.cc",
    "display_embedder/skia_output_device_buffer_queue.h",
    "display_embedder/skia_output_device_gl.cc",
    "display_embedder/skia_output_device_gl.h",
    "display_embedder/skia_output_device_offscreen.cc",
    "display_embedder/skia_output_device_offscreen.h",
    "display_embedder/skia_output_device_webview.cc",
    "display_embedder/skia_output_device_webview.h",
    "display_embedder/skia_output_surface_dependency.h",
    "display_embedder/skia_output_surface_dependency_impl.cc",
    "display_embedder/skia_output_surface_dependency_impl.h",
    "display_embedder/skia_output_surface_impl.cc",
    "display_embedder/skia_output_surface_impl.h",
    "display_embedder/skia_output_surface_impl_on_gpu.cc",
    "display_embedder/skia_output_surface_impl_on_gpu.h",
    "display_embedder/skia_output_surface_impl_on_gpu_debug_capture.cc",
    "display_embedder/skia_output_surface_impl_on_gpu_debug_capture.h",
    "display_embedder/skia_render_copy_results.cc",
    "display_embedder/skia_render_copy_results.h",
    "display_embedder/software_output_surface.cc",
    "display_embedder/software_output_surface.h",
    "display_embedder/vsync_parameter_listener.cc",
    "display_embedder/vsync_parameter_listener.h",
    "frame_sinks/begin_frame_tracker.cc",
    "frame_sinks/begin_frame_tracker.h",
    "frame_sinks/compositor_frame_sink_impl.cc",
    "frame_sinks/compositor_frame_sink_impl.h",
    "frame_sinks/compositor_frame_sink_support.cc",
    "frame_sinks/compositor_frame_sink_support.h",
    "frame_sinks/eviction_handler.cc",
    "frame_sinks/eviction_handler.h",
    "frame_sinks/external_begin_frame_source_mojo.cc",
    "frame_sinks/external_begin_frame_source_mojo.h",
    "frame_sinks/frame_counter.cc",
    "frame_sinks/frame_counter.h",
    "frame_sinks/frame_sink_bundle_impl.cc",
    "frame_sinks/frame_sink_bundle_impl.h",
    "frame_sinks/frame_sink_manager_impl.cc",
    "frame_sinks/frame_sink_manager_impl.h",
    "frame_sinks/frame_sink_observer.h",
    "frame_sinks/gmb_video_frame_pool_context_provider.h",
    "frame_sinks/gmb_video_frame_pool_context_provider_impl.cc",
    "frame_sinks/gmb_video_frame_pool_context_provider_impl.h",
    "frame_sinks/root_compositor_frame_sink_impl.cc",
    "frame_sinks/root_compositor_frame_sink_impl.h",
    "frame_sinks/shared_image_interface_provider.cc",
    "frame_sinks/shared_image_interface_provider.h",
    "frame_sinks/surface_resource_holder.cc",
    "frame_sinks/surface_resource_holder.h",
    "frame_sinks/surface_resource_holder_client.h",
    "frame_sinks/video_capture/capturable_frame_sink.h",
    "frame_sinks/video_capture/frame_sink_video_capturer_impl.cc",
    "frame_sinks/video_capture/frame_sink_video_capturer_impl.h",
    "frame_sinks/video_capture/frame_sink_video_capturer_manager.h",
    "frame_sinks/video_capture/gpu_memory_buffer_video_frame_pool.cc",
    "frame_sinks/video_capture/gpu_memory_buffer_video_frame_pool.h",
    "frame_sinks/video_capture/in_flight_frame_delivery.cc",
    "frame_sinks/video_capture/in_flight_frame_delivery.h",
    "frame_sinks/video_capture/shared_memory_video_frame_pool.cc",
    "frame_sinks/video_capture/shared_memory_video_frame_pool.h",
    "frame_sinks/video_capture/video_capture_overlay.cc",
    "frame_sinks/video_capture/video_capture_overlay.h",
    "frame_sinks/video_capture/video_frame_pool.cc",
    "frame_sinks/video_capture/video_frame_pool.h",
    "frame_sinks/video_detector.cc",
    "frame_sinks/video_detector.h",
    "gl/gpu_service_impl.cc",
    "gl/gpu_service_impl.h",
    "hit_test/hit_test_aggregator.cc",
    "hit_test/hit_test_aggregator.h",
    "hit_test/hit_test_aggregator_delegate.h",
    "hit_test/hit_test_manager.cc",
    "hit_test/hit_test_manager.h",
    "input/input_manager.cc",
    "input/input_manager.h",
    "layers/layer_context_impl.cc",
    "layers/layer_context_impl.h",
    "performance_hint/boost_manager.cc",
    "performance_hint/boost_manager.h",
    "performance_hint/hint_session.cc",
    "performance_hint/hint_session.h",
    "surfaces/frame_index_constants.h",
    "surfaces/latest_local_surface_id_lookup_delegate.h",
    "surfaces/pending_copy_output_request.cc",
    "surfaces/pending_copy_output_request.h",
    "surfaces/referenced_surface_tracker.cc",
    "surfaces/referenced_surface_tracker.h",
    "surfaces/surface.cc",
    "surfaces/surface.h",
    "surfaces/surface_allocation_group.cc",
    "surfaces/surface_allocation_group.h",
    "surfaces/surface_client.h",
    "surfaces/surface_dependency_deadline.cc",
    "surfaces/surface_dependency_deadline.h",
    "surfaces/surface_manager.cc",
    "surfaces/surface_manager.h",
    "surfaces/surface_manager_delegate.h",
    "surfaces/surface_observer.cc",
    "surfaces/surface_observer.h",
    "surfaces/surface_reference.cc",
    "surfaces/surface_reference.h",
    "surfaces/surface_saved_frame.cc",
    "surfaces/surface_saved_frame.h",
    "transitions/surface_animation_manager.cc",
    "transitions/surface_animation_manager.h",
    "transitions/transferable_resource_tracker.cc",
    "transitions/transferable_resource_tracker.h",
  ]

  defines = [ "VIZ_SERVICE_IMPLEMENTATION" ]

  deps = [
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
    "//cc/base",
    "//cc/paint",
    "//components/crash/core/common:crash_key",
    "//components/input",
    "//components/input:mojom",
    "//components/startup_metric_utils",

    # Note that dependency on //gpu/ipc/client is for GpuMemoryBufferImpl. This
    # dependency should not be in public_deps.
    "//components/version_info:version_info",
    "//components/viz/common",
    "//gpu/command_buffer/client",
    "//gpu/config",
    "//gpu/ipc/client",
    "//gpu/ipc/common:common",
    "//gpu/ipc/common:surface_handle_type",
    "//gpu/ipc/service",
    "//gpu/skia_bindings:skia_bindings",
    "//gpu/vulkan:buildflags",
    "//media",
    "//media/capture:capture_lib",
    "//media/mojo/services",
    "//services/metrics/public/mojom",
    "//services/tracing/public/cpp:cpp",
    "//services/viz/privileged/mojom",
    "//services/webnn:webnn_service",
    "//services/webnn/public/mojom",
    "//skia",
    "//skia:skcms",
    "//third_party/libyuv",
    "//ui/base:ozone_buildflags",
    "//ui/display/types",
    "//ui/gfx/animation/keyframe",
  ]

  public_deps = [
    ":viz_debugger",
    ":viz_service_export",
    "//base",
    "//cc",
    "//cc/animation",
    "//cc/debug",
    "//components/viz/common",
    "//gpu/command_buffer/service:gles2",
    "//gpu/ipc/service",
    "//gpu/vulkan:buildflags",
    "//media/gpu/ipc/service",
    "//media/mojo/services",
    "//services/metrics/public/cpp:metrics_cpp",
    "//services/viz/privileged/mojom/compositing",
    "//services/viz/privileged/mojom/gl",
    "//services/viz/public/mojom",
    "//services/webnn/public/mojom",
    "//skia",
    "//ui/base/prediction",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//ui/latency",
  ]

  if (is_chromeos_ash) {
    sources += [
      "display_embedder/output_surface_unified.cc",
      "display_embedder/output_surface_unified.h",
    ]

    deps += [
      "//components/chromeos_camera:jpeg_encode_accelerator_service",
      "//components/chromeos_camera:mjpeg_decode_accelerator_service",
      "//gpu/command_buffer/service:gles2",
      "//media/mojo/services",
    ]

    if (use_v4l2_codec || use_vaapi) {
      deps += [ "//ash/components/arc/video_accelerator" ]
    }
  }

  if (is_apple) {
    sources += [
      "display/ca_layer_overlay.cc",
      "display/ca_layer_overlay.h",
      "display/overlay_processor_mac.cc",
      "display/overlay_processor_mac.h",
      "display_embedder/software_output_device_mac.cc",
      "display_embedder/software_output_device_mac.h",
    ]

    deps += [ "//ui/accelerated_widget_mac" ]
    frameworks = [ "IOSurface.framework" ]
    if (is_ios) {
      sources += [
        "frame_sinks/external_begin_frame_source_ios.h",
        "frame_sinks/external_begin_frame_source_ios.mm",
      ]

      frameworks += [ "CoreGraphics.framework" ]
    }
    if (is_mac) {
      sources += [
        "frame_sinks/external_begin_frame_source_mac.cc",
        "frame_sinks/external_begin_frame_source_mac.h",
      ]
    }
  }

  if (is_android || use_ozone) {
    sources += [
      "display/overlay_combination_cache.cc",
      "display/overlay_combination_cache.h",
      "display/overlay_processor_strategy.cc",
      "display/overlay_processor_strategy.h",
      "display/overlay_processor_using_strategy.cc",
      "display/overlay_processor_using_strategy.h",
      "display/overlay_proposed_candidate.cc",
      "display/overlay_proposed_candidate.h",
      "display/overlay_strategy_fullscreen.cc",
      "display/overlay_strategy_fullscreen.h",
      "display/overlay_strategy_single_on_top.cc",
      "display/overlay_strategy_single_on_top.h",
      "display/overlay_strategy_underlay.cc",
      "display/overlay_strategy_underlay.h",
    ]
  }

  if (enable_cast_overlay_strategy) {
    sources += [
      "display/overlay_strategy_underlay_cast.cc",
      "display/overlay_strategy_underlay_cast.h",
    ]

    deps += [ "//chromecast/media/service/mojom" ]
  }

  if (is_android) {
    sources += [
      "display/overlay_processor_android.cc",
      "display/overlay_processor_android.h",
      "display/overlay_processor_surface_control.cc",
      "display/overlay_processor_surface_control.h",
      "frame_sinks/external_begin_frame_source_android.cc",
      "frame_sinks/external_begin_frame_source_android.h",
      "gl/throw_uncaught_exception.cc",
      "gl/throw_uncaught_exception.h",
    ]

    deps += [ ":service_jni_headers" ]
  }

  if (use_ozone) {
    sources += [
      "display/overlay_processor_delegated.cc",
      "display/overlay_processor_delegated.h",
      "display/overlay_processor_delegated_support.cc",
      "display/overlay_processor_delegated_support.h",
      "display/overlay_processor_ozone.cc",
      "display/overlay_processor_ozone.h",
      "display_embedder/software_output_device_ozone.cc",
      "display_embedder/software_output_device_ozone.h",
    ]

    public_deps += [ "//ui/ozone" ]
  }

  if (is_win) {
    sources += [
      "display/dc_layer_overlay.cc",
      "display/dc_layer_overlay.h",
      "display/overlay_processor_delegated_support.cc",
      "display/overlay_processor_delegated_support.h",
      "display/overlay_processor_win.cc",
      "display/overlay_processor_win.h",
      "display_embedder/output_device_backing.cc",
      "display_embedder/output_device_backing.h",
      "display_embedder/skia_output_device_dcomp.cc",
      "display_embedder/skia_output_device_dcomp.h",
      "display_embedder/software_output_device_win.cc",
      "display_embedder/software_output_device_win.h",
      "frame_sinks/external_begin_frame_source_win.cc",
      "frame_sinks/external_begin_frame_source_win.h",
      "gl/info_collection_gpu_service_impl.cc",
      "gl/info_collection_gpu_service_impl.h",
    ]

    # SkiaOutputDeviceBufferQueue doesn't support Windows.
    sources -= [
      "display_embedder/output_presenter.h",
      "display_embedder/output_presenter_gl.cc",
      "display_embedder/output_presenter_gl.h",
      "display_embedder/skia_output_device_buffer_queue.cc",
      "display_embedder/skia_output_device_buffer_queue.h",
    ]
  }

  if (is_fuchsia) {
    sources += [
      "display_embedder/output_presenter_fuchsia.cc",
      "display_embedder/output_presenter_fuchsia.h",
    ]
  }

  if (use_vaapi) {
    deps += [ "//media/gpu/vaapi" ]
  }

  if (enable_vulkan) {
    deps += [ "//gpu/vulkan" ]

    sources += [
      "display_embedder/skia_output_device_vulkan.cc",
      "display_embedder/skia_output_device_vulkan.h",
    ]

    if (is_android) {
      sources += [
        "display_embedder/skia_output_device_vulkan_secondary_cb.cc",
        "display_embedder/skia_output_device_vulkan_secondary_cb.h",
      ]
    }

    # TODO(crbug.com/40193891): ideally, ozone_platform_x11 should not be used outside
    # ui/ozone.
    if (ozone_platform_x11) {
      sources += [
        "display_embedder/skia_output_device_x11.cc",
        "display_embedder/skia_output_device_x11.h",
      ]

      libs = [ "xshmfence" ]

      deps += [
        "//ui/base/x",
        "//ui/events/platform/x11",
        "//ui/gfx/x",
      ]
    }

    if (is_chromeos && use_v4l2_codec) {
      deps += [ "//media/gpu/chromeos:common" ]
    }
  }

  if (skia_use_dawn) {
    if (is_win || is_android) {
      sources += [
        "display_embedder/skia_output_device_dawn.cc",
        "display_embedder/skia_output_device_dawn.h",
      ]
    }
    public_deps += [ "//third_party/dawn/include/dawn:headers" ]

    deps += [
      "//third_party/dawn/include/dawn:cpp_headers",
      "//third_party/dawn/src/dawn:proc",
      "//third_party/dawn/src/dawn/native",
    ]
  }
}

viz_source_set("unit_tests") {
  testonly = true
  sources = [
    "debugger/viz_debugger_unittests/viz_debugger_internal.cc",
    "debugger/viz_debugger_unittests/viz_debugger_internal.h",
    "debugger/viz_debugger_unittests/viz_debugger_multithread_unittest.cc",
    "debugger/viz_debugger_unittests/viz_debugger_rwlock_unittest.cc",
    "debugger/viz_debugger_unittests/viz_debugger_unittest.cc",
    "debugger/viz_debugger_unittests/viz_debugger_unittest_base.cc",
    "debugger/viz_debugger_unittests/viz_debugger_unittest_base.h",
    "display/bsp_tree_unittest.cc",
    "display/copy_output_scaling_pixeltest.cc",
    "display/delegated_ink_point_pixel_test_helper.cc",
    "display/delegated_ink_point_pixel_test_helper.h",
    "display/display_damage_tracker_unittest.cc",
    "display/display_resource_provider_skia_unittest.cc",
    "display/display_resource_provider_software_unittest.cc",
    "display/display_scheduler_unittest.cc",
    "display/display_unittest.cc",
    "display/display_utils_unittest.cc",
    "display/draw_polygon_unittest.cc",
    "display/frame_interval_decider_unittest.cc",
    "display/frame_interval_matchers_unittest.cc",
    "display/frame_rate_decider_unittest.cc",
    "display/occlusion_culler_unittest.cc",
    "display/overdraw_tracker_unittest.cc",
    "display/overlay_candidate_factory_unittest.cc",
    "display/readback_pixeltest.cc",
    "display/renderer_pixeltest.cc",
    "display/resolved_frame_data_unittest.cc",
    "display/software_renderer_unittest.cc",
    "display/surface_aggregator_pixeltest.cc",
    "display/surface_aggregator_unittest.cc",
    "display/viz_pixel_test.cc",
    "display/viz_pixel_test.h",
    "display_embedder/buffer_queue_unittest.cc",
    "display_embedder/server_shared_bitmap_manager_unittest.cc",
    "display_embedder/skia_output_device_buffer_queue_unittest.cc",
    "display_embedder/skia_output_surface_impl_unittest.cc",
    "display_embedder/software_output_surface_unittest.cc",
    "display_embedder/vsync_parameter_listener_unittest.cc",
    "frame_sinks/begin_frame_tracker_unittest.cc",
    "frame_sinks/compositor_frame_sink_support_unittest.cc",
    "frame_sinks/frame_sink_bundle_impl_unittest.cc",
    "frame_sinks/frame_sink_manager_unittest.cc",
    "frame_sinks/surface_references_unittest.cc",
    "frame_sinks/surface_synchronization_unittest.cc",
    "frame_sinks/video_capture/frame_sink_video_capturer_impl_unittest.cc",
    "frame_sinks/video_capture/shared_memory_video_frame_pool_unittest.cc",
    "frame_sinks/video_capture/video_capture_overlay_unittest.cc",
    "frame_sinks/video_detector_unittest.cc",
    "gl/gpu_service_impl_unittest.cc",
    "hit_test/hit_test_aggregator_unittest.cc",
    "input/mock_input_manager.cc",
    "input/mock_input_manager.h",
    "main/viz_main_impl_unittest.cc",
    "performance_hint/boost_manager_unittest.cc",
    "surfaces/referenced_surface_tracker_unittest.cc",
    "surfaces/surface_unittest.cc",
    "transitions/transferable_resource_tracker_unittest.cc",
  ]

  if (!use_aura && !is_mac && !is_win) {
    sources -= [ "display_embedder/buffer_queue_unittest.cc" ]
  }

  deps = [
    ":service",
    ":viz_debugger",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//cc:test_support",
    "//cc/paint",
    "//components/input",
    "//components/viz/client",
    "//components/viz/common",
    "//components/viz/host",
    "//components/viz/service/main:main",
    "//components/viz/test:test_suite",
    "//components/viz/test:test_support",
    "//gpu/command_buffer/client",
    "//gpu/command_buffer/client:raster_interface",
    "//gpu/ipc:gl_in_process_context",
    "//gpu/ipc/service",
    "//media",
    "//media:test_support",
    "//media/capture:capture_lib",
    "//services/viz/public/mojom",
    "//skia",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/angle:includes",
    "//third_party/libyuv",
    "//ui/display/types",
    "//ui/gfx:test_support",
    "//ui/gl",
  ]

  if (use_ozone) {
    sources += [
      "display/overlay_combination_cache_unittest.cc",
      "display/overlay_processor_ozone_unittest.cc",
      "display/overlay_unittest.cc",
      "display_embedder/software_output_device_ozone_unittest.cc",
    ]
    deps += [
      "//ui/base:features",
      "//ui/compositor:test_support",
      "//ui/ozone",
    ]
  }

  if (is_mac) {
    sources += [
      "display/overlay_ca_unittest.cc",
      "display_embedder/software_output_device_mac_unittest.mm",
    ]
    frameworks = [ "IOSurface.framework" ]
  }

  if (is_win) {
    sources += [
      "display/overlay_dc_unittest.cc",
      "display_embedder/output_device_backing_unittest.cc",
      "display_embedder/software_output_device_win_unittest.cc",
    ]

    deps += [
      "//ui/gl:test_support",
      "//ui/platform_window",
      "//ui/platform_window/win",
    ]

    # SkiaOutputDeviceBufferQueue doesn't support Windows.
    sources -=
        [ "display_embedder/skia_output_device_buffer_queue_unittest.cc" ]
  }

  if (is_android) {
    sources += [
      "display/overlay_combination_cache_unittest.cc",
      "display/overlay_processor_surface_control_unittest.cc",
      "display/overlay_unittest.cc",
      "frame_sinks/external_begin_frame_source_android_unittest.cc",
    ]
  }

  if (enable_vulkan) {
    deps += [
      "//gpu/vulkan:test_support",
      "//gpu/vulkan/init",
    ]
  }
}

viz_source_set("perf_tests") {
  testonly = true
  sources = [
    "display/bsp_tree_perftest.cc",
    "display/display_perftest.cc",
    "display/renderer_perftest.cc",
    "display/surface_aggregator_perftest.cc",
    "display/viz_perftest.cc",
    "display/viz_perftest.h",
  ]

  deps = [
    ":service",
    "//base",
    "//base/test:test_support",
    "//cc",
    "//cc:test_support",
    "//cc/base",
    "//components/viz/client:client",
    "//components/viz/test:test_support",
    "//testing/gtest",
    "//testing/perf",
    "//third_party/zlib/google:zip",
  ]
}

fuzzer_test("hit_test_manager_fuzzer") {
  sources = [ "hit_test/hit_test_manager_fuzzer.cc" ]

  libfuzzer_options = [ "max_len=81920" ]

  deps = [
    ":service",
    "//base/test:test_support",
    "//components/viz/test:test_support",
    "//ui/gfx:test_support",
  ]
}

if (is_android) {
  android_library("service_java") {
    deps = [
      "//base:base_java",
      "//build/android:build_java",
      "//third_party/jni_zero:jni_zero_java",
      "//ui/android:ui_no_recycler_view_java",
    ]

    srcjar_deps = [ ":service_jni_headers" ]
    sources = [
      "java/src/org/chromium/components/viz/service/frame_sinks/ExternalBeginFrameSourceAndroid.java",
      "java/src/org/chromium/components/viz/service/gl/ThrowUncaughtException.java",
    ]
  }

  generate_jni("service_jni_headers") {
    sources = [
      "java/src/org/chromium/components/viz/service/frame_sinks/ExternalBeginFrameSourceAndroid.java",
      "java/src/org/chromium/components/viz/service/gl/ThrowUncaughtException.java",
    ]
  }
}

group("viz_service_fuzzers") {
  testonly = true
  deps = [
    ":hit_test_manager_fuzzer",
    "compositor_frame_fuzzer:compositor_frame_fuzzer",
  ]
}