diff options
author | kevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-02 17:22:24 +0000 |
---|---|---|
committer | kevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-02 17:22:24 +0000 |
commit | 9c8ea3bf49845e4b082a680f9f0bf759c07f2f34 (patch) | |
tree | a4d81a9394fb4c7599315103807600c8e5734c97 /ui | |
parent | 504f1dd22013ca7ce82f25ddbaec1fe2c0409778 (diff) | |
download | chromium_src-9c8ea3bf49845e4b082a680f9f0bf759c07f2f34.zip chromium_src-9c8ea3bf49845e4b082a680f9f0bf759c07f2f34.tar.gz chromium_src-9c8ea3bf49845e4b082a680f9f0bf759c07f2f34.tar.bz2 |
Fix loading of high-DPI resources for Windows.
BUG=159730
Review URL: https://chromiumcodereview.appspot.com/12378019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185718 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/layout.cc | 11 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle_win.cc | 57 | ||||
-rw-r--r-- | ui/base/win/dpi.cc | 7 |
3 files changed, 40 insertions, 35 deletions
diff --git a/ui/base/layout.cc b/ui/base/layout.cc index a0381592..bb97fd1 100644 --- a/ui/base/layout.cc +++ b/ui/base/layout.cc @@ -118,11 +118,12 @@ std::vector<ScaleFactor>& GetSupportedScaleFactorsInternal() { #elif defined(OS_MACOSX) if (base::mac::IsOSLionOrLater()) supported_scale_factors->push_back(SCALE_FACTOR_200P); -#elif defined(OS_WIN) && defined(ENABLE_HIDPI) - if (base::win::IsMetroProcess() && ui::IsTouchDevicePresent()) { - supported_scale_factors->push_back(SCALE_FACTOR_140P); - supported_scale_factors->push_back(SCALE_FACTOR_180P); - } +#elif defined(OS_WIN) + // Have high-DPI resources for 140% and 180% scaling on Windows based on + // default scaling for Metro mode. Round to nearest supported scale in + // all cases. + supported_scale_factors->push_back(SCALE_FACTOR_140P); + supported_scale_factors->push_back(SCALE_FACTOR_180P); #elif defined(OS_CHROMEOS) // TODO(oshima): Include 200P only if the device support 200P supported_scale_factors->push_back(SCALE_FACTOR_200P); diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc index a98bbaf..3af0249 100644 --- a/ui/base/resource/resource_bundle_win.cc +++ b/ui/base/resource/resource_bundle_win.cc @@ -38,34 +38,35 @@ base::FilePath GetResourcesPakFilePath(const std::string& pak_name) { void ResourceBundle::LoadCommonResources() { // As a convenience, add the current resource module as a data packs. data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); - - bool use_hidpi = false; -#if defined(ENABLE_HIDPI) - // If we're running in HiDPI mode at a scale larger than 150%, we switch - // to 2x resources for desktop layouts. - use_hidpi = ui::GetDPIScale() > 1.5; -#endif - - switch (ui::GetDisplayLayout()) { - case ui::LAYOUT_TOUCH: - AddDataPackFromPath( - GetResourcesPakFilePath("chrome_touch_100_percent.pak"), - SCALE_FACTOR_100P); - break; - default: - if (use_hidpi) { - AddDataPackFromPath(GetResourcesPakFilePath( - "chrome_200_percent.pak"), - SCALE_FACTOR_200P); - AddDataPackFromPath(GetResourcesPakFilePath( - "webkit_resources_200_percent.pak"), - SCALE_FACTOR_200P); - } else { - AddDataPackFromPath( - GetResourcesPakFilePath("chrome_100_percent.pak"), - SCALE_FACTOR_100P); - } - break; + // Have high-DPI resources for 140% and 180% scaling on Windows based on + // default scaling for Metro mode. If high-DPI mode is enabled, load resource + // pak closest to the desired scale factor. The high-DPI resources are + // scaled up from 100% touch. + float scale = ui::win::GetDeviceScaleFactor(); + bool force_touch_resources = false; + switch(ui::GetScaleFactorFromScale(scale)) { + case ui::SCALE_FACTOR_180P: + AddDataPackFromPath(GetResourcesPakFilePath( + "chrome_touch_180_percent.pak"), + SCALE_FACTOR_180P); + force_touch_resources = true; + break; + case ui::SCALE_FACTOR_140P: + AddDataPackFromPath(GetResourcesPakFilePath( + "chrome_touch_140_percent.pak"), + SCALE_FACTOR_140P); + force_touch_resources = true; + } + // TODO(kevers|girard): Remove loading of 1x resources when in high-DPI + // mode once all resources are available at 140% and 180%. + if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH || force_touch_resources) { + AddDataPackFromPath( + GetResourcesPakFilePath("chrome_touch_100_percent.pak"), + SCALE_FACTOR_100P); + } else { + AddDataPackFromPath( + GetResourcesPakFilePath("chrome_100_percent.pak"), + SCALE_FACTOR_100P); } } diff --git a/ui/base/win/dpi.cc b/ui/base/win/dpi.cc index ecfb3e7..b618df9 100644 --- a/ui/base/win/dpi.cc +++ b/ui/base/win/dpi.cc @@ -7,6 +7,7 @@ #include <windows.h> #include "base/win/scoped_hdc.h" +#include "ui/base/layout.h" #include "ui/gfx/display.h" #include "ui/gfx/point_conversions.h" #include "ui/gfx/rect_conversions.h" @@ -17,11 +18,13 @@ namespace { int kDefaultDPIX = 96; int kDefaultDPIY = 96; - float GetDeviceScaleFactorImpl() { #if defined(ENABLE_HIDPI) - return gfx::Display::HasForceDeviceScaleFactor() ? + float scale = gfx::Display::HasForceDeviceScaleFactor() ? gfx::Display::GetForcedDeviceScaleFactor() : ui::GetDPIScale(); + // Quantize to nearest supported scale factor. + scale = ui::GetScaleFactorScale(ui::GetScaleFactorFromScale(scale)); + return scale; #else return 1.0f; #endif |