| OLD | NEW |
| 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 Loading... |
| 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, |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 // Badges |app_icon_bitmap| with |avatar_bitmap| at the bottom right corner and | 109 // Badges |app_icon_bitmap| with |avatar_bitmap| at the bottom right corner and |
| 109 // returns the resulting SkBitmap. | 110 // returns the resulting SkBitmap. |
| 110 SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap, | 111 SkBitmap BadgeIcon(const SkBitmap& app_icon_bitmap, |
| 111 const SkBitmap& avatar_bitmap, | 112 const SkBitmap& avatar_bitmap, |
| 112 int scale_factor) { | 113 int scale_factor) { |
| 113 // TODO(rlp): Share this chunk of code with | 114 // All icons, whether cartoon, GAIA or placeholder, should be square. |
| 114 // avatar_menu_button::DrawTaskBarDecoration. | 115 // TODO(mlerman) - uncomment the ASSERT once noms@ lands the square images. |
| 115 SkBitmap source_bitmap = avatar_bitmap; | 116 // DCHECK(avatar_bitmap.width() == avatar_bitmap.height()); |
| 116 if ((avatar_bitmap.width() == scale_factor * profiles::kAvatarIconWidth) && | 117 |
| 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 } | |
| 127 int avatar_badge_size = kProfileAvatarBadgeSize; | 118 int avatar_badge_size = kProfileAvatarBadgeSize; |
| 128 if (app_icon_bitmap.width() != kShortcutIconSize) { | 119 if (app_icon_bitmap.width() != kShortcutIconSize) { |
| 129 avatar_badge_size = | 120 avatar_badge_size = |
| 130 app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize; | 121 app_icon_bitmap.width() * kProfileAvatarBadgeSize / kShortcutIconSize; |
| 131 } | 122 } |
| 132 SkBitmap sk_icon = skia::ImageOperations::Resize( | 123 SkBitmap sk_icon = skia::ImageOperations::Resize( |
| 133 source_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size, | 124 avatar_bitmap, skia::ImageOperations::RESIZE_LANCZOS3, avatar_badge_size, |
| 134 source_bitmap.height() * avatar_badge_size / source_bitmap.width()); | 125 avatar_bitmap.height() * avatar_badge_size / avatar_bitmap.width()); |
| 135 | 126 |
| 136 // Overlay the avatar on the icon, anchoring it to the bottom-right of the | 127 // Overlay the avatar on the icon, anchoring it to the bottom-right of the |
| 137 // icon. | 128 // icon. |
| 138 SkBitmap badged_bitmap; | 129 SkBitmap badged_bitmap; |
| 139 badged_bitmap.allocN32Pixels(app_icon_bitmap.width(), | 130 badged_bitmap.allocN32Pixels(app_icon_bitmap.width(), |
| 140 app_icon_bitmap.height()); | 131 app_icon_bitmap.height()); |
| 141 SkCanvas offscreen_canvas(badged_bitmap); | 132 SkCanvas offscreen_canvas(badged_bitmap); |
| 142 offscreen_canvas.clear(SK_ColorTRANSPARENT); | 133 offscreen_canvas.clear(SK_ColorTRANSPARENT); |
| 143 | 134 |
| 144 offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0); | 135 offscreen_canvas.drawBitmap(app_icon_bitmap, 0, 0); |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 // Ensure the profile's icon file has been created. | 843 // Ensure the profile's icon file has been created. |
| 853 CreateOrUpdateProfileIcon(profile->GetPath()); | 844 CreateOrUpdateProfileIcon(profile->GetPath()); |
| 854 } | 845 } |
| 855 break; | 846 break; |
| 856 } | 847 } |
| 857 default: | 848 default: |
| 858 NOTREACHED(); | 849 NOTREACHED(); |
| 859 break; | 850 break; |
| 860 } | 851 } |
| 861 } | 852 } |
| OLD | NEW |