static void dump_visitor(const SkGlyphCache& cache, void* context) { int* counter = (int*)context; int index = *counter; *counter += 1; const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); SkDebugf("[%3d] ID %3d, glyphs %3d, size %g, scale %g, skew %g, [%g %g %g %g]\n", index, rec.fFontID, cache.countCachedGlyphs(), rec.fTextSize, rec.fPreScaleX, rec.fPreSkewX, rec.fPost2x2[0][0], rec.fPost2x2[0][1], rec.fPost2x2[1][0], rec.fPost2x2[1][1]); }
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); }