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

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: mac compatible image equality check 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..b773b6efccb8196b66d152f97caaa03010652423 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),
varkha 2016/01/20 21:22:23 Is it OK to use |target_width| for both dest_width
Evan Stade 2016/01/21 19:38:54 The images *should* always be square. The API allo
+ target_scale);
}
} // namespace
@@ -129,14 +128,13 @@ 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()));
- }
- if (grayscale_)
+ 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_) {
Devlin 2016/01/19 22:44:40 this if should go on a newline.
Evan Stade 2016/01/20 23:04:36 Done.
skia = gfx::ImageSkiaOperations::CreateHSLShiftedImage(skia, {-1, 0, 0.6});
+ }
int x_offset = std::floor((size().width() - icon_.Width()) / 2.0);
int y_offset = std::floor((size().height() - icon_.Height()) / 2.0);

Powered by Google App Engine
This is Rietveld 408576698