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

Unified Diff: chrome/browser/ui/app_list/extension_app_item.cc

Issue 135533006: Round app icon corners for bookmark apps in the launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reattempt_icon_generation
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/extension_app_item.cc
diff --git a/chrome/browser/ui/app_list/extension_app_item.cc b/chrome/browser/ui/app_list/extension_app_item.cc
index 118aba962fea09d099bb9dfa2a7b68fbf0a5921a..5a3f0c256c3e0eb30d3dcbca4dabd191791afea6 100644
--- a/chrome/browser/ui/app_list/extension_app_item.cc
+++ b/chrome/browser/ui/app_list/extension_app_item.cc
@@ -66,6 +66,36 @@ extensions::AppSorting* GetAppSorting(Profile* profile) {
return service->extension_prefs()->app_sorting();
}
+// Returns the given |icon| with rounded corners.
+gfx::ImageSkia GetRoundedIcon(gfx::ImageSkia icon) {
+ // The radius used to round the app icon.
+ const size_t kRoundingRadius = 2;
+
+ scoped_ptr<SkCanvas> canvas(
+ skia::CreateBitmapCanvas(icon.width(), icon.height(), false));
+ DCHECK(canvas);
+ canvas->drawBitmap(*icon.bitmap(), 0, 0);
+
+ scoped_ptr<SkCanvas> masking_canvas(
+ skia::CreateBitmapCanvas(icon.width(), icon.height(), false));
+ DCHECK(masking_canvas);
+
+ SkPaint opaque_paint;
+ opaque_paint.setColor(SK_ColorWHITE);
+ opaque_paint.setFlags(SkPaint::kAntiAlias_Flag);
+ masking_canvas->drawRoundRect(
+ SkRect::MakeWH(icon.width(), icon.height()),
+ kRoundingRadius, kRoundingRadius, opaque_paint);
+
+ SkPaint masking_paint;
+ masking_paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
+ canvas->drawBitmap(
+ masking_canvas->getDevice()->accessBitmap(false), 0, 0, &masking_paint);
+
+ return gfx::ImageSkia::CreateFrom1xBitmap(
+ canvas->getDevice()->accessBitmap(false));
+}
+
const color_utils::HSL shift = {-1, 0, 0.6};
} // namespace
@@ -139,6 +169,9 @@ void ExtensionAppItem::UpdateIcon() {
icon = gfx::ImageSkiaOperations::CreateHSLShiftedImage(icon, shift);
}
+ if (GetExtension()->from_bookmark())
+ icon = GetRoundedIcon(icon);
+
if (HasOverlay())
icon = gfx::ImageSkia(new ShortcutOverlayImageSource(icon), icon.size());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698