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

Unified Diff: chrome/browser/app_icon_win.cc

Issue 1408063012: Replaced GetAppIconForSize with GetAppIconImageFamily. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master-plus
Patch Set: Split off ImageFamily stuff into CL 1424913007. Created 5 years, 1 month 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 | « chrome/browser/app_icon_win.h ('k') | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_icon_win.cc
diff --git a/chrome/browser/app_icon_win.cc b/chrome/browser/app_icon_win.cc
index 6f1424e4977b5c54e3ad1045be78dc010264c421..1fbd70726b60b3129ec1307379adc921409aaddf 100644
--- a/chrome/browser/app_icon_win.cc
+++ b/chrome/browser/app_icon_win.cc
@@ -7,7 +7,9 @@
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/chrome_constants.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/geometry/size.h"
#include "ui/gfx/icon_util.h"
+#include "ui/gfx/image/image_family.h"
#if defined(GOOGLE_CHROME_BUILD)
#include "chrome/installer/util/install_util.h"
@@ -28,6 +30,8 @@ int GetAppIconResourceId() {
} // namespace
HICON GetAppIcon() {
+ // TODO(mgiuca): Use GetAppIconForSize instead of LoadIcon, to get correct
+ // scaling. (See http://crbug.com/551256)
const int icon_id = GetAppIconResourceId();
// HICON returned from LoadIcon do not leak and do not have to be destroyed.
return LoadIcon(GetModuleHandle(chrome::kBrowserResourcesDll),
@@ -35,16 +39,43 @@ HICON GetAppIcon() {
}
HICON GetSmallAppIcon() {
+ // TODO(mgiuca): Use GetAppIconForSize instead of LoadImage, to get correct
+ // scaling. (See http://crbug.com/551256)
const int icon_id = GetAppIconResourceId();
+ gfx::Size size = GetSmallAppIconSize();
// HICON returned from LoadImage must be released using DestroyIcon.
return static_cast<HICON>(LoadImage(
GetModuleHandle(chrome::kBrowserResourcesDll), MAKEINTRESOURCE(icon_id),
- IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTCOLOR | LR_SHARED));
+ IMAGE_ICON, size.width(), size.height(), LR_DEFAULTCOLOR | LR_SHARED));
}
-scoped_ptr<SkBitmap> GetAppIconForSize(int size) {
+gfx::Size GetAppIconSize() {
+ return gfx::Size(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
+}
+
+gfx::Size GetSmallAppIconSize() {
+ return gfx::Size(GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON));
+}
+
+scoped_ptr<gfx::ImageFamily> GetAppIconImageFamily() {
const int icon_id = GetAppIconResourceId();
- return IconUtil::CreateSkBitmapFromIconResource(
- GetModuleHandle(chrome::kBrowserResourcesDll), icon_id, size);
+ return IconUtil::CreateImageFamilyFromIconResource(
+ GetModuleHandle(chrome::kBrowserResourcesDll), icon_id);
+}
+
+scoped_ptr<SkBitmap> GetAppIconForSize(const gfx::Size& size) {
+ scoped_ptr<gfx::ImageFamily> family = GetAppIconImageFamily();
+ if (!family)
+ return make_scoped_ptr(new SkBitmap);
calamity 2015/11/09 02:12:11 nit: Why not just return an empty scoped_ptr?
Matt Giuca 2015/11/10 06:56:53 Done.
+
+ // Note: We could just use the LoadImage function from the Windows API, but
+ // that does a *terrible* job scaling images. Therefore, we fetch the original
+ // images and do our own high-quality scaling.
+ gfx::Image image = family->CreateExact(size);
+ return make_scoped_ptr(new SkBitmap(image.AsBitmap()));
+}
+
+scoped_ptr<SkBitmap> GetAppIconForSize(int size) {
+ return GetAppIconForSize(gfx::Size(size, size));
}
« no previous file with comments | « chrome/browser/app_icon_win.h ('k') | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698