chromium/gpu/ipc/service/BUILD.gn

# Copyright 2016 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("//gpu/vulkan/features.gni")
import("//skia/features.gni")
import("//testing/test.gni")
if (is_mac) {
  import("//build/config/mac/mac_sdk.gni")
}
import("//third_party/dawn/scripts/dawn_features.gni")
import("//ui/gl/features.gni")

declare_args() {
  subpixel_font_rendering_disabled = false
}

component("service") {
  output_name = "gpu_ipc_service"
  sources = [
    "command_buffer_stub.cc",
    "command_buffer_stub.h",
    "context_url.cc",
    "context_url.h",
    "gles2_command_buffer_stub.cc",
    "gles2_command_buffer_stub.h",
    "gpu_channel.cc",
    "gpu_channel.h",
    "gpu_channel_manager.cc",
    "gpu_channel_manager.h",
    "gpu_channel_manager_delegate.h",
    "gpu_channel_shared_image_interface.cc",
    "gpu_channel_shared_image_interface.h",
    "gpu_config.h",
    "gpu_init.cc",
    "gpu_init.h",
    "gpu_memory_buffer_factory.cc",
    "gpu_memory_buffer_factory.h",
    "gpu_watchdog_thread.cc",
    "gpu_watchdog_thread.h",
    "image_decode_accelerator_stub.cc",
    "image_decode_accelerator_stub.h",
    "image_decode_accelerator_worker.h",
    "image_transport_surface.h",
    "raster_command_buffer_stub.cc",
    "raster_command_buffer_stub.h",
    "shared_image_stub.cc",
    "shared_image_stub.h",
    "webgpu_command_buffer_stub.cc",
    "webgpu_command_buffer_stub.h",
  ]
  defines = [ "GPU_IPC_SERVICE_IMPLEMENTATION" ]
  if (subpixel_font_rendering_disabled) {
    defines += [ "SUBPIXEL_FONT_RENDERING_DISABLED" ]
  }
  if (dawn_use_built_dxc) {
    defines += [ "DAWN_USE_BUILT_DXC" ]
  }
  public_deps = [
    "//base",
    "//build:chromecast_buildflags",
    "//components/viz/common",
    "//gpu/config",
    "//gpu/ipc/common",
    "//ipc",
    "//ui/base",
    "//ui/display",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//ui/gl",
    "//ui/gl:buildflags",
    "//ui/gl/init",
    "//url",
  ]
  deps = [
    "//build:chromeos_buildflags",

    # crbug.com/799267: crash_key needs to be added explicitly for Windows and
    # Mac even though it's not directly referenced, because it's being
    # implicitly depended upon by gpu/config/gpu_crash_keys.h but deps (even
    # public ones) are not transitive for static libraries.
    "//components/crash/core/common:crash_key",
    "//components/viz/common:shared_image_format",
    "//gpu/command_buffer/common",
    "//gpu/command_buffer/service",
    "//gpu/command_buffer/service:gles2",
    "//gpu/config",
    "//gpu/vulkan:buildflags",
    "//mojo/public/cpp/bindings",
    "//ui/base:ozone_buildflags",
  ]
  libs = []
  ldflags = []
  if (is_win) {
    sources += [
      "dcomp_texture_win.cc",
      "dcomp_texture_win.h",
      "gpu_memory_buffer_factory_dxgi.cc",
      "gpu_memory_buffer_factory_dxgi.h",
      "image_transport_surface_win.cc",
    ]
    libs += [
      "d3d11.lib",
      "dcomp.lib",
      "dxguid.lib",
    ]
  }
  if (is_apple) {
    sources += [
      "gpu_memory_buffer_factory_io_surface.cc",
      "gpu_memory_buffer_factory_io_surface.h",
      "image_transport_surface_overlay_mac.h",
      "image_transport_surface_overlay_mac.mm",
    ]
  }
  if (is_mac) {
    sources += [
      "built_in_shader_cache_loader.cc",
      "built_in_shader_cache_loader.h",
      "built_in_shader_cache_writer.cc",
      "built_in_shader_cache_writer.h",
      "image_transport_surface_mac.mm",
    ]
    deps += [
      "//ui/accelerated_widget_mac",
      "//ui/display:display",
      "//ui/display/types:types",
    ]
    lib_dirs = [ "$mac_sdk_path/usr/lib" ]
    frameworks = [
      "CoreGraphics.framework",
      "IOSurface.framework",
      "OpenGL.framework",
      "QuartzCore.framework",
    ]
    defines += [ "GL_SILENCE_DEPRECATION" ]
  }
  if (is_ios) {
    sources += [ "image_transport_surface_ios.mm" ]
    deps += [ "//ui/accelerated_widget_mac" ]
  }
  if (is_android) {
    sources += [
      "image_transport_surface_android.cc",
      "stream_texture_android.cc",
      "stream_texture_android.h",
    ]
    libs += [ "android" ]
  }
  if (is_linux || is_chromeos) {
    sources += [ "image_transport_surface_linux.cc" ]
  }
  if (use_ozone) {
    sources += [
      "gpu_memory_buffer_factory_native_pixmap.cc",
      "gpu_memory_buffer_factory_native_pixmap.h",
    ]

    deps += [ "//ui/ozone" ]
  }
  if (is_fuchsia) {
    sources += [ "image_transport_surface_fuchsia.cc" ]
  }
  if (enable_vulkan) {
    deps += [ "//gpu/vulkan/init" ]
  }

  if (use_dawn || skia_use_dawn) {
    deps += [
      "//third_party/dawn/src/dawn:proc",
      "//third_party/dawn/src/dawn/native",
    ]
  }
  if (skia_use_dawn) {
    deps += [ "//third_party/dawn/include/dawn:cpp_headers" ]
  }
}

source_set("test_support") {
  testonly = true
  sources = [ "gpu_memory_buffer_factory_test_template.h" ]
  public_deps = [
    ":service",
    "//testing/gtest:gtest",
  ]
  deps = [
    "//base/test:test_support",
    "//gpu/ipc/common",
    "//ui/gl:test_support",
  ]
}