| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/direct_write.h" | 5 #include "ui/gfx/win/direct_write.h" |
| 6 | 6 |
| 7 #include <dwrite.h> | 7 #include <dwrite.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // If forced off, don't use it. | 38 // If forced off, don't use it. |
| 39 const base::CommandLine& command_line = | 39 const base::CommandLine& command_line = |
| 40 *base::CommandLine::ForCurrentProcess(); | 40 *base::CommandLine::ForCurrentProcess(); |
| 41 if (command_line.HasSwitch(switches::kDisableDirectWrite)) | 41 if (command_line.HasSwitch(switches::kDisableDirectWrite)) |
| 42 return false; | 42 return false; |
| 43 | 43 |
| 44 // Can't use GDI on HiDPI. | 44 // Can't use GDI on HiDPI. |
| 45 if (gfx::GetDPIScale() > 1.0f) | 45 if (gfx::GetDPIScale() > 1.0f) |
| 46 return true; | 46 return true; |
| 47 | 47 |
| 48 // We have logic in renderer_font_platform_win.cc for falling back to safe | |
| 49 // font list if machine has more than 1750 fonts installed. Users have | |
| 50 // complained about this as safe font list is usually not sufficient. | |
| 51 // We now disable direct write (gdi) if we encounter more number | |
| 52 // of fonts than a threshold (currently 1750). | |
| 53 // Refer: crbug.com/421305 | |
| 54 const wchar_t kWindowsFontsRegistryKey[] = | |
| 55 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; | |
| 56 base::win::RegistryValueIterator reg_iterator(HKEY_LOCAL_MACHINE, | |
| 57 kWindowsFontsRegistryKey); | |
| 58 const DWORD kMaxAllowedFontsBeforeFallbackToGDI = 1750; | |
| 59 if (reg_iterator.ValueCount() >= kMaxAllowedFontsBeforeFallbackToGDI) | |
| 60 return false; | |
| 61 | |
| 62 // Otherwise, check the field trial. | 48 // Otherwise, check the field trial. |
| 63 const std::string group_name = | 49 const std::string group_name = |
| 64 base::FieldTrialList::FindFullName("DirectWrite"); | 50 base::FieldTrialList::FindFullName("DirectWrite"); |
| 65 return group_name != "Disabled"; | 51 return group_name != "Disabled"; |
| 66 } | 52 } |
| 67 | 53 |
| 68 void MaybeInitializeDirectWrite() { | 54 void MaybeInitializeDirectWrite() { |
| 69 static bool tried_dwrite_initialize = false; | 55 static bool tried_dwrite_initialize = false; |
| 70 if (tried_dwrite_initialize) | 56 if (tried_dwrite_initialize) |
| 71 return; | 57 return; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // (6.1.7600.*). We should just use GDI in these cases. | 90 // (6.1.7600.*). We should just use GDI in these cases. |
| 105 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); | 91 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); |
| 106 if (direct_write_font_mgr) { | 92 if (direct_write_font_mgr) { |
| 107 SetDefaultSkiaFactory(direct_write_font_mgr); | 93 SetDefaultSkiaFactory(direct_write_font_mgr); |
| 108 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); | 94 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); |
| 109 } | 95 } |
| 110 } | 96 } |
| 111 | 97 |
| 112 } // namespace win | 98 } // namespace win |
| 113 } // namespace gfx | 99 } // namespace gfx |
| OLD | NEW |