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

Unified Diff: chrome/browser/profiles/profile_shortcut_manager_win.cc

Issue 268073005: Bring back support for 38x31 avatars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/profiles/profile_shortcut_manager_win.cc
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc
index 721a73482d5201575e6122b1d1ca6fb182d78d3d..8cfd37c9d92e4779bd8d31406fabcd380eafa012 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -111,9 +111,21 @@ const int kProfileAvatarIconResources2x[] = {
SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap,
const SkBitmap& avatar_bitmap,
int scale_factor) {
- // All icons, whether cartoon, GAIA or placeholder, should be square.
- // TODO(mlerman) - uncomment the ASSERT once noms@ lands the square images.
- // DCHECK(avatar_bitmap.width() == avatar_bitmap.height());
+ // TODO(rlp): Share this chunk of code with
+ // avatar_menu_button::DrawTaskBarDecoration.
noms (inactive) 2014/05/05 16:10:53 Can we address this TODO? Maybe move the function
Mike Lerman 2014/05/06 12:43:15 Done, refactored the code into profile_avatar_icon
+ SkBitmap source_bitmap = avatar_bitmap;
+ if ((avatar_bitmap.width() == scale_factor * profiles::kAvatarIconWidth) &&
+ (avatar_bitmap.height() == scale_factor * profiles::kAvatarIconHeight)) {
+ // Shave a couple of columns so the bitmap is more square. So when
+ // resized to a square aspect ratio it looks pretty.
+ gfx::Rect frame(scale_factor * profiles::kAvatarIconWidth,
+ scale_factor * profiles::kAvatarIconHeight);
+ frame.Inset(scale_factor * 2, 0, scale_factor * 2, 0);
+ avatar_bitmap.extractSubset(&source_bitmap, gfx::RectToSkIRect(frame));
+ } else {
+ // If not the icon's aspect ratio, the image should be square.
+ DCHECK(avatar_bitmap.width() == avatar_bitmap.height());
+ }
int avatar_badge_size = kProfileAvatarBadgeSize;
if (app_icon_bitmap.width() != kShortcutIconSize) {
@@ -121,8 +133,8 @@ SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap,
app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize;
}
SkBitmap sk_icon = skia::ImageOperations::Resize(
- avatar_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size,
- avatar_bitmap.height() * avatar_badge_size / avatar_bitmap.width());
+ source_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size,
+ source_bitmap.height() * avatar_badge_size / source_bitmap.width());
// Overlay the avatar on the icon, anchoring it to the bottom-right of the
// icon.
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.cc ('k') | chrome/browser/resources/options/browser_options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698