diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkGlyphCache.cpp | 15 | ||||
-rw-r--r-- | src/core/SkResourceCache.cpp | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index 3f64d6ed48..ed158d3600 100644 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -14,6 +14,8 @@ #include "SkTraceMemoryDump.h" #include "SkTypeface.h" +#include <cctype> + //#define SPEW_PURGE_STATUS namespace { @@ -427,12 +429,19 @@ static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { *counter += 1; const SkTypeface* face = cache.getScalerContext()->getTypeface(); + const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); + SkString fontName; face->getFamilyName(&fontName); - const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); + // Replace all special characters with '_'. + for (size_t index = 0; index < fontName.size(); ++index) { + if (!std::isalnum(fontName[index])) { + fontName[index] = '_'; + } + } - SkString dumpName = SkStringPrintf("%s/%s_%3d/index_%d", - gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, index); + SkString dumpName = SkStringPrintf("%s/%s_%d/index_%d", + gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, index); dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUsed()); dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.countCachedGlyphs()); diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp index a1234e1fef..240d1977e5 100644 --- a/src/core/SkResourceCache.cpp +++ b/src/core/SkResourceCache.cpp @@ -679,6 +679,10 @@ static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable(); if (discardable) { dump->setDiscardableMemoryBacking(dumpName.c_str(), *discardable); + + // The discardable memory size will be calculated by dumper, but we also dump what we think + // the size of object in memory is irrespective of whether object is live or dead. + dump->dumpNumericValue(dumpName.c_str(), "discardable_size", "bytes", rec.bytesUsed()); } else { dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed()); dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |