Commit acf0da57 authored by Glen Robertson's avatar Glen Robertson Committed by Commit Bot

Tidy up some repetitive casting on bitwise IconEffects operations.

Change-Id: Ie7ceb049a3ad622fe0b3e1c998dd88b7e5de1dbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2358726Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Commit-Queue: Glen Robertson <glenrob@chromium.org>
Auto-Submit: Glen Robertson <glenrob@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798973}
parent 06c431ff
...@@ -327,7 +327,7 @@ base::Optional<IconPurpose> GetIconPurpose( ...@@ -327,7 +327,7 @@ base::Optional<IconPurpose> GetIconPurpose(
} }
return base::nullopt; return base::nullopt;
} // namespace }
// This pipeline is meant to: // This pipeline is meant to:
// * Simplify loading icons, as things like effects and type are common // * Simplify loading icons, as things like effects and type are common
...@@ -540,12 +540,9 @@ void IconLoadingPipeline::LoadWebAppIcon( ...@@ -540,12 +540,9 @@ void IconLoadingPipeline::LoadWebAppIcon(
// safe zone, and clear the standard icon effect, apply the mask to the icon // safe zone, and clear the standard icon effect, apply the mask to the icon
// without shrinking it. // without shrinking it.
if (icon_purpose_to_read.value() == IconPurpose::MASKABLE) { if (icon_purpose_to_read.value() == IconPurpose::MASKABLE) {
icon_effects_ = static_cast<apps::IconEffects>( icon_effects_ &= ~apps::IconEffects::kCrOsStandardIcon;
icon_effects_ & ~apps::IconEffects::kCrOsStandardIcon); icon_effects_ |= apps::IconEffects::kCrOsStandardBackground;
icon_effects_ = static_cast<apps::IconEffects>( icon_effects_ |= apps::IconEffects::kCrOsStandardMask;
icon_effects_ | apps::IconEffects::kCrOsStandardBackground);
icon_effects_ = static_cast<apps::IconEffects>(
icon_effects_ | apps::IconEffects::kCrOsStandardMask);
} }
switch (icon_type_) { switch (icon_type_) {
...@@ -564,15 +561,12 @@ void IconLoadingPipeline::LoadWebAppIcon( ...@@ -564,15 +561,12 @@ void IconLoadingPipeline::LoadWebAppIcon(
case apps::mojom::IconType::kUncompressed: case apps::mojom::IconType::kUncompressed:
if (icon_type_ == apps::mojom::IconType::kUncompressed) { if (icon_type_ == apps::mojom::IconType::kUncompressed) {
// For uncompressed icon, apply the resize and pad effect. // For uncompressed icon, apply the resize and pad effect.
icon_effects_ = static_cast<apps::IconEffects>( icon_effects_ |= apps::IconEffects::kResizeAndPad;
icon_effects_ | apps::IconEffects::kResizeAndPad);
// For uncompressed icon, clear the standard icon effects: kBackground // For uncompressed icon, clear the standard icon effects: kBackground
// and kMask. // and kMask.
icon_effects_ = static_cast<apps::IconEffects>( icon_effects_ &= ~apps::IconEffects::kCrOsStandardBackground;
icon_effects_ & ~apps::IconEffects::kCrOsStandardBackground); icon_effects_ &= ~apps::IconEffects::kCrOsStandardMask;
icon_effects_ = static_cast<apps::IconEffects>(
icon_effects_ & ~apps::IconEffects::kCrOsStandardMask);
} }
FALLTHROUGH; FALLTHROUGH;
case apps::mojom::IconType::kStandard: case apps::mojom::IconType::kStandard:
...@@ -676,8 +670,7 @@ void IconLoadingPipeline::LoadIconFromResource(int icon_resource) { ...@@ -676,8 +670,7 @@ void IconLoadingPipeline::LoadIconFromResource(int icon_resource) {
// //
// For the default icon, use the raw icon, because the standard icon image // For the default icon, use the raw icon, because the standard icon image
// convert could break the test cases. // convert could break the test cases.
icon_effects_ = static_cast<apps::IconEffects>( icon_effects_ &= ~apps::IconEffects::kCrOsStandardIcon;
icon_effects_ & ~apps::IconEffects::kCrOsStandardIcon);
} }
#endif #endif
......
...@@ -54,6 +54,26 @@ enum IconEffects : uint32_t { ...@@ -54,6 +54,26 @@ enum IconEffects : uint32_t {
// and kCrOsStandardMask together. // and kCrOsStandardMask together.
}; };
inline IconEffects operator|(IconEffects a, IconEffects b) {
return static_cast<IconEffects>(static_cast<uint32_t>(a) |
static_cast<uint32_t>(b));
}
inline IconEffects operator|=(IconEffects& a, IconEffects b) {
a = a | b;
return a;
}
inline IconEffects operator&(IconEffects a, uint32_t b) {
return static_cast<IconEffects>(static_cast<uint32_t>(a) &
static_cast<uint32_t>(b));
}
inline IconEffects operator&=(IconEffects& a, uint32_t b) {
a = a & b;
return a;
}
// Returns a callback that converts compressed data to an ImageSkia. // Returns a callback that converts compressed data to an ImageSkia.
base::OnceCallback<void(std::vector<uint8_t> compressed_data)> base::OnceCallback<void(std::vector<uint8_t> compressed_data)>
CompressedDataToImageSkiaCallback( CompressedDataToImageSkiaCallback(
......
...@@ -388,30 +388,23 @@ IconEffects WebAppsChromeOs::GetIconEffects(const web_app::WebApp* web_app, ...@@ -388,30 +388,23 @@ IconEffects WebAppsChromeOs::GetIconEffects(const web_app::WebApp* web_app,
bool is_disabled) { bool is_disabled) {
IconEffects icon_effects = IconEffects::kNone; IconEffects icon_effects = IconEffects::kNone;
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) { if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
icon_effects = web_app->is_generated_icon() icon_effects |= web_app->is_generated_icon()
? static_cast<IconEffects>( ? IconEffects::kCrOsStandardMask
icon_effects | IconEffects::kCrOsStandardMask) : IconEffects::kCrOsStandardIcon;
: static_cast<IconEffects>(
icon_effects | IconEffects::kCrOsStandardIcon);
} else { } else {
icon_effects = icon_effects |= IconEffects::kResizeAndPad;
static_cast<IconEffects>(icon_effects | IconEffects::kResizeAndPad);
} }
if (extensions::util::ShouldApplyChromeBadgeToWebApp(profile(), if (extensions::util::ShouldApplyChromeBadgeToWebApp(profile(),
web_app->app_id())) { web_app->app_id())) {
icon_effects = icon_effects |= IconEffects::kChromeBadge;
static_cast<IconEffects>(icon_effects | IconEffects::kChromeBadge);
} }
icon_effects = static_cast<IconEffects>(icon_effects | icon_effects |= WebAppsBase::GetIconEffects(web_app);
WebAppsBase::GetIconEffects(web_app));
if (paused) { if (paused) {
icon_effects = icon_effects |= IconEffects::kPaused;
static_cast<IconEffects>(icon_effects | IconEffects::kPaused);
} }
if (is_disabled) { if (is_disabled) {
icon_effects = icon_effects |= IconEffects::kBlocked;
static_cast<IconEffects>(icon_effects | IconEffects::kBlocked);
} }
return icon_effects; return icon_effects;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment