| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 | 421 |
| 422 static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { | 422 static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { |
| 423 SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*>
(context); | 423 SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*>
(context); |
| 424 SkTraceMemoryDump* dump = dumpContext->dump; | 424 SkTraceMemoryDump* dump = dumpContext->dump; |
| 425 int* counter = dumpContext->counter; | 425 int* counter = dumpContext->counter; |
| 426 int index = *counter; | 426 int index = *counter; |
| 427 *counter += 1; | 427 *counter += 1; |
| 428 | 428 |
| 429 const SkTypeface* face = cache.getScalerContext()->getTypeface(); | 429 const SkTypeface* face = cache.getScalerContext()->getTypeface(); |
| 430 SkString font_name; | 430 SkString fontName; |
| 431 face->getFamilyName(&font_name); | 431 face->getFamilyName(&fontName); |
| 432 const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); | 432 const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); |
| 433 | 433 |
| 434 SkString dump_name = SkStringPrintf("%s/%s_%3d/index_%d", | 434 SkString dumpName = SkStringPrintf("%s/%s_%3d/index_%d", |
| 435 gGlyphCacheDumpName, font_name.c_str(),
rec.fFontID, index); | 435 gGlyphCacheDumpName, fontName.c_str(), r
ec.fFontID, index); |
| 436 | 436 |
| 437 dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", cache.getMemoryUs
ed()); | 437 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUse
d()); |
| 438 dump->dumpNumericValue(dump_name.c_str(), "glyph_count", "objects", cache.co
untCachedGlyphs()); | 438 dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.cou
ntCachedGlyphs()); |
| 439 dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr); | 439 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |
| 440 } | 440 } |
| 441 | 441 |
| 442 void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 442 void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
| 443 dump->dumpNumericValue(gGlyphCacheDumpName, "size", "bytes", SkGraphics::Get
FontCacheUsed()); | 443 dump->dumpNumericValue(gGlyphCacheDumpName, "size", "bytes", SkGraphics::Get
FontCacheUsed()); |
| 444 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_size", "bytes", | 444 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_size", "bytes", |
| 445 SkGraphics::GetFontCacheLimit()); | 445 SkGraphics::GetFontCacheLimit()); |
| 446 dump->dumpNumericValue(gGlyphCacheDumpName, "glyph_count", "objects", | 446 dump->dumpNumericValue(gGlyphCacheDumpName, "glyph_count", "objects", |
| 447 SkGraphics::GetFontCacheCountUsed()); | 447 SkGraphics::GetFontCacheCountUsed()); |
| 448 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_glyph_count", "objects", | 448 dump->dumpNumericValue(gGlyphCacheDumpName, "budget_glyph_count", "objects", |
| 449 SkGraphics::GetFontCacheCountLimit()); | 449 SkGraphics::GetFontCacheCountLimit()); |
| 450 | 450 |
| 451 if (dump->getRequestedDetails() == SkTraceMemoryDump::kLight_LevelOfDetail)
{ |
| 452 dump->setMemoryBacking(gGlyphCacheDumpName, "malloc", nullptr); |
| 453 return; |
| 454 } |
| 455 |
| 451 int counter = 0; | 456 int counter = 0; |
| 452 SkGlyphCacheDumpContext context = { &counter, dump }; | 457 SkGlyphCacheDumpContext context = { &counter, dump }; |
| 453 SkGlyphCache::VisitAll(sk_trace_dump_visitor, &context); | 458 SkGlyphCache::VisitAll(sk_trace_dump_visitor, &context); |
| 454 } | 459 } |
| 455 | 460 |
| 456 void SkGlyphCache::VisitAll(Visitor visitor, void* context) { | 461 void SkGlyphCache::VisitAll(Visitor visitor, void* context) { |
| 457 SkGlyphCache_Globals& globals = get_globals(); | 462 SkGlyphCache_Globals& globals = get_globals(); |
| 458 AutoAcquire ac(globals.fLock); | 463 AutoAcquire ac(globals.fLock); |
| 459 SkGlyphCache* cache; | 464 SkGlyphCache* cache; |
| 460 | 465 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 640 } |
| 636 | 641 |
| 637 void SkGraphics::PurgeFontCache() { | 642 void SkGraphics::PurgeFontCache() { |
| 638 get_globals().purgeAll(); | 643 get_globals().purgeAll(); |
| 639 SkTypefaceCache::PurgeAll(); | 644 SkTypefaceCache::PurgeAll(); |
| 640 } | 645 } |
| 641 | 646 |
| 642 // TODO(herb): clean up TLS apis. | 647 // TODO(herb): clean up TLS apis. |
| 643 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } | 648 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } |
| 644 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } | 649 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } |
| OLD | NEW |