diff --git a/BUILD.gn b/BUILD.gn index dab6592f484995..b80b4a5be10c2a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -100,7 +100,6 @@ group("gn_all") { if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) { deps += [ "//chrome", - "//chrome/browser/ui/color:dump_colors", "//chrome/test:browser_tests", "//chrome/test:interactive_ui_tests", "//chrome/test:sync_integration_tests", @@ -812,6 +811,10 @@ group("gn_all") { ] } + if (use_color_pipeline) { + deps += [ "//chrome/browser/ui/color:dump_colors" ] + } + # PFFFT. deps += [ "//third_party/pffft:fuzzers", diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index f079f5eb0e09a2..4f5402808b2ef6 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -2217,6 +2217,7 @@ jumbo_static_library("browser") { "//ui/base:ui_data_pack", "//ui/base/idle", "//ui/base/ime", + "//ui/color:color_buildflags", "//ui/events:events_base", "//ui/gfx", "//ui/gfx/geometry", diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index b50bb72118cff7..03889e2f51c7a8 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -24,7 +24,6 @@ #include "base/values.h" #include "build/build_config.h" #include "chrome/browser/themes/theme_properties.h" -#include "chrome/browser/ui/color/chrome_color_id.h" #include "chrome/browser/ui/frame/window_frame_util.h" #include "chrome/common/extensions/manifest_handlers/theme_handler.h" #include "chrome/common/themes/autogenerated_theme_util.h" @@ -32,10 +31,7 @@ #include "components/crx_file/id_util.h" #include "content/public/browser/browser_thread.h" #include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkColor.h" #include "ui/base/resource/data_pack.h" -#include "ui/color/color_mixer.h" -#include "ui/color/color_provider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/color_analysis.h" @@ -49,6 +45,13 @@ #include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/skia_util.h" +#if BUILDFLAG(USE_COLOR_PIPELINE) +#include "chrome/browser/ui/color/chrome_color_id.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/color/color_mixer.h" +#include "ui/color/color_provider.h" +#endif + using content::BrowserThread; using extensions::Extension; using TP = ThemeProperties; @@ -1015,6 +1018,7 @@ bool BrowserThemePack::HasCustomImage(int idr_id) const { return false; } +#if BUILDFLAG(USE_COLOR_PIPELINE) void BrowserThemePack::AddCustomThemeColorMixers( ui::ColorProvider* provider) const { // A map from theme property IDs to color IDs for use in color mixers. @@ -1037,6 +1041,7 @@ void BrowserThemePack::AddCustomThemeColorMixers( return; provider->AddMixer().AddSet({kColorSetCustomTheme, std::move(theme_colors)}); } +#endif // private: diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h index 86fc5a0dc088c7..752fba0062b02e 100644 --- a/chrome/browser/themes/browser_theme_pack.h +++ b/chrome/browser/themes/browser_theme_pack.h @@ -18,6 +18,7 @@ #include "extensions/common/extension.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/layout.h" +#include "ui/color/color_buildflags.h" #include "ui/gfx/color_utils.h" namespace base { @@ -31,8 +32,11 @@ class Image; } namespace ui { -class ColorProvider; class DataPack; + +#if BUILDFLAG(USE_COLOR_PIPELINE) +class ColorProvider; +#endif } // An optimized representation of a theme, backed by a mmapped DataPack. @@ -95,9 +99,11 @@ class BrowserThemePack : public CustomThemeSupplier { const override; bool HasCustomImage(int id) const override; +#if BUILDFLAG(USE_COLOR_PIPELINE) // Builds the color mixers that represent the state of the current browser // theme instance. void AddCustomThemeColorMixers(ui::ColorProvider* provider) const; +#endif private: friend class BrowserThemePackTest; diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index 9638fd80990552..c36e66b712d78b 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -13,21 +13,25 @@ #include "base/values.h" #include "build/build_config.h" #include "chrome/browser/themes/theme_properties.h" -#include "chrome/browser/ui/color/chrome_color_id.h" #include "chrome/browser/ui/frame/window_frame_util.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/themes/autogenerated_theme_util.h" #include "chrome/grit/theme_resources.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/color/color_mixer.h" -#include "ui/color/color_provider.h" -#include "ui/color/color_test_ids.h" +#include "ui/color/color_buildflags.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_rep.h" +#if BUILDFLAG(USE_COLOR_PIPELINE) +#include "chrome/browser/ui/color/chrome_color_id.h" +#include "ui/color/color_mixer.h" +#include "ui/color/color_provider.h" +#include "ui/color/color_test_ids.h" +#endif + using extensions::Extension; using TP = ThemeProperties; @@ -737,6 +741,7 @@ TEST_F(BrowserThemePackTest, TestNonExistantImages) { EXPECT_FALSE(LoadRawBitmapsTo(out_file_paths)); } +#if BUILDFLAG(USE_COLOR_PIPELINE) TEST_F(BrowserThemePackTest, TestCreateColorMixersOmniboxNoValues) { // Tests to make sure that existing colors within the color provider are not // overwritten or lost in the absence of any user provided theme values. @@ -786,6 +791,7 @@ TEST_F(BrowserThemePackTest, TestCreateColorMixersOmniboxAllValues) { EXPECT_EQ(SkColorSetRGB(120, 140, 160), provider.GetColor(kColorOmniboxBackground)); } +#endif // TODO(erg): This test should actually test more of the built resources from // the extension data, but for now, exists so valgrind can test some of the diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 3e55f83ce61952..2ce4bfa757edd2 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn @@ -1386,7 +1386,6 @@ jumbo_static_library("ui") { "//chrome/browser/resource_coordinator:tab_metrics_event_proto", "//chrome/browser/resource_coordinator/tab_ranker", "//chrome/browser/safe_browsing:advanced_protection", - "//chrome/browser/ui/color:color", "//chrome/browser/ui/webui/app_management:mojo_bindings", "//chrome/common:buildflags", "//chrome/common:search_mojom", @@ -1435,6 +1434,13 @@ jumbo_static_library("ui") { "//google_apis/drive", ] } + + if (use_color_pipeline) { + deps += [ + "//chrome/browser/ui/color:color", + "//chrome/browser/ui/color:mixers", + ] + } } if (enable_supervised_users) { @@ -3291,7 +3297,6 @@ jumbo_static_library("ui") { "webauthn/transport_utils.h", ] deps += [ - "//chrome/browser/ui/color:mixers", "//chrome/browser/ui/views", "//components/constrained_window", "//components/media_message_center", diff --git a/chrome/browser/ui/color/BUILD.gn b/chrome/browser/ui/color/BUILD.gn index 0a9c725ce2bd80..af9c61b8128741 100644 --- a/chrome/browser/ui/color/BUILD.gn +++ b/chrome/browser/ui/color/BUILD.gn @@ -2,6 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//ui/base/ui_features.gni") + +assert(use_color_pipeline) + source_set("color") { sources = [ "chrome_color_id.h", diff --git a/ui/base/ui_features.gni b/ui/base/ui_features.gni index 213fdef1e67aca..d4a71dc3f513c4 100644 --- a/ui/base/ui_features.gni +++ b/ui/base/ui_features.gni @@ -13,6 +13,10 @@ declare_args() { # Whether the message center should be included for displaying notifications. enable_message_center = is_win || is_mac || is_linux + + # Whether to compute UI colors with the color pipeline framework, + # instead of NativeTheme/ThemeService. + use_color_pipeline = false } enable_hidpi = is_mac || is_win || is_linux || is_ios diff --git a/ui/color/BUILD.gn b/ui/color/BUILD.gn index 71b481e7ec2a18..347b28476fea56 100644 --- a/ui/color/BUILD.gn +++ b/ui/color/BUILD.gn @@ -2,8 +2,16 @@ # 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/jumbo.gni") import("//testing/test.gni") +import("//ui/base/ui_features.gni") + +buildflag_header("color_buildflags") { + header = "color_buildflags.h" + + flags = [ "USE_COLOR_PIPELINE=$use_color_pipeline" ] +} jumbo_component("color") { sources = [ @@ -23,6 +31,7 @@ jumbo_component("color") { defines = [ "IS_COLOR_IMPL" ] public_deps = [ + ":color_buildflags", "//base", "//skia", "//ui/gfx:color_utils",