Chromium Code Reviews| 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 "ui/gfx/win/dpi.h" | 5 #include "ui/gfx/win/dpi.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/win/scoped_hdc.h" | 9 #include "base/win/scoped_hdc.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // user must logout to change the DPI setting. This value also applies | 127 // user must logout to change the DPI setting. This value also applies |
| 128 // to all screens. | 128 // to all screens. |
| 129 dpi_x = GetDeviceCaps(screen_dc, LOGPIXELSX); | 129 dpi_x = GetDeviceCaps(screen_dc, LOGPIXELSX); |
| 130 dpi_y = GetDeviceCaps(screen_dc, LOGPIXELSY); | 130 dpi_y = GetDeviceCaps(screen_dc, LOGPIXELSY); |
| 131 } | 131 } |
| 132 return Size(dpi_x, dpi_y); | 132 return Size(dpi_x, dpi_y); |
| 133 } | 133 } |
| 134 | 134 |
| 135 float GetDPIScale() { | 135 float GetDPIScale() { |
| 136 if (IsHighDPIEnabled()) { | 136 if (IsHighDPIEnabled()) { |
| 137 if (GetDPI().width() <= 120) { | 137 float dpi_scale = gfx::Display::HasForceDeviceScaleFactor() ? |
|
sky
2014/09/24 23:51:15
If there is a forced scale we should honor it.
ananta
2014/09/24 23:56:00
Thanks for catching that. Fixed
| |
| 138 // 120 logical pixels is 125% scale. We do this to maintain previous | 138 gfx::Display::GetForcedDeviceScaleFactor() : |
| 139 GetUnforcedDeviceScaleFactor(); | |
| 140 if (dpi_scale <= 1.25) { | |
| 141 // Force 125% and below to 100% scale. We do this to maintain previous | |
| 139 // (non-DPI-aware) behavior where only the font size was boosted. | 142 // (non-DPI-aware) behavior where only the font size was boosted. |
| 140 return 1.0; | 143 return 1.0; |
| 141 } | 144 } |
| 142 return gfx::Display::HasForceDeviceScaleFactor() ? | 145 return dpi_scale; |
| 143 gfx::Display::GetForcedDeviceScaleFactor() : | |
| 144 GetUnforcedDeviceScaleFactor(); | |
| 145 } | 146 } |
| 146 return 1.0; | 147 return 1.0; |
| 147 } | 148 } |
| 148 | 149 |
| 149 void ForceHighDPISupportForTesting(float scale) { | 150 void ForceHighDPISupportForTesting(float scale) { |
| 150 g_device_scale_factor = scale; | 151 g_device_scale_factor = scale; |
| 151 } | 152 } |
| 152 | 153 |
| 153 bool IsHighDPIEnabled() { | 154 bool IsHighDPIEnabled() { |
| 154 // Flag stored in HKEY_CURRENT_USER\SOFTWARE\\Google\\Chrome\\Profile, | 155 // Flag stored in HKEY_CURRENT_USER\SOFTWARE\\Google\\Chrome\\Profile, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 return static_cast<int>(GetSystemMetrics(metric) / | 225 return static_cast<int>(GetSystemMetrics(metric) / |
| 225 GetDeviceScaleFactor() + 0.5); | 226 GetDeviceScaleFactor() + 0.5); |
| 226 } | 227 } |
| 227 | 228 |
| 228 bool IsDeviceScaleFactorSet() { | 229 bool IsDeviceScaleFactorSet() { |
| 229 return g_device_scale_factor != 0.0f; | 230 return g_device_scale_factor != 0.0f; |
| 230 } | 231 } |
| 231 | 232 |
| 232 } // namespace win | 233 } // namespace win |
| 233 } // namespace gfx | 234 } // namespace gfx |
| OLD | NEW |