| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 FallbackListShaperCache::iterator it = gFallbackListShaperCache->find(key); | 215 FallbackListShaperCache::iterator it = gFallbackListShaperCache->find(key); |
| 216 ShapeCache* result = nullptr; | 216 ShapeCache* result = nullptr; |
| 217 if (it == gFallbackListShaperCache->end()) { | 217 if (it == gFallbackListShaperCache->end()) { |
| 218 result = new ShapeCache(); | 218 result = new ShapeCache(); |
| 219 gFallbackListShaperCache->set(key, WTF::wrapUnique(result)); | 219 gFallbackListShaperCache->set(key, WTF::wrapUnique(result)); |
| 220 } else { | 220 } else { |
| 221 result = it->value.get(); | 221 result = it->value.get(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 ASSERT(result); | 224 DCHECK(result); |
| 225 return result; | 225 return result; |
| 226 } | 226 } |
| 227 | 227 |
| 228 typedef HashMap<FontCache::FontFileKey, | 228 typedef HashMap<FontCache::FontFileKey, |
| 229 RefPtr<OpenTypeVerticalData>, | 229 RefPtr<OpenTypeVerticalData>, |
| 230 IntHash<FontCache::FontFileKey>, | 230 IntHash<FontCache::FontFileKey>, |
| 231 UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> | 231 UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> |
| 232 FontVerticalDataCache; | 232 FontVerticalDataCache; |
| 233 | 233 |
| 234 FontVerticalDataCache& fontVerticalDataCacheInstance() { | 234 FontVerticalDataCache& fontVerticalDataCacheInstance() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 PassRefPtr<SimpleFontData> FontCache::fontDataFromFontPlatformData( | 284 PassRefPtr<SimpleFontData> FontCache::fontDataFromFontPlatformData( |
| 285 const FontPlatformData* platformData, | 285 const FontPlatformData* platformData, |
| 286 ShouldRetain shouldRetain, | 286 ShouldRetain shouldRetain, |
| 287 bool subpixelAscentDescent) { | 287 bool subpixelAscentDescent) { |
| 288 if (!gFontDataCache) | 288 if (!gFontDataCache) |
| 289 gFontDataCache = new FontDataCache; | 289 gFontDataCache = new FontDataCache; |
| 290 | 290 |
| 291 #if DCHECK_IS_ON() | 291 #if DCHECK_IS_ON() |
| 292 if (shouldRetain == DoNotRetain) | 292 if (shouldRetain == DoNotRetain) |
| 293 ASSERT(m_purgePreventCount); | 293 DCHECK(m_purgePreventCount); |
| 294 #endif | 294 #endif |
| 295 | 295 |
| 296 return gFontDataCache->get(platformData, shouldRetain, subpixelAscentDescent); | 296 return gFontDataCache->get(platformData, shouldRetain, subpixelAscentDescent); |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool FontCache::isPlatformFamilyMatchAvailable( | 299 bool FontCache::isPlatformFamilyMatchAvailable( |
| 300 const FontDescription& fontDescription, | 300 const FontDescription& fontDescription, |
| 301 const AtomicString& family) { | 301 const AtomicString& family) { |
| 302 return getFontPlatformData( | 302 return getFontPlatformData( |
| 303 fontDescription, | 303 fontDescription, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 321 return String::fromUTF8( | 321 return String::fromUTF8( |
| 322 gfx::FontList::FirstAvailableOrFirst(families.utf8().data()).c_str()); | 322 gfx::FontList::FirstAvailableOrFirst(families.utf8().data()).c_str()); |
| 323 } | 323 } |
| 324 | 324 |
| 325 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont( | 325 SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont( |
| 326 const FontDescription& fontDescription) { | 326 const FontDescription& fontDescription) { |
| 327 return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef(); | 327 return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void FontCache::releaseFontData(const SimpleFontData* fontData) { | 330 void FontCache::releaseFontData(const SimpleFontData* fontData) { |
| 331 ASSERT(gFontDataCache); | 331 DCHECK(gFontDataCache); |
| 332 | 332 |
| 333 gFontDataCache->release(fontData); | 333 gFontDataCache->release(fontData); |
| 334 } | 334 } |
| 335 | 335 |
| 336 static inline void purgePlatformFontDataCache() { | 336 static inline void purgePlatformFontDataCache() { |
| 337 if (!gFontPlatformDataCache) | 337 if (!gFontPlatformDataCache) |
| 338 return; | 338 return; |
| 339 | 339 |
| 340 Vector<FontCacheKey> keysToRemove; | 340 Vector<FontCacheKey> keysToRemove; |
| 341 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); | 341 keysToRemove.reserveInitialCapacity(gFontPlatformDataCache->size()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 HeapHashSet<WeakMember<FontCacheClient>>& fontCacheClients() { | 421 HeapHashSet<WeakMember<FontCacheClient>>& fontCacheClients() { |
| 422 DEFINE_STATIC_LOCAL(HeapHashSet<WeakMember<FontCacheClient>>, clients, | 422 DEFINE_STATIC_LOCAL(HeapHashSet<WeakMember<FontCacheClient>>, clients, |
| 423 (new HeapHashSet<WeakMember<FontCacheClient>>)); | 423 (new HeapHashSet<WeakMember<FontCacheClient>>)); |
| 424 invalidateFontCache = true; | 424 invalidateFontCache = true; |
| 425 return clients; | 425 return clients; |
| 426 } | 426 } |
| 427 | 427 |
| 428 void FontCache::addClient(FontCacheClient* client) { | 428 void FontCache::addClient(FontCacheClient* client) { |
| 429 CHECK(client); | 429 CHECK(client); |
| 430 ASSERT(!fontCacheClients().contains(client)); | 430 DCHECK(!fontCacheClients().contains(client)); |
| 431 fontCacheClients().insert(client); | 431 fontCacheClients().insert(client); |
| 432 } | 432 } |
| 433 | 433 |
| 434 static unsigned short gGeneration = 0; | 434 static unsigned short gGeneration = 0; |
| 435 | 435 |
| 436 unsigned short FontCache::generation() { | 436 unsigned short FontCache::generation() { |
| 437 return gGeneration; | 437 return gGeneration; |
| 438 } | 438 } |
| 439 | 439 |
| 440 void FontCache::invalidate() { | 440 void FontCache::invalidate() { |
| 441 if (!invalidateFontCache) { | 441 if (!invalidateFontCache) { |
| 442 ASSERT(!gFontPlatformDataCache); | 442 DCHECK(!gFontPlatformDataCache); |
| 443 return; | 443 return; |
| 444 } | 444 } |
| 445 | 445 |
| 446 if (gFontPlatformDataCache) { | 446 if (gFontPlatformDataCache) { |
| 447 delete gFontPlatformDataCache; | 447 delete gFontPlatformDataCache; |
| 448 gFontPlatformDataCache = new FontPlatformDataCache; | 448 gFontPlatformDataCache = new FontPlatformDataCache; |
| 449 } | 449 } |
| 450 | 450 |
| 451 gGeneration++; | 451 gGeneration++; |
| 452 | 452 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 473 | 473 |
| 474 debug::alias(&fontCache); | 474 debug::alias(&fontCache); |
| 475 debug::alias(&fontMgr); | 475 debug::alias(&fontMgr); |
| 476 debug::alias(&numFamilies); | 476 debug::alias(&numFamilies); |
| 477 | 477 |
| 478 CHECK(false); | 478 CHECK(false); |
| 479 } | 479 } |
| 480 | 480 |
| 481 void FontCache::dumpFontPlatformDataCache( | 481 void FontCache::dumpFontPlatformDataCache( |
| 482 base::trace_event::ProcessMemoryDump* memoryDump) { | 482 base::trace_event::ProcessMemoryDump* memoryDump) { |
| 483 ASSERT(isMainThread()); | 483 DCHECK(isMainThread()); |
| 484 if (!gFontPlatformDataCache) | 484 if (!gFontPlatformDataCache) |
| 485 return; | 485 return; |
| 486 base::trace_event::MemoryAllocatorDump* dump = | 486 base::trace_event::MemoryAllocatorDump* dump = |
| 487 memoryDump->CreateAllocatorDump("font_caches/font_platform_data_cache"); | 487 memoryDump->CreateAllocatorDump("font_caches/font_platform_data_cache"); |
| 488 size_t fontPlatformDataObjectsSize = | 488 size_t fontPlatformDataObjectsSize = |
| 489 gFontPlatformDataCache->size() * sizeof(FontPlatformData); | 489 gFontPlatformDataCache->size() * sizeof(FontPlatformData); |
| 490 dump->AddScalar("size", "bytes", fontPlatformDataObjectsSize); | 490 dump->AddScalar("size", "bytes", fontPlatformDataObjectsSize); |
| 491 memoryDump->AddSuballocation(dump->guid(), | 491 memoryDump->AddSuballocation(dump->guid(), |
| 492 WTF::Partitions::kAllocatedObjectPoolName); | 492 WTF::Partitions::kAllocatedObjectPoolName); |
| 493 } | 493 } |
| 494 | 494 |
| 495 void FontCache::dumpShapeResultCache( | 495 void FontCache::dumpShapeResultCache( |
| 496 base::trace_event::ProcessMemoryDump* memoryDump) { | 496 base::trace_event::ProcessMemoryDump* memoryDump) { |
| 497 ASSERT(isMainThread()); | 497 DCHECK(isMainThread()); |
| 498 if (!gFallbackListShaperCache) { | 498 if (!gFallbackListShaperCache) { |
| 499 return; | 499 return; |
| 500 } | 500 } |
| 501 base::trace_event::MemoryAllocatorDump* dump = | 501 base::trace_event::MemoryAllocatorDump* dump = |
| 502 memoryDump->CreateAllocatorDump("font_caches/shape_caches"); | 502 memoryDump->CreateAllocatorDump("font_caches/shape_caches"); |
| 503 size_t shapeResultCacheSize = 0; | 503 size_t shapeResultCacheSize = 0; |
| 504 FallbackListShaperCache::iterator iter; | 504 FallbackListShaperCache::iterator iter; |
| 505 for (iter = gFallbackListShaperCache->begin(); | 505 for (iter = gFallbackListShaperCache->begin(); |
| 506 iter != gFallbackListShaperCache->end(); ++iter) { | 506 iter != gFallbackListShaperCache->end(); ++iter) { |
| 507 shapeResultCacheSize += iter->value->byteSize(); | 507 shapeResultCacheSize += iter->value->byteSize(); |
| 508 } | 508 } |
| 509 dump->AddScalar("size", "bytes", shapeResultCacheSize); | 509 dump->AddScalar("size", "bytes", shapeResultCacheSize); |
| 510 memoryDump->AddSuballocation(dump->guid(), | 510 memoryDump->AddSuballocation(dump->guid(), |
| 511 WTF::Partitions::kAllocatedObjectPoolName); | 511 WTF::Partitions::kAllocatedObjectPoolName); |
| 512 } | 512 } |
| 513 | 513 |
| 514 } // namespace blink | 514 } // namespace blink |
| OLD | NEW |