OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkGlyphCache.h" | 8 #include "SkGlyphCache.h" |
9 #include "SkGlyphCache_Globals.h" | 9 #include "SkGlyphCache_Globals.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 423 } |
424 | 424 |
425 static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { | 425 static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { |
426 SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*>
(context); | 426 SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*>
(context); |
427 SkTraceMemoryDump* dump = dumpContext->dump; | 427 SkTraceMemoryDump* dump = dumpContext->dump; |
428 int* counter = dumpContext->counter; | 428 int* counter = dumpContext->counter; |
429 int index = *counter; | 429 int index = *counter; |
430 *counter += 1; | 430 *counter += 1; |
431 | 431 |
432 const SkTypeface* face = cache.getScalerContext()->getTypeface(); | 432 const SkTypeface* face = cache.getScalerContext()->getTypeface(); |
433 SkString font_name; | 433 SkString fontName; |
434 face->getFamilyName(&font_name); | 434 face->getFamilyName(&fontName); |
435 const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); | 435 const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); |
436 | 436 |
437 SkString dump_name = SkStringPrintf("%s/%s_%3d/index_%d", | 437 SkString dumpName = SkStringPrintf("%s/%s_%3d/index_%d", |
438 gGlyphCacheDumpName, font_name.c_str(),
rec.fFontID, index); | 438 gGlyphCacheDumpName, fontName.c_str(), r
ec.fFontID, index); |
439 | 439 |
440 dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", cache.getMemoryUs
ed()); | 440 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUse
d()); |
441 dump->dumpNumericValue(dump_name.c_str(), "glyph_count", "objects", cache.co
untCachedGlyphs()); | 441 dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.cou
ntCachedGlyphs()); |
442 dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr); | 442 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |
443 } | 443 } |
444 | 444 |
445 void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 445 void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
| 446 if (!(dump->getRequestedDetails() | SkTraceMemoryDump::kMemoryTotals | |
| 447 SkTraceMemoryDump::kMallocDetails)) |
| 448 return; |
| 449 |
446 dump->dumpNumericValue(gGlyphCacheDumpName, "size", "bytes", SkGraphics::Get
FontCacheUsed()); | 450 dump->dumpNumericValue(gGlyphCacheDumpName, "size", "bytes", SkGraphics::Get
FontCacheUsed()); |
447 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_size", "bytes", | 451 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_size", "bytes", |
448 SkGraphics::GetFontCacheLimit()); | 452 SkGraphics::GetFontCacheLimit()); |
449 dump->dumpNumericValue(gGlyphCacheDumpName, "glyph_count", "objects", | 453 dump->dumpNumericValue(gGlyphCacheDumpName, "glyph_count", "objects", |
450 SkGraphics::GetFontCacheCountUsed()); | 454 SkGraphics::GetFontCacheCountUsed()); |
451 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_glyph_count", "objects", | 455 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_glyph_count", "objects", |
452 SkGraphics::GetFontCacheCountLimit()); | 456 SkGraphics::GetFontCacheCountLimit()); |
453 | 457 |
| 458 if (!(dump->getRequestedDetails() | SkTraceMemoryDump::kMallocDetails)) { |
| 459 dump->setMemoryBacking(gGlyphCacheDumpName, "malloc", nullptr); |
| 460 return; |
| 461 } |
| 462 |
454 int counter = 0; | 463 int counter = 0; |
455 SkGlyphCacheDumpContext context = { &counter, dump }; | 464 SkGlyphCacheDumpContext context = { &counter, dump }; |
456 SkGlyphCache::VisitAll(sk_trace_dump_visitor, &context); | 465 SkGlyphCache::VisitAll(sk_trace_dump_visitor, &context); |
457 } | 466 } |
458 | 467 |
459 void SkGlyphCache::VisitAll(Visitor visitor, void* context) { | 468 void SkGlyphCache::VisitAll(Visitor visitor, void* context) { |
460 SkGlyphCache_Globals& globals = get_globals(); | 469 SkGlyphCache_Globals& globals = get_globals(); |
461 AutoAcquire ac(globals.fLock); | 470 AutoAcquire ac(globals.fLock); |
462 SkGlyphCache* cache; | 471 SkGlyphCache* cache; |
463 | 472 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 } | 647 } |
639 | 648 |
640 void SkGraphics::PurgeFontCache() { | 649 void SkGraphics::PurgeFontCache() { |
641 get_globals().purgeAll(); | 650 get_globals().purgeAll(); |
642 SkTypefaceCache::PurgeAll(); | 651 SkTypefaceCache::PurgeAll(); |
643 } | 652 } |
644 | 653 |
645 // TODO(herb): clean up TLS apis. | 654 // TODO(herb): clean up TLS apis. |
646 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } | 655 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } |
647 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } | 656 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } |
OLD | NEW |