Index: ui/gfx/win/dpi.cc |
diff --git a/ui/gfx/win/dpi.cc b/ui/gfx/win/dpi.cc |
index 88766ce2d4f6da8b12cf5a6e9c2298230dda9fd0..ae5db806084e681f3ea9e4e7d0b014a238a0b2a1 100644 |
--- a/ui/gfx/win/dpi.cc |
+++ b/ui/gfx/win/dpi.cc |
@@ -6,6 +6,7 @@ |
#include <windows.h> |
#include "base/command_line.h" |
+#include "base/metrics/field_trial.h" |
#include "base/win/scoped_hdc.h" |
#include "base/win/windows_version.h" |
#include "base/win/registry.h" |
@@ -228,5 +229,35 @@ bool IsDeviceScaleFactorSet() { |
return g_device_scale_factor != 0.0f; |
} |
+bool ShouldUseDirectWrite() { |
+ // If the flag is currently on, and we're on Win7 or above, we enable |
+ // DirectWrite. Skia does not require the additions to DirectWrite in QFE |
+ // 2670838, but a simple 'better than XP' check is not enough. |
+ if (base::win::GetVersion() < base::win::VERSION_WIN7) |
+ return false; |
+ |
+ base::win::OSInfo::VersionNumber os_version = |
+ base::win::OSInfo::GetInstance()->version_number(); |
+ if ((os_version.major == 6) && (os_version.minor == 1)) { |
+ // We can't use DirectWrite for pre-release versions of Windows 7. |
+ if (os_version.build < 7600) |
+ return false; |
+ } |
+ // If forced off, don't use it. |
+ const base::CommandLine& command_line = |
+ *base::CommandLine::ForCurrentProcess(); |
+ if (command_line.HasSwitch(switches::kDisableDirectWrite)) |
+ return false; |
+ |
+ // Can't use GDI on HiDPI. |
+ if (gfx::GetDPIScale() > 1.0f) |
+ return true; |
+ |
+ // Otherwise, check the field trial. |
+ const std::string group_name = |
+ base::FieldTrialList::FindFullName("DirectWrite"); |
+ return group_name != "Disabled"; |
+} |
+ |
} // namespace win |
} // namespace gfx |