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

Unified Diff: trunk/src/chrome/browser/ui/views/frame/taskbar_decorator_win.cc

Issue 234583008: Revert 263262 "Newly created profiles should have the grey silho..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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: trunk/src/chrome/browser/ui/views/frame/taskbar_decorator_win.cc
===================================================================
--- trunk/src/chrome/browser/ui/views/frame/taskbar_decorator_win.cc (revision 263283)
+++ trunk/src/chrome/browser/ui/views/frame/taskbar_decorator_win.cc (working copy)
@@ -43,15 +43,32 @@
base::win::ScopedGDIObject<HICON> icon;
if (bitmap.get()) {
+ const SkBitmap* source_bitmap = NULL;
+ SkBitmap squarer_bitmap;
+ if ((bitmap->width() == profiles::kAvatarIconWidth) &&
+ (bitmap->height() == profiles::kAvatarIconHeight)) {
+ // Shave a couple of columns so the bitmap is more square. So when
+ // resized to a square aspect ratio it looks pretty.
+ int x = 2;
+ bitmap->extractSubset(&squarer_bitmap, SkIRect::MakeXYWH(x, 0,
+ profiles::kAvatarIconWidth - x * 2, profiles::kAvatarIconHeight));
+ source_bitmap = &squarer_bitmap;
+ } else {
+ // The image's size has changed. Resize what we have.
+ source_bitmap = bitmap.get();
+ }
+
+ // Maintain aspect ratio on resize. It is assumed that the image is wider
+ // than it is tall.
const size_t kOverlayIconSize = 16;
- const SkBitmap* source_bitmap = bitmap.get();
-
- // Maintain aspect ratio on resize. Image is assumed to be square.
+ size_t resized_height =
+ source_bitmap->height() * kOverlayIconSize / source_bitmap->width();
+ DCHECK_GE(kOverlayIconSize, resized_height);
// Since the target size is so small, we use our best resizer.
SkBitmap sk_icon = skia::ImageOperations::Resize(
*source_bitmap,
skia::ImageOperations::RESIZE_LANCZOS3,
- kOverlayIconSize, kOverlayIconSize);
+ kOverlayIconSize, resized_height);
// Paint the resized icon onto a 16x16 canvas otherwise Windows will badly
// hammer it to 16x16.
@@ -59,7 +76,7 @@
offscreen_bitmap.allocN32Pixels(kOverlayIconSize, kOverlayIconSize);
SkCanvas offscreen_canvas(offscreen_bitmap);
offscreen_canvas.clear(SK_ColorTRANSPARENT);
- offscreen_canvas.drawBitmap(sk_icon, 0, 0);
+ offscreen_canvas.drawBitmap(sk_icon, 0, kOverlayIconSize - resized_height);
icon.Set(IconUtil::CreateHICONFromSkBitmap(offscreen_bitmap));
if (!icon.Get())

Powered by Google App Engine
This is Rietveld 408576698