[tracing] Remove counter logic and just use address on glyph cache dumps

This CL removes the logic of counting the index of glyphs and uses the
address of the glyph object for dump name. This makes the dump names
consistent across multiple dumps.

BUG=543479

Review URL: https://codereview.chromium.org/1425443002
This commit is contained in:
ssid 2015-10-23 10:49:35 -07:00 committed by Commit bot
parent 546dc3294d
commit 93775bd279

View File

@ -19,15 +19,7 @@
//#define SPEW_PURGE_STATUS
namespace {
const char gGlyphCacheDumpName[] = "skia/sk_glyph_cache";
// Used to pass context to the sk_trace_dump_visitor.
struct SkGlyphCacheDumpContext {
int* counter;
SkTraceMemoryDump* dump;
};
} // namespace
// Returns the shared globals
@ -433,11 +425,7 @@ void SkGlyphCache::Dump() {
}
static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) {
SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*>(context);
SkTraceMemoryDump* dump = dumpContext->dump;
int* counter = dumpContext->counter;
int index = *counter;
*counter += 1;
SkTraceMemoryDump* dump = static_cast<SkTraceMemoryDump*>(context);
const SkTypeface* face = cache.getScalerContext()->getTypeface();
const SkScalerContextRec& rec = cache.getScalerContext()->getRec();
@ -451,8 +439,8 @@ static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) {
}
}
SkString dumpName = SkStringPrintf("%s/%s_%d/index_%d",
gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, 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());
@ -473,9 +461,7 @@ void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) {
return;
}
int counter = 0;
SkGlyphCacheDumpContext context = { &counter, dump };
SkGlyphCache::VisitAll(sk_trace_dump_visitor, &context);
SkGlyphCache::VisitAll(sk_trace_dump_visitor, dump);
}
void SkGlyphCache::VisitAll(Visitor visitor, void* context) {