static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context) { SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context); SkString dump_name = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getCategory(), &rec); SkDiscardableMemory* discardable = rec.diagnostic_only_getDiscardable(); if (discardable) { dump->setDiscardableMemoryBacking(dump_name.c_str(), *discardable); } else { dump->dumpNumericValue(dump_name.c_str(), "size", "bytes", rec.bytesUsed()); dump->setMemoryBacking(dump_name.c_str(), "malloc", nullptr); } }
static void sk_trace_dump_visitor(const SkResourceCache::Rec& rec, void* context) { SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context); SkString dumpName = SkStringPrintf("skia/sk_resource_cache/%s_%p", rec.getCategory(), &rec); 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); } }
static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context); const SkTypeface* face = cache.getScalerContext()->getTypeface(); const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); SkString fontName; face->getFamilyName(&fontName); // 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_%d/%p", gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, &cache); dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUsed()); dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.countCachedGlyphs()); dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); }