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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 FallbackListShaperCache::iterator it = | 216 FallbackListShaperCache::iterator it = |
217 g_fallback_list_shaper_cache->Find(key); | 217 g_fallback_list_shaper_cache->Find(key); |
218 ShapeCache* result = nullptr; | 218 ShapeCache* result = nullptr; |
219 if (it == g_fallback_list_shaper_cache->end()) { | 219 if (it == g_fallback_list_shaper_cache->end()) { |
220 result = new ShapeCache(); | 220 result = new ShapeCache(); |
221 g_fallback_list_shaper_cache->Set(key, WTF::WrapUnique(result)); | 221 g_fallback_list_shaper_cache->Set(key, WTF::WrapUnique(result)); |
222 } else { | 222 } else { |
223 result = it->value.get(); | 223 result = it->value.get(); |
224 } | 224 } |
225 | 225 |
226 ASSERT(result); | 226 DCHECK(result); |
227 return result; | 227 return result; |
228 } | 228 } |
229 | 229 |
230 typedef HashMap<FontCache::FontFileKey, | 230 typedef HashMap<FontCache::FontFileKey, |
231 RefPtr<OpenTypeVerticalData>, | 231 RefPtr<OpenTypeVerticalData>, |
232 IntHash<FontCache::FontFileKey>, | 232 IntHash<FontCache::FontFileKey>, |
233 UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> | 233 UnsignedWithZeroKeyHashTraits<FontCache::FontFileKey>> |
234 FontVerticalDataCache; | 234 FontVerticalDataCache; |
235 | 235 |
236 FontVerticalDataCache& FontVerticalDataCacheInstance() { | 236 FontVerticalDataCache& FontVerticalDataCacheInstance() { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 PassRefPtr<SimpleFontData> FontCache::FontDataFromFontPlatformData( | 287 PassRefPtr<SimpleFontData> FontCache::FontDataFromFontPlatformData( |
288 const FontPlatformData* platform_data, | 288 const FontPlatformData* platform_data, |
289 ShouldRetain should_retain, | 289 ShouldRetain should_retain, |
290 bool subpixel_ascent_descent) { | 290 bool subpixel_ascent_descent) { |
291 if (!g_font_data_cache) | 291 if (!g_font_data_cache) |
292 g_font_data_cache = new FontDataCache; | 292 g_font_data_cache = new FontDataCache; |
293 | 293 |
294 #if DCHECK_IS_ON() | 294 #if DCHECK_IS_ON() |
295 if (should_retain == kDoNotRetain) | 295 if (should_retain == kDoNotRetain) |
296 ASSERT(purge_prevent_count_); | 296 DCHECK(purge_prevent_count_); |
297 #endif | 297 #endif |
298 | 298 |
299 return g_font_data_cache->Get(platform_data, should_retain, | 299 return g_font_data_cache->Get(platform_data, should_retain, |
300 subpixel_ascent_descent); | 300 subpixel_ascent_descent); |
301 } | 301 } |
302 | 302 |
303 bool FontCache::IsPlatformFamilyMatchAvailable( | 303 bool FontCache::IsPlatformFamilyMatchAvailable( |
304 const FontDescription& font_description, | 304 const FontDescription& font_description, |
305 const AtomicString& family) { | 305 const AtomicString& family) { |
306 return GetFontPlatformData( | 306 return GetFontPlatformData( |
(...skipping 18 matching lines...) Expand all Loading... |
325 return String::FromUTF8( | 325 return String::FromUTF8( |
326 gfx::FontList::FirstAvailableOrFirst(families.Utf8().Data()).c_str()); | 326 gfx::FontList::FirstAvailableOrFirst(families.Utf8().Data()).c_str()); |
327 } | 327 } |
328 | 328 |
329 SimpleFontData* FontCache::GetNonRetainedLastResortFallbackFont( | 329 SimpleFontData* FontCache::GetNonRetainedLastResortFallbackFont( |
330 const FontDescription& font_description) { | 330 const FontDescription& font_description) { |
331 return GetLastResortFallbackFont(font_description, kDoNotRetain).LeakRef(); | 331 return GetLastResortFallbackFont(font_description, kDoNotRetain).LeakRef(); |
332 } | 332 } |
333 | 333 |
334 void FontCache::ReleaseFontData(const SimpleFontData* font_data) { | 334 void FontCache::ReleaseFontData(const SimpleFontData* font_data) { |
335 ASSERT(g_font_data_cache); | 335 DCHECK(g_font_data_cache); |
336 | 336 |
337 g_font_data_cache->Release(font_data); | 337 g_font_data_cache->Release(font_data); |
338 } | 338 } |
339 | 339 |
340 static inline void PurgePlatformFontDataCache() { | 340 static inline void PurgePlatformFontDataCache() { |
341 if (!g_font_platform_data_cache) | 341 if (!g_font_platform_data_cache) |
342 return; | 342 return; |
343 | 343 |
344 Vector<FontCacheKey> keys_to_remove; | 344 Vector<FontCacheKey> keys_to_remove; |
345 keys_to_remove.ReserveInitialCapacity(g_font_platform_data_cache->size()); | 345 keys_to_remove.ReserveInitialCapacity(g_font_platform_data_cache->size()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 HeapHashSet<WeakMember<FontCacheClient>>& FontCacheClients() { | 425 HeapHashSet<WeakMember<FontCacheClient>>& FontCacheClients() { |
426 DEFINE_STATIC_LOCAL(HeapHashSet<WeakMember<FontCacheClient>>, clients, | 426 DEFINE_STATIC_LOCAL(HeapHashSet<WeakMember<FontCacheClient>>, clients, |
427 (new HeapHashSet<WeakMember<FontCacheClient>>)); | 427 (new HeapHashSet<WeakMember<FontCacheClient>>)); |
428 g_invalidate_font_cache = true; | 428 g_invalidate_font_cache = true; |
429 return clients; | 429 return clients; |
430 } | 430 } |
431 | 431 |
432 void FontCache::AddClient(FontCacheClient* client) { | 432 void FontCache::AddClient(FontCacheClient* client) { |
433 CHECK(client); | 433 CHECK(client); |
434 ASSERT(!FontCacheClients().Contains(client)); | 434 DCHECK(!FontCacheClients().Contains(client)); |
435 FontCacheClients().insert(client); | 435 FontCacheClients().insert(client); |
436 } | 436 } |
437 | 437 |
438 static unsigned short g_generation = 0; | 438 static unsigned short g_generation = 0; |
439 | 439 |
440 unsigned short FontCache::Generation() { | 440 unsigned short FontCache::Generation() { |
441 return g_generation; | 441 return g_generation; |
442 } | 442 } |
443 | 443 |
444 void FontCache::Invalidate() { | 444 void FontCache::Invalidate() { |
445 if (!g_invalidate_font_cache) { | 445 if (!g_invalidate_font_cache) { |
446 ASSERT(!g_font_platform_data_cache); | 446 DCHECK(!g_font_platform_data_cache); |
447 return; | 447 return; |
448 } | 448 } |
449 | 449 |
450 if (g_font_platform_data_cache) { | 450 if (g_font_platform_data_cache) { |
451 delete g_font_platform_data_cache; | 451 delete g_font_platform_data_cache; |
452 g_font_platform_data_cache = new FontPlatformDataCache; | 452 g_font_platform_data_cache = new FontPlatformDataCache; |
453 } | 453 } |
454 | 454 |
455 g_generation++; | 455 g_generation++; |
456 | 456 |
(...skipping 20 matching lines...) Expand all Loading... |
477 | 477 |
478 debug::Alias(&font_cache); | 478 debug::Alias(&font_cache); |
479 debug::Alias(&font_mgr); | 479 debug::Alias(&font_mgr); |
480 debug::Alias(&num_families); | 480 debug::Alias(&num_families); |
481 | 481 |
482 CHECK(false); | 482 CHECK(false); |
483 } | 483 } |
484 | 484 |
485 void FontCache::DumpFontPlatformDataCache( | 485 void FontCache::DumpFontPlatformDataCache( |
486 base::trace_event::ProcessMemoryDump* memory_dump) { | 486 base::trace_event::ProcessMemoryDump* memory_dump) { |
487 ASSERT(IsMainThread()); | 487 DCHECK(IsMainThread()); |
488 if (!g_font_platform_data_cache) | 488 if (!g_font_platform_data_cache) |
489 return; | 489 return; |
490 base::trace_event::MemoryAllocatorDump* dump = | 490 base::trace_event::MemoryAllocatorDump* dump = |
491 memory_dump->CreateAllocatorDump("font_caches/font_platform_data_cache"); | 491 memory_dump->CreateAllocatorDump("font_caches/font_platform_data_cache"); |
492 size_t font_platform_data_objects_size = | 492 size_t font_platform_data_objects_size = |
493 g_font_platform_data_cache->size() * sizeof(FontPlatformData); | 493 g_font_platform_data_cache->size() * sizeof(FontPlatformData); |
494 dump->AddScalar("size", "bytes", font_platform_data_objects_size); | 494 dump->AddScalar("size", "bytes", font_platform_data_objects_size); |
495 memory_dump->AddSuballocation(dump->guid(), | 495 memory_dump->AddSuballocation(dump->guid(), |
496 WTF::Partitions::kAllocatedObjectPoolName); | 496 WTF::Partitions::kAllocatedObjectPoolName); |
497 } | 497 } |
498 | 498 |
499 void FontCache::DumpShapeResultCache( | 499 void FontCache::DumpShapeResultCache( |
500 base::trace_event::ProcessMemoryDump* memory_dump) { | 500 base::trace_event::ProcessMemoryDump* memory_dump) { |
501 ASSERT(IsMainThread()); | 501 DCHECK(IsMainThread()); |
502 if (!g_fallback_list_shaper_cache) { | 502 if (!g_fallback_list_shaper_cache) { |
503 return; | 503 return; |
504 } | 504 } |
505 base::trace_event::MemoryAllocatorDump* dump = | 505 base::trace_event::MemoryAllocatorDump* dump = |
506 memory_dump->CreateAllocatorDump("font_caches/shape_caches"); | 506 memory_dump->CreateAllocatorDump("font_caches/shape_caches"); |
507 size_t shape_result_cache_size = 0; | 507 size_t shape_result_cache_size = 0; |
508 FallbackListShaperCache::iterator iter; | 508 FallbackListShaperCache::iterator iter; |
509 for (iter = g_fallback_list_shaper_cache->begin(); | 509 for (iter = g_fallback_list_shaper_cache->begin(); |
510 iter != g_fallback_list_shaper_cache->end(); ++iter) { | 510 iter != g_fallback_list_shaper_cache->end(); ++iter) { |
511 shape_result_cache_size += iter->value->ByteSize(); | 511 shape_result_cache_size += iter->value->ByteSize(); |
512 } | 512 } |
513 dump->AddScalar("size", "bytes", shape_result_cache_size); | 513 dump->AddScalar("size", "bytes", shape_result_cache_size); |
514 memory_dump->AddSuballocation(dump->guid(), | 514 memory_dump->AddSuballocation(dump->guid(), |
515 WTF::Partitions::kAllocatedObjectPoolName); | 515 WTF::Partitions::kAllocatedObjectPoolName); |
516 } | 516 } |
517 | 517 |
518 } // namespace blink | 518 } // namespace blink |
OLD | NEW |