chromium/ui/color/BUILD.gn

# Copyright 2019 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/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")
import("//ui/base/ui_features.gni")

assert(use_blink, "Not supported without use_blink")

source_set("color_headers") {
  sources = [
    "color_id.h",
    "color_id_macros.inc",
    "color_id_map_macros.inc",
    "color_metrics.h",
    "color_mixer.h",
    "color_provider.h",
    "color_provider_manager.h",
    "color_provider_utils.h",
  ]

  public_deps = [
    ":color_provider_key",
    ":mojom",
    "//base",
    "//skia",
    "//ui/gfx:color_utils",
  ]
}

# Keep the deps on this target to a minimum so that chromeos/crosapi can depend on it.
component("color_provider_key") {
  sources = [
    "color_provider_key.cc",
    "color_provider_key.h",
    "system_theme.h",
  ]

  defines = [ "IS_COLOR_PROVIDER_KEY_IMPL" ]

  deps = [
    "//base",
    "//skia",
    "//third_party/abseil-cpp:absl",
  ]
}

component("color") {
  sources = [
    "color_metrics.cc",
    "color_mixer.cc",
    "color_provider.cc",
    "color_provider_source.cc",
    "color_provider_source.h",
    "color_provider_source_observer.cc",
    "color_provider_source_observer.h",
    "color_provider_utils.cc",
    "color_provider_utils.h",
    "color_recipe.cc",
    "color_recipe.h",
    "color_transform.cc",
    "color_transform.h",
  ]

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

  defines = [ "IS_COLOR_IMPL" ]

  public_deps = [
    ":color_headers",
    "//base",
    "//skia",
    "//ui/base:features",
    "//ui/gfx:color_utils",
  ]

  if (is_mac) {
    sources += [
      "mac/native_color_transform.mm",
      "mac/system_color_utils.h",
      "mac/system_color_utils.mm",
    ]
    frameworks = [ "AppKit.framework" ]
  }
}

source_set("test_support") {
  testonly = true

  sources = [ "color_test_ids.h" ]

  deps = [ ":color_headers" ]
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "color_mixer_unittest.cc",
    "color_provider_manager_unittest.cc",
    "color_provider_source_observer_unittest.cc",
    "color_provider_unittest.cc",
    "color_provider_utils_unittest.cc",
    "color_recipe_unittest.cc",
    "color_transform_unittest.cc",
    "sys_color_mixer_unittest.cc",
  ]

  deps = [
    ":color",
    ":mixers",
    ":test_support",
    "//base/test:test_support",
    "//testing/gtest",
  ]
}

if (is_win) {
  component("accent_color_observer") {
    sources = [
      "win/accent_color_observer.cc",
      "win/accent_color_observer.h",
    ]

    defines = [ "IS_COLOR_IMPL" ]

    public_deps = [
      "//base",
      "//third_party/abseil-cpp:absl",
    ]

    deps = [
      "//skia",
      "//ui/gfx:color_utils",
    ]
  }
}

component("mixers") {
  sources = [
    "color_mixers.cc",
    "color_mixers.h",
    "color_provider_manager.cc",
    "color_provider_manager.h",
    "core_default_color_mixer.cc",
    "core_default_color_mixer.h",
    "css_system_color_mixer.cc",
    "css_system_color_mixer.h",
    "fluent_ui_color_mixer.cc",
    "fluent_ui_color_mixer.h",
    "material_ui_color_mixer.cc",
    "material_ui_color_mixer.h",
    "native_color_mixers.cc",
    "native_color_mixers.h",
    "ref_color_mixer.cc",
    "ref_color_mixer.h",
    "sys_color_mixer.cc",
    "sys_color_mixer.h",
    "ui_color_mixer.cc",
    "ui_color_mixer.h",
  ]

  defines = [ "IS_COLOR_IMPL" ]

  deps = [
    ":color",
    ":color_headers",
    ":color_provider_key",
    "//skia",
    "//third_party/material_color_utilities",
    "//ui/base:features",
    "//ui/color/dynamic_color",
    "//ui/gfx:color_utils",
    "//ui/native_theme:features",
  ]

  public_deps = [ "//base" ]

  if (is_chromeos) {
    sources += [ "chromeos/native_color_mixers_chromeos.cc" ]
  } else if (is_mac) {
    sources += [
      "mac/css_system_color_mixer_mac.mm",
      "mac/native_color_mixers_mac.mm",
    ]
    frameworks = [ "AppKit.framework" ]
  } else if (is_win) {
    sources += [
      "win/css_system_color_mixer_win.cc",
      "win/native_color_mixers_win.cc",
    ]
    deps += [ ":accent_color_observer" ]
  }
}

mojom("mojom") {
  generate_java = true
  sources = [
    "color_id.mojom",
    "scheme_variant.mojom",
  ]
}