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

Side by Side Diff: trunk/src/chrome/browser/profiles/profile_shortcut_manager_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_shortcut_manager_win.h" 5 #include "chrome/browser/profiles/profile_shortcut_manager_win.h"
6 6
7 #include <shlobj.h> // For SHChangeNotify(). 7 #include <shlobj.h> // For SHChangeNotify().
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 IDR_PROFILE_AVATAR_2X_16, 96 IDR_PROFILE_AVATAR_2X_16,
97 IDR_PROFILE_AVATAR_2X_17, 97 IDR_PROFILE_AVATAR_2X_17,
98 IDR_PROFILE_AVATAR_2X_18, 98 IDR_PROFILE_AVATAR_2X_18,
99 IDR_PROFILE_AVATAR_2X_19, 99 IDR_PROFILE_AVATAR_2X_19,
100 IDR_PROFILE_AVATAR_2X_20, 100 IDR_PROFILE_AVATAR_2X_20,
101 IDR_PROFILE_AVATAR_2X_21, 101 IDR_PROFILE_AVATAR_2X_21,
102 IDR_PROFILE_AVATAR_2X_22, 102 IDR_PROFILE_AVATAR_2X_22,
103 IDR_PROFILE_AVATAR_2X_23, 103 IDR_PROFILE_AVATAR_2X_23,
104 IDR_PROFILE_AVATAR_2X_24, 104 IDR_PROFILE_AVATAR_2X_24,
105 IDR_PROFILE_AVATAR_2X_25, 105 IDR_PROFILE_AVATAR_2X_25,
106 IDR_PROFILE_AVATAR_2X_26,
107 }; 106 };
108 107
109 // Badges |app_icon_bitmap| with |avatar_bitmap| at the bottom right corner and 108 // Badges |app_icon_bitmap| with |avatar_bitmap| at the bottom right corner and
110 // returns the resulting SkBitmap. 109 // returns the resulting SkBitmap.
111 SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap, 110 SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap,
112 const SkBitmap& avatar_bitmap, 111 const SkBitmap& avatar_bitmap,
113 int scale_factor) { 112 int scale_factor) {
114 // All icons, whether cartoon, GAIA or placeholder, should be square. 113 // TODO(rlp): Share this chunk of code with
115 DLOG_ASSERT(avatar_bitmap.width() == avatar_bitmap.height()); 114 // avatar_menu_button::DrawTaskBarDecoration.
116 115 SkBitmap source_bitmap = avatar_bitmap;
116 if ((avatar_bitmap.width() == scale_factor * profiles::kAvatarIconWidth) &&
117 (avatar_bitmap.height() == scale_factor * profiles::kAvatarIconHeight)) {
118 // Shave a couple of columns so the bitmap is more square. So when
119 // resized to a square aspect ratio it looks pretty.
120 gfx::Rect frame(scale_factor * profiles::kAvatarIconWidth,
121 scale_factor * profiles::kAvatarIconHeight);
122 frame.Inset(scale_factor * 2, 0, scale_factor * 2, 0);
123 avatar_bitmap.extractSubset(&source_bitmap, gfx::RectToSkIRect(frame));
124 } else {
125 NOTREACHED();
126 }
117 int avatar_badge_size = kProfileAvatarBadgeSize; 127 int avatar_badge_size = kProfileAvatarBadgeSize;
118 if (app_icon_bitmap.width() != kShortcutIconSize) { 128 if (app_icon_bitmap.width() != kShortcutIconSize) {
119 avatar_badge_size = 129 avatar_badge_size =
120 app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize; 130 app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize;
121 } 131 }
122 SkBitmap sk_icon = skia::ImageOperations::Resize( 132 SkBitmap sk_icon = skia::ImageOperations::Resize(
123 avatar_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size, 133 source_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size,
124 avatar_bitmap.height() * avatar_badge_size / avatar_bitmap.width()); 134 source_bitmap.height() * avatar_badge_size / source_bitmap.width());
125 135
126 // Overlay the avatar on the icon, anchoring it to the bottom-right of the 136 // Overlay the avatar on the icon, anchoring it to the bottom-right of the
127 // icon. 137 // icon.
128 SkBitmap badged_bitmap; 138 SkBitmap badged_bitmap;
129 badged_bitmap.allocN32Pixels(app_icon_bitmap.width(), 139 badged_bitmap.allocN32Pixels(app_icon_bitmap.width(),
130 app_icon_bitmap.height()); 140 app_icon_bitmap.height());
131 SkCanvas offscreen_canvas(badged_bitmap); 141 SkCanvas offscreen_canvas(badged_bitmap);
132 offscreen_canvas.clear(SK_ColorTRANSPARENT); 142 offscreen_canvas.clear(SK_ColorTRANSPARENT);
133 143
134 offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0); 144 offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0);
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // Ensure the profile's icon file has been created. 852 // Ensure the profile's icon file has been created.
843 CreateOrUpdateProfileIcon(profile->GetPath()); 853 CreateOrUpdateProfileIcon(profile->GetPath());
844 } 854 }
845 break; 855 break;
846 } 856 }
847 default: 857 default:
848 NOTREACHED(); 858 NOTREACHED();
849 break; 859 break;
850 } 860 }
851 } 861 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/profiles/profile_metrics.cc ('k') | trunk/src/chrome/browser/profiles/profile_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698