2d8e3ffd创建于 2024年8月24日历史提交
# 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/ui.gni")
import("//testing/test.gni")

component("compositor") {
  sources = [
    "animation_throughput_reporter.cc",
    "animation_throughput_reporter.h",
    "callback_layer_animation_observer.cc",
    "callback_layer_animation_observer.h",
    "canvas_painter.cc",
    "canvas_painter.h",
    "clip_recorder.cc",
    "clip_recorder.h",
    "closure_animation_observer.cc",
    "closure_animation_observer.h",
    "compositor.cc",
    "compositor.h",
    "compositor_animation_observer.cc",
    "compositor_animation_observer.h",
    "compositor_export.h",
    "compositor_lock.cc",
    "compositor_lock.h",
    "compositor_observer.h",
    "compositor_switches.cc",
    "compositor_switches.h",
    "debug_utils.cc",
    "debug_utils.h",
    "float_animation_curve_adapter.cc",
    "float_animation_curve_adapter.h",
    "layer.cc",
    "layer.h",
    "layer_animation_delegate.h",
    "layer_animation_element.cc",
    "layer_animation_element.h",
    "layer_animation_observer.cc",
    "layer_animation_observer.h",
    "layer_animation_sequence.cc",
    "layer_animation_sequence.h",
    "layer_animator.cc",
    "layer_animator.h",
    "layer_animator_collection.cc",
    "layer_animator_collection.h",
    "layer_delegate.cc",
    "layer_delegate.h",
    "layer_observer.h",
    "layer_owner.cc",
    "layer_owner.h",
    "layer_threaded_animation_delegate.h",
    "layer_tree_owner.cc",
    "layer_tree_owner.h",
    "layer_type.cc",
    "layer_type.h",
    "overscroll/scroll_input_handler.cc",
    "overscroll/scroll_input_handler.h",
    "paint_cache.cc",
    "paint_cache.h",
    "paint_context.cc",
    "paint_context.h",
    "paint_recorder.cc",
    "paint_recorder.h",
    "presentation_time_recorder.cc",
    "presentation_time_recorder.h",
    "property_change_reason.h",
    "scoped_animation_duration_scale_mode.cc",
    "scoped_animation_duration_scale_mode.h",
    "scoped_layer_animation_settings.cc",
    "scoped_layer_animation_settings.h",
    "throughput_tracker.cc",
    "throughput_tracker.h",
    "throughput_tracker_host.h",
    "total_animation_throughput_reporter.cc",
    "total_animation_throughput_reporter.h",
    "transform_animation_curve_adapter.cc",
    "transform_animation_curve_adapter.h",
    "transform_recorder.cc",
    "transform_recorder.h",
  ]

  if (is_mac) {
    sources += [
      "recyclable_compositor_mac.cc",
      "recyclable_compositor_mac.h",
    ]
  }

  defines = [ "COMPOSITOR_IMPLEMENTATION" ]

  public_deps = [ "//cc" ]
  deps = [
    "//base",
    "//base/third_party/dynamic_annotations",
    "//build:chromeos_buildflags",
    "//cc/animation",
    "//cc/paint",
    "//components/viz/host",
    "//gpu/command_buffer/common",
    "//services/viz/privileged/mojom/compositing",
    "//skia",
    "//ui/base",
    "//ui/display",
    "//ui/events",
    "//ui/gfx",
    "//ui/gfx/animation",
    "//ui/gfx/animation/keyframe",
    "//ui/gfx/geometry",
    "//ui/gl",
  ]

  if (is_apple) {
    deps += [ "//ui/accelerated_widget_mac" ]
  }

  if (is_win && use_aura) {
    # TODO(sky): before we make this real need to remove
    # IDR_BITMAP_BRUSH_IMAGE.
    deps += [ "//ui/resources" ]
  }
}

static_library("test_support") {
  testonly = true
  sources = [
    "test/animation_throughput_reporter_test_base.cc",
    "test/animation_throughput_reporter_test_base.h",
    "test/direct_layer_tree_frame_sink.cc",
    "test/direct_layer_tree_frame_sink.h",
    "test/draw_waiter_for_test.cc",
    "test/draw_waiter_for_test.h",
    "test/fake_context_factory.cc",
    "test/fake_context_factory.h",
    "test/in_process_context_factory.cc",
    "test/in_process_context_factory.h",
    "test/layer_animation_observer_test_api.cc",
    "test/layer_animation_observer_test_api.h",
    "test/layer_animation_stopped_waiter.cc",
    "test/layer_animation_stopped_waiter.h",
    "test/layer_animator_test_controller.cc",
    "test/layer_animator_test_controller.h",
    "test/multi_layer_animator_test_controller.cc",
    "test/multi_layer_animator_test_controller.h",
    "test/multi_layer_animator_test_controller_delegate.h",
    "test/test_compositor_host.cc",
    "test/test_compositor_host.h",
    "test/test_context_factories.cc",
    "test/test_context_factories.h",
    "test/test_layer_animation_delegate.cc",
    "test/test_layer_animation_delegate.h",
    "test/test_layer_animation_observer.cc",
    "test/test_layer_animation_observer.h",
    "test/test_layers.cc",
    "test/test_layers.h",
    "test/test_suite.cc",
    "test/test_suite.h",
    "test/test_utils.cc",
    "test/test_utils.h",
    "test/throughput_report_checker.cc",
    "test/throughput_report_checker.h",
  ]

  if (ohos_unittests) {
    sources += [
      "//ohos_nweb/src/sysevent/event_reporter.cc",
    ]
  }

  if (is_android) {
    sources += [ "test/test_compositor_host_android.cc" ]
  }

  if (is_mac) {
    sources += [ "test/test_compositor_host_mac.mm" ]
  }

  if (is_ios) {
    sources += [ "test/test_compositor_host_ios.mm" ]
  }

  if (is_win) {
    sources += [ "test/test_compositor_host_win.cc" ]
  }

  if (ohos_unittests) {
    sources += [
      "test/test_compositor_host_ohos.cc",
    ]
  }

  public_deps = [ ":compositor" ]
  deps = [
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//cc",
    "//cc:test_support",
    "//components/viz/host",
    "//components/viz/service",
    "//components/viz/test:test_support",
    "//gpu/command_buffer/client:gles2_implementation",
    "//gpu/command_buffer/client:raster",
    "//gpu/command_buffer/common",
    "//gpu/ipc:gl_in_process_context",
    "//gpu/skia_bindings",
    "//skia",
    "//testing/gtest",
    "//ui/base",
    "//ui/display",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//ui/gl:test_support",
  ]

  if (is_apple) {
    deps += [
      "//gpu/ipc/service:service",
      "//ui/accelerated_widget_mac",
    ]
  }

  if (use_ozone && !ohos_unittests) {
    sources += [
      "test/test_compositor_host_ozone.cc",
      "test/test_compositor_host_ozone.h",
    ]

    deps += [
      "//ui/ozone",
      "//ui/platform_window",
    ]
  }
}

test("compositor_unittests") {
  use_xvfb = use_xvfb_in_this_config

  sources = [
    "animation_throughput_reporter_unittest.cc",
    "callback_layer_animation_observer_unittest.cc",
    "canvas_painter_unittest.cc",
    "compositor_lock_unittest.cc",
    "compositor_unittest.cc",
    "layer_animation_element_unittest.cc",
    "layer_animation_sequence_unittest.cc",
    "layer_animator_unittest.cc",
    "layer_owner_unittest.cc",
    "layer_unittest.cc",
    "presentation_time_recorder_unittest.cc",
    "run_all_unittests.cc",
    "throughput_tracker_unittest.cc",
    "total_animation_throughput_reporter_unittest.cc",
    "transform_animation_curve_adapter_unittest.cc",
    "compositor_unittests.cc",
  ]

  if (ohos_unittests) {
    sources += [
      "//cef/libcef/common/soc_perf_util.cc",
      "//content/browser/browser_thread_impl.cc",
      "//content/browser/scheduler/browser_task_executor.cc",
      "//content/public/common/content_features.cc",
      "//content/public/common/content_switches.cc",
      "//content/renderer/render_remote_proxy_ohos.cc",
      "//content/renderer/render_remote_proxy_ohos.h"
    ]
  }

  data = [ "//ui/gfx/test/data/compositor/" ]

  deps = [
    ":compositor",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//cc",
    "//cc:test_support",
    "//components/viz/common",
    "//components/viz/test:test_support",
    "//mojo/core/embedder",
    "//skia",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/base",
    "//ui/gfx",
    "//ui/gfx:test_support",
    "//ui/gfx/geometry",
    "//ui/gl",
    "//ui/resources",
  ]

  data_deps = [ "//testing/buildbot/filters:compositor_unittests_filters" ]

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

  if (is_fuchsia) {
    # TODO(https://crbug.com/1185811): Investigate removing the requirement for
    # job_policy_ambient_mark_vmo_exec for the sake of V8's allocator in tests.
    test_runner_shard = "//build/config/fuchsia/test/elf_test_ambient_exec_runner.shard.test-cml"
    additional_manifest_fragments = [
      "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
      "//build/config/fuchsia/test/present_view.shard.test-cml",
      "//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
    ]
  }

  if (is_ios) {
    public_deps = [ "//ui/gfx:unit_tests_bundle_data" ]
  }
}