Skip to content

Commit

Permalink
Port ImageModel and ThemedVectorImage to color pipeline.
Browse files Browse the repository at this point in the history
Bug: 1249645
Change-Id: I897f36cdf9f3cd95cc1fba56b058c49d3b75315d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3170344
Reviewed-by: David Trainor <dtrainor@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#923899}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Sep 22, 2021
1 parent 6d310e5 commit 618a92e
Show file tree
Hide file tree
Showing 76 changed files with 281 additions and 256 deletions.
2 changes: 1 addition & 1 deletion ash/app_list/views/search_result_tile_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void SearchResultTileItemView::SetBadgeIcon(const ui::ImageModel& badge_icon,
}

gfx::ImageSkia badge_icon_skia =
views::GetImageSkiaFromImageModel(badge_icon, GetNativeTheme());
views::GetImageSkiaFromImageModel(badge_icon, GetColorProvider());

if (use_badge_icon_background) {
badge_icon_skia =
Expand Down
2 changes: 1 addition & 1 deletion ash/app_list/views/search_result_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ void SearchResultView::OnMetadataChanged() {
if (result() && !result()->badge_icon().IsEmpty()) {
const ui::ImageModel& badge_icon = result()->badge_icon();
gfx::ImageSkia badge_icon_skia =
views::GetImageSkiaFromImageModel(badge_icon, GetNativeTheme());
views::GetImageSkiaFromImageModel(badge_icon, GetColorProvider());

if (result()->use_badge_icon_background())
badge_icon_skia =
Expand Down
5 changes: 3 additions & 2 deletions ash/system/holding_space/holding_space_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/paint_vector_icon.h"
Expand Down Expand Up @@ -517,14 +518,14 @@ HoldingSpaceTray::CreateContextMenuModel() {
static_cast<int>(HoldingSpaceCommandId::kHidePreviews),
l10n_util::GetStringUTF16(
IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_HIDE_PREVIEWS),
ui::ImageModel::FromVectorIcon(kVisibilityOffIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kVisibilityOffIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
} else {
context_menu_model->AddItemWithIcon(
static_cast<int>(HoldingSpaceCommandId::kShowPreviews),
l10n_util::GetStringUTF16(
IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_SHOW_PREVIEWS),
ui::ImageModel::FromVectorIcon(kVisibilityIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kVisibilityIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}

Expand Down
18 changes: 10 additions & 8 deletions ash/system/holding_space/holding_space_view_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/color/color_id.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/vector_icons.h"
#include "ui/views/view.h"
Expand Down Expand Up @@ -601,23 +602,23 @@ ui::SimpleMenuModel* HoldingSpaceViewDelegate::BuildMenuModel() {
context_menu_model_->AddItemWithIcon(
static_cast<int>(HoldingSpaceCommandId::kPauseItem),
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_PAUSE),
ui::ImageModel::FromVectorIcon(kPauseIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kPauseIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}

if (is_resumable) {
context_menu_model_->AddItemWithIcon(
static_cast<int>(HoldingSpaceCommandId::kResumeItem),
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_RESUME),
ui::ImageModel::FromVectorIcon(kResumeIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kResumeIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}

if (is_cancelable) {
context_menu_model_->AddItemWithIcon(
static_cast<int>(HoldingSpaceCommandId::kCancelItem),
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_CANCEL),
ui::ImageModel::FromVectorIcon(kCancelIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kCancelIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}

Expand All @@ -632,7 +633,7 @@ ui::SimpleMenuModel* HoldingSpaceViewDelegate::BuildMenuModel() {
static_cast<int>(HoldingSpaceCommandId::kShowInFolder),
l10n_util::GetStringUTF16(
IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_SHOW_IN_FOLDER),
ui::ImageModel::FromVectorIcon(kFolderIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kFolderIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));

std::string mime_type;
Expand All @@ -648,7 +649,7 @@ ui::SimpleMenuModel* HoldingSpaceViewDelegate::BuildMenuModel() {
static_cast<int>(HoldingSpaceCommandId::kCopyImageToClipboard),
l10n_util::GetStringUTF16(
IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_COPY_IMAGE_TO_CLIPBOARD),
ui::ImageModel::FromVectorIcon(kCopyIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(kCopyIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}
}
Expand All @@ -658,13 +659,13 @@ ui::SimpleMenuModel* HoldingSpaceViewDelegate::BuildMenuModel() {
context_menu_model_->AddItemWithIcon(
static_cast<int>(HoldingSpaceCommandId::kPinItem),
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_PIN),
ui::ImageModel::FromVectorIcon(views::kPinIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(views::kPinIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
} else {
context_menu_model_->AddItemWithIcon(
static_cast<int>(HoldingSpaceCommandId::kUnpinItem),
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_UNPIN),
ui::ImageModel::FromVectorIcon(views::kUnpinIcon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(views::kUnpinIcon, ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}
}
Expand All @@ -674,7 +675,8 @@ ui::SimpleMenuModel* HoldingSpaceViewDelegate::BuildMenuModel() {
static_cast<int>(HoldingSpaceCommandId::kRemoveItem),
l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_CONTEXT_MENU_REMOVE),
ui::ImageModel::FromVectorIcon(kCancelCircleOutlineIcon,
/*color_id=*/-1, kHoldingSpaceIconSize));
ui::kColorMenuIcon,
kHoldingSpaceIconSize));
}

return context_menu_model_.get();
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/apps/app_service/menu_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "content/public/common/content_features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/vector_icon_types.h"

Expand Down Expand Up @@ -171,7 +172,7 @@ bool PopulateNewItemFromMojoMenuItems(
std::move(get_vector_icon).Run(item->command_id, item->string_id);
model->AddItemWithStringIdAndIcon(
item->command_id, item->string_id,
ui::ImageModel::FromVectorIcon(icon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(icon, ui::kColorMenuIcon,
ash::kAppContextMenuIconSize));
break;
}
Expand All @@ -182,7 +183,7 @@ bool PopulateNewItemFromMojoMenuItems(
std::move(get_vector_icon).Run(item->command_id, item->string_id);
model->AddActionableSubmenuWithStringIdAndIcon(
item->command_id, item->string_id, submenu,
ui::ImageModel::FromVectorIcon(icon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(icon, ui::kColorMenuIcon,
ash::kAppContextMenuIconSize));
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/models/image_model.h"
#include "ui/base/window_open_disposition.h"
#include "ui/color/color_id.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/native_theme/native_theme.h"
#include "url/gurl.h"

using content::WebContents;
Expand Down Expand Up @@ -68,8 +68,7 @@ ui::ImageModel CreateDeviceIcon(
const gfx::VectorIcon& icon = device_type == sync_pb::SyncEnums::TYPE_TABLET
? kTabletIcon
: kHardwareSmartphoneIcon;
return ui::ImageModel::FromVectorIcon(
icon, ui::NativeTheme::kColorId_DefaultIconColor, kDeviceIconSize);
return ui::ImageModel::FromVectorIcon(icon, ui::kColorIcon, kDeviceIconSize);
}

// Adds |devices| to |picker_entries| and returns the new list. The devices are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/image_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_id.h"
#include "ui/events/event.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
Expand Down Expand Up @@ -187,8 +188,7 @@ void RequestSystemProxyCredentialsView::Init() {
auto error_icon = std::make_unique<views::ImageView>();
const int kIconSize = 18;
error_icon->SetImage(ui::ImageModel::FromVectorIcon(
vector_icons::kInfoOutlineIcon,
ui::NativeTheme::kColorId_AlertSeverityHigh, kIconSize));
vector_icons::kInfoOutlineIcon, ui::kColorAlertHighSeverity, kIconSize));
error_icon->SetImageSize(gfx::Size(kIconSize, kIconSize));
error_icon->SetVisible(show_error_label_);
layout->AddView(std::move(error_icon));
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/profiles/profile_avatar_icon_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/color/color_id.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/favicon_size.h"
Expand All @@ -46,7 +47,6 @@
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/native_theme.h"
#include "url/url_canon.h"

#if defined(OS_WIN)
Expand Down Expand Up @@ -367,9 +367,8 @@ constexpr size_t kPlaceholderAvatarIndex = 0;
#endif

ui::ImageModel GetGuestAvatar(int size) {
return ui::ImageModel::FromVectorIcon(
kUserAccountAvatarIcon, ui::NativeTheme::kColorId_AvatarIconGuest,
size);
return ui::ImageModel::FromVectorIcon(kUserAccountAvatarIcon,
ui::kColorAvatarIconGuest, size);
}

gfx::Image GetSizedAvatarIcon(const gfx::Image& image,
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/recovery/recovery_install_global_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "components/prefs/pref_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/native_theme/native_theme.h"
#include "ui/color/color_id.h"

RecoveryInstallGlobalError::RecoveryInstallGlobalError(Profile* profile)
: elevation_needed_(false),
Expand Down Expand Up @@ -69,8 +69,8 @@ std::u16string RecoveryInstallGlobalError::MenuItemLabel() {
}

ui::ImageModel RecoveryInstallGlobalError::MenuItemIcon() {
return ui::ImageModel::FromVectorIcon(
kBrowserToolsUpdateIcon, ui::NativeTheme::kColorId_AlertSeverityHigh);
return ui::ImageModel::FromVectorIcon(kBrowserToolsUpdateIcon,
ui::kColorAlertHighSeverity);
}

void RecoveryInstallGlobalError::ExecuteMenuItem(Browser* browser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "components/sync_device_info/device_info.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"

Expand Down Expand Up @@ -78,7 +79,7 @@ void ClickToCallContextMenuObserver::BuildMenu(
IDS_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE,
base::UTF8ToUTF16(devices_[0]->client_name())),
ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::kColorMenuIcon,
ui::SimpleMenuModel::kDefaultIconSize));
#endif
} else {
Expand All @@ -95,7 +96,7 @@ void ClickToCallContextMenuObserver::BuildMenu(
IDS_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_MULTIPLE_DEVICES,
sub_menu_model_.get(),
ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::kColorMenuIcon,
ui::SimpleMenuModel::kDefaultIconSize));
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "components/sync_device_info/device_info.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"

Expand Down Expand Up @@ -75,7 +76,7 @@ void SharedClipboardContextMenuObserver::InitMenu(
IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE,
base::UTF8ToUTF16(devices_[0]->client_name())),
ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::kColorMenuIcon,
ui::SimpleMenuModel::kDefaultIconSize));
#endif
} else {
Expand All @@ -92,7 +93,7 @@ void SharedClipboardContextMenuObserver::InitMenu(
IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES,
sub_menu_model_.get(),
ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::kColorMenuIcon,
ui::SimpleMenuModel::kDefaultIconSize));
#endif
}
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ui/app_list/app_context_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "chrome/grit/generated_resources.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/color/color_id.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/views/vector_icons.h"
Expand Down Expand Up @@ -75,7 +76,7 @@ ui::ImageModel AppContextMenu::GetIconForCommandId(int command_id) const {
GetMenuItemVectorIcon(command_id, controller_->IsAppPinned(app_id_)
? IDS_APP_LIST_CONTEXT_MENU_UNPIN
: IDS_APP_LIST_CONTEXT_MENU_PIN);
return ui::ImageModel::FromVectorIcon(icon, /*color_id=*/-1,
return ui::ImageModel::FromVectorIcon(icon, ui::kColorMenuIcon,
ash::kAppContextMenuIconSize);
}

Expand Down Expand Up @@ -158,7 +159,7 @@ void AppContextMenu::AddContextMenuOption(ui::SimpleMenuModel* menu_model,
if (!icon.is_empty()) {
menu_model->AddItemWithStringIdAndIcon(
command_id, string_id,
ui::ImageModel::FromVectorIcon(icon, /*color_id=*/-1,
ui::ImageModel::FromVectorIcon(icon, ui::kColorMenuIcon,
ash::kAppContextMenuIconSize));
return;
}
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/ui/app_list/extension_app_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/vector_icons.h"
Expand All @@ -38,10 +39,9 @@ void AddMenuItemIconsForSystemApps(const std::string& app_id,
const int index = start_index + i;
if (menu_model->GetLabelAt(index) ==
l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_NEW_WINDOW)) {
menu_model->SetIcon(
index, ui::ImageModel::FromVectorIcon(views::kNewWindowIcon,
/*color_id=*/-1,
ash::kAppContextMenuIconSize));
menu_model->SetIcon(index, ui::ImageModel::FromVectorIcon(
views::kNewWindowIcon, ui::kColorMenuIcon,
ash::kAppContextMenuIconSize));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include "chromeos/ui/vector_icons/vector_icons.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/native_theme/native_theme.h"

namespace app_list {

Expand Down Expand Up @@ -64,8 +64,7 @@ ArcAppReinstallAppResult::ArcAppReinstallAppResult(
SetIcon(IconInfo(masked_app_icon));
SetChipIcon(masked_app_icon);
SetBadgeIcon(ui::ImageModel::FromVectorIcon(
vector_icons::kCloudDownloadIcon,
ui::NativeTheme::kColorId_DefaultIconColor,
vector_icons::kCloudDownloadIcon, ui::kColorIcon,
ash::SharedAppListConfig::instance().search_tile_badge_icon_dimension()));
SetUseBadgeIconBackground(true);
SetNotifyVisibilityChange(true);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/sharesheet/sharesheet_target_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "chrome/browser/ui/ash/sharesheet/sharesheet_constants.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/gfx/font_list.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/layout/box_layout.h"
Expand All @@ -38,8 +39,7 @@ std::unique_ptr<views::ImageView> CreateImageView(
return image;
} else if (vector_icon != nullptr) {
return std::make_unique<views::ImageView>(ui::ImageModel::FromVectorIcon(
*vector_icon, ui::NativeTheme::kColorId_DefaultIconColor,
sharesheet::kIconSize));
*vector_icon, ui::kColorIcon, sharesheet::kIconSize));
}
NOTREACHED();
return nullptr;
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ui/ash/shelf/extension_shelf_context_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "content/public/browser/context_menu_params.h"
#include "extensions/browser/extension_prefs.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_id.h"
#include "ui/display/scoped_display_for_new_windows.h"
#include "ui/display/screen.h"
#include "ui/gfx/paint_vector_icon.h"
Expand Down Expand Up @@ -209,7 +210,7 @@ void ExtensionShelfContextMenu::CreateOpenNewSubmenu(
open_new_submenu_model_.get(),
ui::ImageModel::FromVectorIcon(
GetCommandIdVectorIcon(ash::MENU_OPEN_NEW, GetLaunchTypeStringId()),
/*color_id=*/-1, ash::kAppContextMenuIconSize));
ui::kColorMenuIcon, ash::kAppContextMenuIconSize));
}

extensions::LaunchType ExtensionShelfContextMenu::GetLaunchType() const {
Expand Down
Loading

0 comments on commit 618a92e

Please sign in to comment.