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

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

Issue 1580983002: Fix the dynamic browser action setIcon path to work with any size icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twiddle constant 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 d2ebc0c5092804067f35672fc227e5daed0fdbe7..bd9aa21dd7d5a4bb80e2b7c41d5970ae179a8118 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