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

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

Issue 256743005: Add removeAll method to sets and maps and use them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (!gFontPlatformDataCache) 190 if (!gFontPlatformDataCache)
191 return; 191 return;
192 192
193 Vector<FontCacheKey> keysToRemove; 193 Vector<FontCacheKey> keysToRemove;
194 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); 194 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size());
195 FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->en d(); 195 FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->en d();
196 for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache-> begin(); platformData != platformDataEnd; ++platformData) { 196 for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache-> begin(); platformData != platformDataEnd; ++platformData) {
197 if (platformData->value && !gFontDataCache->contains(platformData->value .get())) 197 if (platformData->value && !gFontDataCache->contains(platformData->value .get()))
198 keysToRemove.append(platformData->key); 198 keysToRemove.append(platformData->key);
199 } 199 }
200 200 gFontPlatformDataCache->removeAll(keysToRemove);
201 size_t keysToRemoveCount = keysToRemove.size();
202 for (size_t i = 0; i < keysToRemoveCount; ++i)
203 gFontPlatformDataCache->remove(keysToRemove[i]);
204 } 201 }
205 202
206 static inline void purgeFontVerticalDataCache() 203 static inline void purgeFontVerticalDataCache()
207 { 204 {
208 #if ENABLE(OPENTYPE_VERTICAL) 205 #if ENABLE(OPENTYPE_VERTICAL)
209 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance (); 206 FontVerticalDataCache& fontVerticalDataCache = fontVerticalDataCacheInstance ();
210 if (!fontVerticalDataCache.isEmpty()) { 207 if (!fontVerticalDataCache.isEmpty()) {
211 // Mark & sweep unused verticalData 208 // Mark & sweep unused verticalData
212 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache. end(); 209 FontVerticalDataCache::iterator verticalDataEnd = fontVerticalDataCache. end();
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) 211 if (verticalData->value)
215 verticalData->value->setInFontCache(false); 212 verticalData->value->setInFontCache(false);
216 } 213 }
217 214
218 gFontDataCache->markAllVerticalData(); 215 gFontDataCache->markAllVerticalData();
219 216
220 Vector<FontCache::FontFileKey> keysToRemove; 217 Vector<FontCache::FontFileKey> keysToRemove;
221 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); 218 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size());
222 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCach e.begin(); verticalData != verticalDataEnd; ++verticalData) { 219 for (FontVerticalDataCache::iterator verticalData = fontVerticalDataCach e.begin(); verticalData != verticalDataEnd; ++verticalData) {
223 if (!verticalData->value || !verticalData->value->inFontCache()) 220 if (!verticalData->value || !verticalData->value->inFontCache())
224 keysToRemove.append(verticalData->key); 221 keysToRemove.append(verticalData->key);
225 } 222 }
226 for (size_t i = 0, count = keysToRemove.size(); i < count; ++i) 223 fontVerticalDataCache.removeAll(keysToRemove);
227 fontVerticalDataCache.take(keysToRemove[i]);
228 } 224 }
229 #endif 225 #endif
230 } 226 }
231 227
232 void FontCache::purge(PurgeSeverity PurgeSeverity) 228 void FontCache::purge(PurgeSeverity PurgeSeverity)
233 { 229 {
234 // We should never be forcing the purge while the FontCachePurgePreventer is in scope. 230 // We should never be forcing the purge while the FontCachePurgePreventer is in scope.
235 ASSERT(!m_purgePreventCount || PurgeSeverity == PurgeIfNeeded); 231 ASSERT(!m_purgePreventCount || PurgeSeverity == PurgeIfNeeded);
236 if (m_purgePreventCount) 232 if (m_purgePreventCount)
237 return; 233 return;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 clients.append(*it); 295 clients.append(*it);
300 296
301 ASSERT(numClients == clients.size()); 297 ASSERT(numClients == clients.size());
302 for (size_t i = 0; i < numClients; ++i) 298 for (size_t i = 0; i < numClients; ++i)
303 clients[i]->fontCacheInvalidated(); 299 clients[i]->fontCacheInvalidated();
304 300
305 purge(ForcePurge); 301 purge(ForcePurge);
306 } 302 }
307 303
308 } // namespace WebCore 304 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698