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/metrics/field_trial.h" |
9 #include "base/win/scoped_hdc.h" | 10 #include "base/win/scoped_hdc.h" |
10 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
11 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
12 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
13 #include "ui/gfx/switches.h" | 14 #include "ui/gfx/switches.h" |
14 #include "ui/gfx/point_conversions.h" | 15 #include "ui/gfx/point_conversions.h" |
15 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
16 #include "ui/gfx/size_conversions.h" | 17 #include "ui/gfx/size_conversions.h" |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 222 |
222 int GetSystemMetricsInDIP(int metric) { | 223 int GetSystemMetricsInDIP(int metric) { |
223 return static_cast<int>(GetSystemMetrics(metric) / | 224 return static_cast<int>(GetSystemMetrics(metric) / |
224 GetDeviceScaleFactor() + 0.5); | 225 GetDeviceScaleFactor() + 0.5); |
225 } | 226 } |
226 | 227 |
227 bool IsDeviceScaleFactorSet() { | 228 bool IsDeviceScaleFactorSet() { |
228 return g_device_scale_factor != 0.0f; | 229 return g_device_scale_factor != 0.0f; |
229 } | 230 } |
230 | 231 |
| 232 bool ShouldUseDirectWrite() { |
| 233 // If the flag is currently on, and we're on Win7 or above, we enable |
| 234 // DirectWrite. Skia does not require the additions to DirectWrite in QFE |
| 235 // 2670838, but a simple 'better than XP' check is not enough. |
| 236 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 237 return false; |
| 238 |
| 239 base::win::OSInfo::VersionNumber os_version = |
| 240 base::win::OSInfo::GetInstance()->version_number(); |
| 241 if ((os_version.major == 6) && (os_version.minor == 1)) { |
| 242 // We can't use DirectWrite for pre-release versions of Windows 7. |
| 243 if (os_version.build < 7600) |
| 244 return false; |
| 245 } |
| 246 // If forced off, don't use it. |
| 247 const base::CommandLine& command_line = |
| 248 *base::CommandLine::ForCurrentProcess(); |
| 249 if (command_line.HasSwitch(switches::kDisableDirectWrite)) |
| 250 return false; |
| 251 |
| 252 // Can't use GDI on HiDPI. |
| 253 if (gfx::GetDPIScale() > 1.0f) |
| 254 return true; |
| 255 |
| 256 // Otherwise, check the field trial. |
| 257 const std::string group_name = |
| 258 base::FieldTrialList::FindFullName("DirectWrite"); |
| 259 return group_name != "Disabled"; |
| 260 } |
| 261 |
231 } // namespace win | 262 } // namespace win |
232 } // namespace gfx | 263 } // namespace gfx |
OLD | NEW |