Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: chrome/browser/ui/extensions/icon_with_badge_image_source.cc

Issue 1647903003: Fix the dynamic browser action setIcon path to work with any size icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/extensions/icon_with_badge_image_source.cc
diff --git a/chrome/browser/ui/extensions/icon_with_badge_image_source.cc b/chrome/browser/ui/extensions/icon_with_badge_image_source.cc
index 322dcce754393993d52697e5b51d0e816e847550..71609344f7cd01787f60168eb7b998e16cd1d323 100644
--- a/chrome/browser/ui/extensions/icon_with_badge_image_source.cc
+++ b/chrome/browser/ui/extensions/icon_with_badge_image_source.cc
@@ -90,14 +90,13 @@ SkPaint* GetBadgeTextPaintSingleton() {
}
gfx::ImageSkiaRep ScaleImageSkiaRep(const gfx::ImageSkiaRep& rep,
+ int target_width,
float target_scale) {
- gfx::Size scaled_size =
- gfx::ScaleToCeiledSize(rep.pixel_size(), target_scale / rep.scale());
- return gfx::ImageSkiaRep(skia::ImageOperations::Resize(
- rep.sk_bitmap(),
- skia::ImageOperations::RESIZE_BEST,
- scaled_size.width(),
- scaled_size.height()), target_scale);
+ return gfx::ImageSkiaRep(
+ skia::ImageOperations::Resize(rep.sk_bitmap(),
+ skia::ImageOperations::RESIZE_BEST,
+ target_width, target_width),
+ target_scale);
}
} // namespace
@@ -129,11 +128,10 @@ void IconWithBadgeImageSource::Draw(gfx::Canvas* canvas) {
return;
gfx::ImageSkia skia = icon_.AsImageSkia();
- // TODO(estade): Fix setIcon and enable this on !MD.
- if (ui::MaterialDesignController::IsModeMaterial()) {
- gfx::ImageSkiaRep rep = skia.GetRepresentation(canvas->image_scale());
- if (rep.scale() != canvas->image_scale())
- skia.AddRepresentation(ScaleImageSkiaRep(rep, canvas->image_scale()));
+ gfx::ImageSkiaRep rep = skia.GetRepresentation(canvas->image_scale());
+ if (rep.scale() != canvas->image_scale()) {
+ skia.AddRepresentation(
+ ScaleImageSkiaRep(rep, skia.width(), canvas->image_scale()));
}
if (grayscale_)
skia = gfx::ImageSkiaOperations::CreateHSLShiftedImage(skia, {-1, 0, 0.6});
« no previous file with comments | « chrome/browser/extensions/extension_action.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_action_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698