Commit eafb44b4 authored by nancylingwang@google.com's avatar nancylingwang@google.com Committed by Commit Bot

Add the kStandard icon type to enum IconCompression.

TODO: Modify IconCompression to IconType. Because IconCompression is
used anywhere, so modify the enum name with a separate CL, so that we
can use the new kStandard anywhere, hidden with the flag in that new
separate CL.

BUG=1083331

Change-Id: I74132ddcfbd2da976e76ec018c9fecf57424d90b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250143
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780158}
parent 4a914f21
...@@ -362,6 +362,8 @@ void IconLoadingPipeline::LoadWebAppIcon( ...@@ -362,6 +362,8 @@ void IconLoadingPipeline::LoadWebAppIcon(
} }
FALLTHROUGH; FALLTHROUGH;
case apps::mojom::IconCompression::kUncompressed: case apps::mojom::IconCompression::kUncompressed:
FALLTHROUGH;
case apps::mojom::IconCompression::kStandard:
// If |icon_effects| are requested, we must always load the // If |icon_effects| are requested, we must always load the
// uncompressed image to apply the icon effects, and then re-encode the // uncompressed image to apply the icon effects, and then re-encode the
// image if the compressed icon is requested. // image if the compressed icon is requested.
...@@ -370,6 +372,10 @@ void IconLoadingPipeline::LoadWebAppIcon( ...@@ -370,6 +372,10 @@ void IconLoadingPipeline::LoadWebAppIcon(
SkBitmapToImageSkiaCallback(base::BindOnce( SkBitmapToImageSkiaCallback(base::BindOnce(
&IconLoadingPipeline::MaybeApplyEffectsAndComplete, &IconLoadingPipeline::MaybeApplyEffectsAndComplete,
base::WrapRefCounted(this)))); base::WrapRefCounted(this))));
// TODO(crbug.com/1083331): For kStandard icons, if the icon is
// generated or maskable, modify the icon effect, don't apply
// kResizeAndPad to shrink the icon.
return; return;
case apps::mojom::IconCompression::kUnknown: case apps::mojom::IconCompression::kUnknown:
break; break;
...@@ -413,6 +419,8 @@ void IconLoadingPipeline::LoadExtensionIcon( ...@@ -413,6 +419,8 @@ void IconLoadingPipeline::LoadExtensionIcon(
} }
FALLTHROUGH; FALLTHROUGH;
case apps::mojom::IconCompression::kUncompressed: case apps::mojom::IconCompression::kUncompressed:
FALLTHROUGH;
case apps::mojom::IconCompression::kStandard:
// If |icon_effects| are requested, we must always load the // If |icon_effects| are requested, we must always load the
// uncompressed image to apply the icon effects, and then re-encode // uncompressed image to apply the icon effects, and then re-encode
// the image if the compressed icon is requested. // the image if the compressed icon is requested.
...@@ -470,7 +478,9 @@ void IconLoadingPipeline::LoadIconFromResource(int icon_resource) { ...@@ -470,7 +478,9 @@ void IconLoadingPipeline::LoadIconFromResource(int icon_resource) {
return; return;
} }
FALLTHROUGH; FALLTHROUGH;
case apps::mojom::IconCompression::kUncompressed: { case apps::mojom::IconCompression::kUncompressed:
FALLTHROUGH;
case apps::mojom::IconCompression::kStandard: {
// For compressed icons with |icon_effects|, or for uncompressed // For compressed icons with |icon_effects|, or for uncompressed
// icons, we load the uncompressed image, apply the icon effects, and // icons, we load the uncompressed image, apply the icon effects, and
// then re-encode the image if necessary. // then re-encode the image if necessary.
...@@ -514,6 +524,11 @@ void IconLoadingPipeline::MaybeApplyEffectsAndComplete( ...@@ -514,6 +524,11 @@ void IconLoadingPipeline::MaybeApplyEffectsAndComplete(
} }
gfx::ImageSkia processed_image = image; gfx::ImageSkia processed_image = image;
// TODO(crbug.com/1083331):
// 1. For kStandard icons, shrink and apply the mask.
// 2. For the default apps, use the raw image, and don't shrink and apply the
// mask.
// Apply the icon effects on the uncompressed data. If the caller requests // Apply the icon effects on the uncompressed data. If the caller requests
// an uncompressed icon, return the uncompressed result; otherwise, encode // an uncompressed icon, return the uncompressed result; otherwise, encode
// the icon to a compressed icon, return the compressed result. // the icon to a compressed icon, return the compressed result.
......
...@@ -80,6 +80,10 @@ void ArcIconOnceLoader::SizeSpecificLoader::LoadIcon( ...@@ -80,6 +80,10 @@ void ArcIconOnceLoader::SizeSpecificLoader::LoadIcon(
case apps::mojom::IconCompression::kCompressed: case apps::mojom::IconCompression::kCompressed:
icon_type = ArcAppIcon::IconType::kCompressed; icon_type = ArcAppIcon::IconType::kCompressed;
break; break;
case apps::mojom::IconCompression::kStandard:
// TODO(crbug.com/1083331): Set icon_type as
// ArcAppIcon::IconType::kTwoLayer.
break;
} }
iter = icons_ iter = icons_
.insert(std::make_pair( .insert(std::make_pair(
......
...@@ -160,9 +160,15 @@ struct IconKey { ...@@ -160,9 +160,15 @@ struct IconKey {
}; };
enum IconCompression { enum IconCompression {
// Sentinel value used in error cases.
kUnknown, kUnknown,
// Icon as an uncompressed gfx::ImageSkia with no standard Chrome OS mask.
kUncompressed, kUncompressed,
// Icon as compressed bytes with no standard Chrome OS mask.
kCompressed, kCompressed,
// Icon as an uncompressed gfx::ImageSkia with the standard Chrome OS mask
// applied. This is the default suggested icon type.
kStandard,
}; };
struct IconValue { struct IconValue {
......
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