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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 float GetDPIScale() { | 138 float GetDPIScale() { |
139 if (IsHighDPIEnabled()) { | 139 if (IsHighDPIEnabled()) { |
140 return gfx::Display::HasForceDeviceScaleFactor() ? | 140 return gfx::Display::HasForceDeviceScaleFactor() ? |
141 gfx::Display::GetForcedDeviceScaleFactor() : | 141 gfx::Display::GetForcedDeviceScaleFactor() : |
142 GetUnforcedDeviceScaleFactor(); | 142 GetUnforcedDeviceScaleFactor(); |
143 } | 143 } |
144 return 1.0; | 144 return 1.0; |
145 } | 145 } |
146 | 146 |
147 void ForceHighDPISupportForTesting(float scale) { | 147 void ForceHighDPISupportForTesting(float scale) { |
148 force_highdpi_for_testing = true; | |
149 g_device_scale_factor = scale; | 148 g_device_scale_factor = scale; |
150 } | 149 } |
151 | 150 |
152 bool IsHighDPIEnabled() { | 151 bool IsHighDPIEnabled() { |
153 // Flag stored in HKEY_CURRENT_USER\SOFTWARE\\Google\\Chrome\\Profile, | 152 // Flag stored in HKEY_CURRENT_USER\SOFTWARE\\Google\\Chrome\\Profile, |
154 // under the DWORD value high-dpi-support. | 153 // under the DWORD value high-dpi-support. |
155 // Default is disabled. | 154 // Default is disabled. |
156 static DWORD value = ReadRegistryValue( | 155 static DWORD value = ReadRegistryValue( |
157 HKEY_CURRENT_USER, kRegistryProfilePath, | 156 HKEY_CURRENT_USER, kRegistryProfilePath, |
158 kHighDPISupportW, FALSE); | 157 kHighDPISupportW, TRUE); |
159 return force_highdpi_for_testing || (value == 1); | 158 return value != 0; |
160 } | 159 } |
161 | 160 |
162 bool IsInHighDPIMode() { | 161 bool IsInHighDPIMode() { |
163 return GetDPIScale() > 1.0; | 162 return GetDPIScale() > 1.0; |
164 } | 163 } |
165 | 164 |
166 void EnableHighDPISupport() { | 165 void EnableHighDPISupport() { |
167 if (IsHighDPIEnabled() && | 166 if (IsHighDPIEnabled() && |
168 !SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) { | 167 !SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) { |
169 SetProcessDPIAwareWrapper(); | 168 SetProcessDPIAwareWrapper(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 241 |
243 double GetUndocumentedDPITouchScale() { | 242 double GetUndocumentedDPITouchScale() { |
244 static double scale = | 243 static double scale = |
245 (base::win::GetVersion() < base::win::VERSION_WIN8_1) ? | 244 (base::win::GetVersion() < base::win::VERSION_WIN8_1) ? |
246 GetUndocumentedDPIScale() : 1.0; | 245 GetUndocumentedDPIScale() : 1.0; |
247 return scale; | 246 return scale; |
248 } | 247 } |
249 | 248 |
250 } // namespace win | 249 } // namespace win |
251 } // namespace gfx | 250 } // namespace gfx |
OLD | NEW |