Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(929)

Side by Side Diff: ui/gfx/win/direct_write.cc

Issue 667013003: Disable direct write if font count in registry is greater than or equal to threshold (currently 175… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment as per code review suggestion. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/win/registry.h"
10 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
11 #include "ui/gfx/switches.h" 12 #include "ui/gfx/switches.h"
12 #include "ui/gfx/win/dpi.h" 13 #include "ui/gfx/win/dpi.h"
13 14
14 namespace gfx { 15 namespace gfx {
15 namespace win { 16 namespace win {
16 17
17 bool ShouldUseDirectWrite() { 18 bool ShouldUseDirectWrite() {
18 // If the flag is currently on, and we're on Win7 or above, we enable 19 // If the flag is currently on, and we're on Win7 or above, we enable
19 // DirectWrite. Skia does not require the additions to DirectWrite in QFE 20 // DirectWrite. Skia does not require the additions to DirectWrite in QFE
(...skipping 11 matching lines...) Expand all
31 // If forced off, don't use it. 32 // If forced off, don't use it.
32 const base::CommandLine& command_line = 33 const base::CommandLine& command_line =
33 *base::CommandLine::ForCurrentProcess(); 34 *base::CommandLine::ForCurrentProcess();
34 if (command_line.HasSwitch(switches::kDisableDirectWrite)) 35 if (command_line.HasSwitch(switches::kDisableDirectWrite))
35 return false; 36 return false;
36 37
37 // Can't use GDI on HiDPI. 38 // Can't use GDI on HiDPI.
38 if (gfx::GetDPIScale() > 1.0f) 39 if (gfx::GetDPIScale() > 1.0f)
39 return true; 40 return true;
40 41
42 // We have logic in renderer_font_platform_win.cc for falling back to safe
43 // font list if machine has more than 1750 fonts installed. Users have
44 // complained about this as safe font list is usually not sufficient.
45 // We now disable direct write (gdi) if we encounter more number
46 // of fonts than a threshold (currently 1750).
47 // Refer: crbug.com/421305
48 const wchar_t kWindowsFontsRegistryKey[] =
49 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
50 base::win::RegistryValueIterator reg_iterator(HKEY_LOCAL_MACHINE,
51 kWindowsFontsRegistryKey);
52 const DWORD kMaxAllowedFontsBeforeFallbackToGDI = 1750;
53 if (reg_iterator.ValueCount() >= kMaxAllowedFontsBeforeFallbackToGDI)
54 return false;
55
41 // Otherwise, check the field trial. 56 // Otherwise, check the field trial.
42 const std::string group_name = 57 const std::string group_name =
43 base::FieldTrialList::FindFullName("DirectWrite"); 58 base::FieldTrialList::FindFullName("DirectWrite");
44 return group_name != "Disabled"; 59 return group_name != "Disabled";
45 } 60 }
46 61
47 } // namespace win 62 } // namespace win
48 } // namespace gfx 63 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698