| OLD | NEW |
| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return; | 330 return; |
| 331 | 331 |
| 332 Vector<FontCacheKey> keysToRemove; | 332 Vector<FontCacheKey> keysToRemove; |
| 333 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); | 333 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); |
| 334 for (auto& sizedFonts : *gFontPlatformDataCache) { | 334 for (auto& sizedFonts : *gFontPlatformDataCache) { |
| 335 Vector<unsigned> sizesToRemove; | 335 Vector<unsigned> sizesToRemove; |
| 336 sizesToRemove.reserveInitialCapacity(sizedFonts.value.size()); | 336 sizesToRemove.reserveInitialCapacity(sizedFonts.value.size()); |
| 337 for (const auto& platformData : sizedFonts.value) { | 337 for (const auto& platformData : sizedFonts.value) { |
| 338 if (platformData.value && | 338 if (platformData.value && |
| 339 !gFontDataCache->contains(platformData.value.get())) | 339 !gFontDataCache->contains(platformData.value.get())) |
| 340 sizesToRemove.append(platformData.key); | 340 sizesToRemove.push_back(platformData.key); |
| 341 } | 341 } |
| 342 sizedFonts.value.removeAll(sizesToRemove); | 342 sizedFonts.value.removeAll(sizesToRemove); |
| 343 if (sizedFonts.value.isEmpty()) | 343 if (sizedFonts.value.isEmpty()) |
| 344 keysToRemove.append(sizedFonts.key); | 344 keysToRemove.push_back(sizedFonts.key); |
| 345 } | 345 } |
| 346 gFontPlatformDataCache->removeAll(keysToRemove); | 346 gFontPlatformDataCache->removeAll(keysToRemove); |
| 347 } | 347 } |
| 348 | 348 |
| 349 static inline void purgeFontVerticalDataCache() { | 349 static inline void purgeFontVerticalDataCache() { |
| 350 FontVerticalDataCache& fontVerticalDataCache = | 350 FontVerticalDataCache& fontVerticalDataCache = |
| 351 fontVerticalDataCacheInstance(); | 351 fontVerticalDataCacheInstance(); |
| 352 if (!fontVerticalDataCache.isEmpty()) { | 352 if (!fontVerticalDataCache.isEmpty()) { |
| 353 // Mark & sweep unused verticalData | 353 // Mark & sweep unused verticalData |
| 354 FontVerticalDataCache::iterator verticalDataEnd = | 354 FontVerticalDataCache::iterator verticalDataEnd = |
| 355 fontVerticalDataCache.end(); | 355 fontVerticalDataCache.end(); |
| 356 for (FontVerticalDataCache::iterator verticalData = | 356 for (FontVerticalDataCache::iterator verticalData = |
| 357 fontVerticalDataCache.begin(); | 357 fontVerticalDataCache.begin(); |
| 358 verticalData != verticalDataEnd; ++verticalData) { | 358 verticalData != verticalDataEnd; ++verticalData) { |
| 359 if (verticalData->value) | 359 if (verticalData->value) |
| 360 verticalData->value->setInFontCache(false); | 360 verticalData->value->setInFontCache(false); |
| 361 } | 361 } |
| 362 | 362 |
| 363 gFontDataCache->markAllVerticalData(); | 363 gFontDataCache->markAllVerticalData(); |
| 364 | 364 |
| 365 Vector<FontCache::FontFileKey> keysToRemove; | 365 Vector<FontCache::FontFileKey> keysToRemove; |
| 366 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); | 366 keysToRemove.reserveInitialCapacity(fontVerticalDataCache.size()); |
| 367 for (FontVerticalDataCache::iterator verticalData = | 367 for (FontVerticalDataCache::iterator verticalData = |
| 368 fontVerticalDataCache.begin(); | 368 fontVerticalDataCache.begin(); |
| 369 verticalData != verticalDataEnd; ++verticalData) { | 369 verticalData != verticalDataEnd; ++verticalData) { |
| 370 if (!verticalData->value || !verticalData->value->inFontCache()) | 370 if (!verticalData->value || !verticalData->value->inFontCache()) |
| 371 keysToRemove.append(verticalData->key); | 371 keysToRemove.push_back(verticalData->key); |
| 372 } | 372 } |
| 373 fontVerticalDataCache.removeAll(keysToRemove); | 373 fontVerticalDataCache.removeAll(keysToRemove); |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 | 376 |
| 377 static inline void purgeFallbackListShaperCache() { | 377 static inline void purgeFallbackListShaperCache() { |
| 378 unsigned items = 0; | 378 unsigned items = 0; |
| 379 if (gFallbackListShaperCache) { | 379 if (gFallbackListShaperCache) { |
| 380 FallbackListShaperCache::iterator iter; | 380 FallbackListShaperCache::iterator iter; |
| 381 for (iter = gFallbackListShaperCache->begin(); | 381 for (iter = gFallbackListShaperCache->begin(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 gGeneration++; | 442 gGeneration++; |
| 443 | 443 |
| 444 HeapVector<Member<FontCacheClient>> clients; | 444 HeapVector<Member<FontCacheClient>> clients; |
| 445 size_t numClients = fontCacheClients().size(); | 445 size_t numClients = fontCacheClients().size(); |
| 446 clients.reserveInitialCapacity(numClients); | 446 clients.reserveInitialCapacity(numClients); |
| 447 HeapHashSet<WeakMember<FontCacheClient>>::iterator end = | 447 HeapHashSet<WeakMember<FontCacheClient>>::iterator end = |
| 448 fontCacheClients().end(); | 448 fontCacheClients().end(); |
| 449 for (HeapHashSet<WeakMember<FontCacheClient>>::iterator it = | 449 for (HeapHashSet<WeakMember<FontCacheClient>>::iterator it = |
| 450 fontCacheClients().begin(); | 450 fontCacheClients().begin(); |
| 451 it != end; ++it) | 451 it != end; ++it) |
| 452 clients.append(*it); | 452 clients.push_back(*it); |
| 453 | 453 |
| 454 ASSERT(numClients == clients.size()); | 454 ASSERT(numClients == clients.size()); |
| 455 for (size_t i = 0; i < numClients; ++i) | 455 for (size_t i = 0; i < numClients; ++i) |
| 456 clients[i]->fontCacheInvalidated(); | 456 clients[i]->fontCacheInvalidated(); |
| 457 | 457 |
| 458 purge(ForcePurge); | 458 purge(ForcePurge); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void FontCache::dumpFontPlatformDataCache( | 461 void FontCache::dumpFontPlatformDataCache( |
| 462 base::trace_event::ProcessMemoryDump* memoryDump) { | 462 base::trace_event::ProcessMemoryDump* memoryDump) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 485 for (iter = gFallbackListShaperCache->begin(); | 485 for (iter = gFallbackListShaperCache->begin(); |
| 486 iter != gFallbackListShaperCache->end(); ++iter) { | 486 iter != gFallbackListShaperCache->end(); ++iter) { |
| 487 shapeResultCacheSize += iter->value->byteSize(); | 487 shapeResultCacheSize += iter->value->byteSize(); |
| 488 } | 488 } |
| 489 dump->AddScalar("size", "bytes", shapeResultCacheSize); | 489 dump->AddScalar("size", "bytes", shapeResultCacheSize); |
| 490 memoryDump->AddSuballocation(dump->guid(), | 490 memoryDump->AddSuballocation(dump->guid(), |
| 491 WTF::Partitions::kAllocatedObjectPoolName); | 491 WTF::Partitions::kAllocatedObjectPoolName); |
| 492 } | 492 } |
| 493 | 493 |
| 494 } // namespace blink | 494 } // namespace blink |
| OLD | NEW |