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

Side by Side Diff: content/common/dwrite_font_platform_win.cc

Issue 796643004: Experimental change: Remove DirectWrite 1750 font limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 "content/public/common/dwrite_font_platform_win.h" 5 #include "content/public/common/dwrite_font_platform_win.h"
6 6
7 #include <dwrite.h> 7 #include <dwrite.h>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // users, so we are putting arbitrary limit on cache file size. There are 77 // users, so we are putting arbitrary limit on cache file size. There are
78 // multiple ways we can tune our working size, like mapping only required part 78 // multiple ways we can tune our working size, like mapping only required part
79 // of section at any given time. 79 // of section at any given time.
80 const double kArbitraryCacheFileSizeLimit = (20 * 1024 * 1024); 80 const double kArbitraryCacheFileSizeLimit = (20 * 1024 * 1024);
81 81
82 // We have chosen current font file length arbitrarily. In our logic 82 // We have chosen current font file length arbitrarily. In our logic
83 // if we don't find file we are looking for in cache we end up loading 83 // if we don't find file we are looking for in cache we end up loading
84 // that file directly from system fonts folder. 84 // that file directly from system fonts folder.
85 const unsigned int kMaxFontFileNameLength = 34; 85 const unsigned int kMaxFontFileNameLength = 34;
86 86
87 const DWORD kCacheFileVersion = 101; 87 const DWORD kCacheFileVersion = 102;
88 const DWORD kFileSignature = 0x4D4F5243; // CROM 88 const DWORD kFileSignature = 0x4D4F5243; // CROM
89 const DWORD kMagicCompletionSignature = 0x454E4F44; // DONE 89 const DWORD kMagicCompletionSignature = 0x454E4F44; // DONE
90 90
91 const DWORD kUndefinedDWORDS = 36; 91 const DWORD kUndefinedDWORDS = 36;
92 92
93 // Make sure that all structure sizes align with 8 byte boundary otherwise 93 // Make sure that all structure sizes align with 8 byte boundary otherwise
94 // dr. memory test may complain. 94 // dr. memory test may complain.
95 #pragma pack(push, 8) 95 #pragma pack(push, 8)
96 // Cache file header, includes signature, completion bits and version. 96 // Cache file header, includes signature, completion bits and version.
97 struct CacheFileHeader { 97 struct CacheFileHeader {
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 IDWriteFontCollection* GetCustomFontCollection(IDWriteFactory* factory) { 1021 IDWriteFontCollection* GetCustomFontCollection(IDWriteFactory* factory) {
1022 if (g_font_collection.Get() != NULL) 1022 if (g_font_collection.Get() != NULL)
1023 return g_font_collection.Get(); 1023 return g_font_collection.Get();
1024 1024
1025 base::TimeTicks start_tick = base::TimeTicks::Now(); 1025 base::TimeTicks start_tick = base::TimeTicks::Now();
1026 1026
1027 FontCollectionLoader::Initialize(factory); 1027 FontCollectionLoader::Initialize(factory);
1028 1028
1029 bool cache_file_loaded = g_font_loader->LoadCacheFile(); 1029 bool cache_file_loaded = g_font_loader->LoadCacheFile();
1030 1030
1031 // We try here to put arbitrary limit on max number of fonts that could
1032 // be loaded, otherwise we fallback to restricted set of fonts.
1033 const UINT32 kMaxFontThreshold = 1750;
1034 HRESULT hr = E_FAIL; 1031 HRESULT hr = E_FAIL;
1035 if (g_font_loader->GetFontMapSize() < kMaxFontThreshold) { 1032 g_font_loader->EnableCollectionBuildingMode(true);
1036 g_font_loader->EnableCollectionBuildingMode(true); 1033 hr = factory->CreateCustomFontCollection(
1037 hr = factory->CreateCustomFontCollection( 1034 g_font_loader.Get(), NULL, 0, g_font_collection.GetAddressOf());
1038 g_font_loader.Get(), NULL, 0, g_font_collection.GetAddressOf()); 1035 g_font_loader->EnableCollectionBuildingMode(false);
1039 g_font_loader->EnableCollectionBuildingMode(false);
1040 }
1041 1036
1042 bool loading_restricted = false; 1037 bool loading_restricted = false;
1043 if (FAILED(hr) || !g_font_collection.Get()) { 1038 if (FAILED(hr) || !g_font_collection.Get()) {
1044 loading_restricted = true; 1039 loading_restricted = true;
1045 // We will try here just one more time with restricted font set. 1040 // We will try here just one more time with restricted font set.
1046 g_font_loader->LoadRestrictedFontList(); 1041 g_font_loader->LoadRestrictedFontList();
1047 hr = factory->CreateCustomFontCollection( 1042 hr = factory->CreateCustomFontCollection(
1048 g_font_loader.Get(), NULL, 0, g_font_collection.GetAddressOf()); 1043 g_font_loader.Get(), NULL, 0, g_font_collection.GetAddressOf());
1049 } 1044 }
1050 1045
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 reinterpret_cast<IUnknown**>(factory.GetAddressOf())))); 1093 reinterpret_cast<IUnknown**>(factory.GetAddressOf()))));
1099 1094
1100 base::TimeTicks start_tick = base::TimeTicks::Now(); 1095 base::TimeTicks start_tick = base::TimeTicks::Now();
1101 1096
1102 FontCollectionLoader::Initialize(factory.Get()); 1097 FontCollectionLoader::Initialize(factory.Get());
1103 1098
1104 g_font_loader->EnterStaticCacheMode(file_name); 1099 g_font_loader->EnterStaticCacheMode(file_name);
1105 1100
1106 mswr::ComPtr<IDWriteFontCollection> font_collection; 1101 mswr::ComPtr<IDWriteFontCollection> font_collection;
1107 1102
1108 // We try here to put arbitrary limit on max number of fonts that could
1109 // be loaded, otherwise we fallback to restricted set of fonts.
cpu_(ooo_6.6-7.5) 2014/12/11 23:31:24 we had the same constant twice?
Shrikant Kelkar 2014/12/11 23:43:50 Acknowledged.
1110 const UINT32 kMaxFontThreshold = 1750;
1111 HRESULT hr = E_FAIL; 1103 HRESULT hr = E_FAIL;
1112 if (g_font_loader->GetFontMapSize() < kMaxFontThreshold) { 1104 g_font_loader->EnableCollectionBuildingMode(true);
cpu_(ooo_6.6-7.5) 2014/12/11 23:31:24 can it handle 20K fonts? is so go ahead. lgtm.
Shrikant Kelkar 2014/12/11 23:43:50 It may not.. but in this experiment let's see to w
1113 g_font_loader->EnableCollectionBuildingMode(true); 1105 hr = factory->CreateCustomFontCollection(
1114 hr = factory->CreateCustomFontCollection( 1106 g_font_loader.Get(), NULL, 0, font_collection.GetAddressOf());
1115 g_font_loader.Get(), NULL, 0, font_collection.GetAddressOf()); 1107 g_font_loader->EnableCollectionBuildingMode(false);
1116 g_font_loader->EnableCollectionBuildingMode(false);
1117 }
1118 1108
1119 bool loading_restricted = false; 1109 bool loading_restricted = false;
1120 if (FAILED(hr) || !font_collection.Get()) { 1110 if (FAILED(hr) || !font_collection.Get()) {
1121 loading_restricted = true; 1111 loading_restricted = true;
1122 // We will try here just one more time with restricted font set. 1112 // We will try here just one more time with restricted font set.
1123 g_font_loader->LoadRestrictedFontList(); 1113 g_font_loader->LoadRestrictedFontList();
1124 hr = factory->CreateCustomFontCollection( 1114 hr = factory->CreateCustomFontCollection(
1125 g_font_loader.Get(), NULL, 0, font_collection.GetAddressOf()); 1115 g_font_loader.Get(), NULL, 0, font_collection.GetAddressOf());
1126 } 1116 }
1127 1117
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 g_shared_font_cache.Set(mapping); 1174 g_shared_font_cache.Set(mapping);
1185 1175
1186 return true; 1176 return true;
1187 } 1177 }
1188 1178
1189 bool BuildFontCache(const base::FilePath& file) { 1179 bool BuildFontCache(const base::FilePath& file) {
1190 return BuildFontCacheInternal(file.value().c_str()); 1180 return BuildFontCacheInternal(file.value().c_str());
1191 } 1181 }
1192 1182
1193 } // namespace content 1183 } // namespace content
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