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

Side by Side Diff: Source/platform/fonts/FontCache.cpp

Issue 617103003: Replace ENABLE_OPENTYPE_VERTICAL implementation with HarfBuzz (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@removeOpenTypeVertical
Patch Set: Additional TestExpectations tweaking for Mac 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 | « Source/platform/fonts/FontCache.h ('k') | Source/platform/fonts/FontDataCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 FontFaceCreationParams createByAlternateFamily(alternateName); 107 FontFaceCreationParams createByAlternateFamily(alternateName);
108 result = getFontPlatformData(fontDescription, createByAlternateFamil y, true); 108 result = getFontPlatformData(fontDescription, createByAlternateFamil y, true);
109 } 109 }
110 if (result) 110 if (result)
111 gFontPlatformDataCache->set(key, adoptPtr(new FontPlatformData(*resu lt))); // Cache the result under the old name. 111 gFontPlatformDataCache->set(key, adoptPtr(new FontPlatformData(*resu lt))); // Cache the result under the old name.
112 } 112 }
113 113
114 return result; 114 return result;
115 } 115 }
116 116
117 #if ENABLE(OPENTYPE_VERTICAL)
118 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey> > F ontVerticalDataCache; 117 typedef HashMap<FontCache::FontFileKey, RefPtr<OpenTypeVerticalData>, IntHash<Fo ntCache::FontFileKey>, UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey> > F ontVerticalDataCache;
119 118
120 FontVerticalDataCache& fontVerticalDataCacheInstance() 119 FontVerticalDataCache& fontVerticalDataCacheInstance()
121 { 120 {
122 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ()); 121 DEFINE_STATIC_LOCAL(FontVerticalDataCache, fontVerticalDataCache, ());
123 return fontVerticalDataCache; 122 return fontVerticalDataCache;
124 } 123 }
125 124
126 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData) 125 PassRefPtr<OpenTypeVerticalData> FontCache::getVerticalData(const FontFileKey& k ey, const FontPlatformData& platformData)
127 { 126 {
128 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); 127 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance ();
129 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key); 128 FontVerticalDataCache::iterator result = fontVerticalDataCache.find(key);
130 if (result != fontVerticalDataCache.end()) 129 if (result != fontVerticalDataCache.end())
131 return result.get()->value; 130 return result.get()->value;
132 131
133 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData); 132 RefPtr<OpenTypeVerticalData> verticalData = OpenTypeVerticalData::create(pla tformData);
134 if (!verticalData->isOpenType()) 133 if (!verticalData->isOpenType())
135 verticalData.clear(); 134 verticalData.clear();
136 fontVerticalDataCache.set(key, verticalData); 135 fontVerticalDataCache.set(key, verticalData);
137 return verticalData; 136 return verticalData;
138 } 137 }
139 #endif
140 138
141 static FontDataCache* gFontDataCache = 0; 139 static FontDataCache* gFontDataCache = 0;
142 140
143 PassRefPtr<SimpleFontData> FontCache::getFontData(const FontDescription& fontDes cription, const AtomicString& family, bool checkingAlternateName, ShouldRetain s houldRetain) 141 PassRefPtr<SimpleFontData> FontCache::getFontData(const FontDescription& fontDes cription, const AtomicString& family, bool checkingAlternateName, ShouldRetain s houldRetain)
144 { 142 {
145 if (FontPlatformData* platformData = getFontPlatformData(fontDescription, Fo ntFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)), checkingA lternateName)) 143 if (FontPlatformData* platformData = getFontPlatformData(fontDescription, Fo ntFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)), checkingA lternateName))
146 return fontDataFromFontPlatformData(platformData, shouldRetain); 144 return fontDataFromFontPlatformData(platformData, shouldRetain);
147 145
148 return nullptr; 146 return nullptr;
149 } 147 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->en d(); 187 FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->en d();
190 for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache-> begin(); platformData != platformDataEnd; ++platformData) { 188 for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache-> begin(); platformData != platformDataEnd; ++platformData) {
191 if (platformData->value && !gFontDataCache->contains(platformData->value .get())) 189 if (platformData->value && !gFontDataCache->contains(platformData->value .get()))
192 keysToRemove.append(platformData->key); 190 keysToRemove.append(platformData->key);
193 } 191 }
194 gFontPlatformDataCache->removeAll(keysToRemove); 192 gFontPlatformDataCache->removeAll(keysToRemove);
195 } 193 }
196 194
197 static inline void purgeFontVerticalDataCache() 195 static inline void purgeFontVerticalDataCache()
198 { 196 {
199 #if ENABLE(OPENTYPE_VERTICAL)
200 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); 197 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance ();
201 if (!fontVerticalDataCache.isEmpty()) { 198 if (!fontVerticalDataCache.isEmpty()) {
202 // Mark & sweep unused verticalData 199 // Mark & sweep unused verticalData
203 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache. end(); 200 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache. end();
204 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCach e.begin(); verticalData != verticalDataEnd; ++verticalData) { 201 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCach e.begin(); verticalData != verticalDataEnd; ++verticalData) {
205 if (verticalData->value) 202 if (verticalData->value)
206 verticalData->value->setInFontCache(false); 203 verticalData->value->setInFontCache(false);
207 } 204 }
208 205
209 gFontDataCache->markAllVerticalData(); 206 gFontDataCache->markAllVerticalData();
210 207
211 Vector<FontCache::FontFileKey> keysToRemove; 208 Vector<FontCache::FontFileKey> keysToRemove;
212 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); 209 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size());
213 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCach e.begin(); verticalData != verticalDataEnd; ++verticalData) { 210 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCach e.begin(); verticalData != verticalDataEnd; ++verticalData) {
214 if (!verticalData->value || !verticalData->value->inFontCache()) 211 if (!verticalData->value || !verticalData->value->inFontCache())
215 keysToRemove.append(verticalData->key); 212 keysToRemove.append(verticalData->key);
216 } 213 }
217 fontVerticalDataCache.removeAll(keysToRemove); 214 fontVerticalDataCache.removeAll(keysToRemove);
218 } 215 }
219 #endif
220 } 216 }
221 217
222 void FontCache::purge(PurgeSeverity PurgeSeverity) 218 void FontCache::purge(PurgeSeverity PurgeSeverity)
223 { 219 {
224 // We should never be forcing the purge while the FontCachePurgePreventer is in scope. 220 // We should never be forcing the purge while the FontCachePurgePreventer is in scope.
225 ASSERT(!m_purgePreventCount || PurgeSeverity == PurgeIfNeeded); 221 ASSERT(!m_purgePreventCount || PurgeSeverity == PurgeIfNeeded);
226 if (m_purgePreventCount) 222 if (m_purgePreventCount)
227 return; 223 return;
228 224
229 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity)) 225 if (!gFontDataCache || !gFontDataCache->purge(PurgeSeverity))
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 clients.append(*it); 281 clients.append(*it);
286 282
287 ASSERT(numClients == clients.size()); 283 ASSERT(numClients == clients.size());
288 for (size_t i = 0; i < numClients; ++i) 284 for (size_t i = 0; i < numClients; ++i)
289 clients[i]->fontCacheInvalidated(); 285 clients[i]->fontCacheInvalidated();
290 286
291 purge(ForcePurge); 287 purge(ForcePurge);
292 } 288 }
293 289
294 } // namespace blink 290 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontCache.h ('k') | Source/platform/fonts/FontDataCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698