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

Unified Diff: chrome/browser/ui/views/elevation_icon_setter.cc

Issue 849543003: Make elevation icon size correct in different DPI settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comment Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/elevation_icon_setter.cc
diff --git a/chrome/browser/ui/views/elevation_icon_setter.cc b/chrome/browser/ui/views/elevation_icon_setter.cc
index 99912883269f0eaf945133d24f2ba5d8491f0759..ccffcbe689cba7373154f52e96654470267f9b5a 100644
--- a/chrome/browser/ui/views/elevation_icon_setter.cc
+++ b/chrome/browser/ui/views/elevation_icon_setter.cc
@@ -14,6 +14,7 @@
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "ui/gfx/icon_util.h"
+#include "ui/gfx/win/dpi.h"
#endif
@@ -71,8 +72,15 @@ ElevationIconSetter::~ElevationIconSetter() {
void ElevationIconSetter::SetButtonIcon(scoped_ptr<SkBitmap> icon) {
if (icon) {
- button_->SetImage(views::Button::STATE_NORMAL,
- gfx::ImageSkia::CreateFrom1xBitmap(*icon));
+ float device_scale_factor = 1.0f;
+#if defined(OS_WIN)
+ // Windows gives us back a correctly-scaled image for the current DPI, so
+ // mark this image as having been scaled for the current DPI already.
+ device_scale_factor = gfx::GetDPIScale();
+#endif
+ button_->SetImage(
+ views::Button::STATE_NORMAL,
+ gfx::ImageSkia(gfx::ImageSkiaRep(*icon, device_scale_factor)));
button_->SizeToPreferredSize();
if (button_->parent())
button_->parent()->Layout();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698