Chromium Code Reviews| Index: src/core/SkGlyphCache.cpp |
| diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp |
| index 9b0199f6cf9f3f23b253aa77ab56276376d13055..e719c00b8352ba01f6d4252a58ab9cb1f807e50f 100755 |
| --- a/src/core/SkGlyphCache.cpp |
| +++ b/src/core/SkGlyphCache.cpp |
| @@ -104,10 +104,14 @@ SkUnichar SkGlyphCache::glyphToUnichar(uint16_t glyphID) { |
| return fScalerContext->glyphIDToChar(glyphID); |
| } |
| -unsigned SkGlyphCache::getGlyphCount() { |
| +unsigned SkGlyphCache::getGlyphCount() const { |
| return fScalerContext->getGlyphCount(); |
| } |
| +int SkGlyphCache::countCachedGlyphs() const { |
| + return fGlyphMap.count(); |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) { |
| @@ -402,18 +406,39 @@ void SkGlyphCache::AttachCache(SkGlyphCache* cache) { |
| get_globals().attachCacheToHead(cache); |
| } |
| +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]); |
| +} |
| + |
| void SkGlyphCache::Dump() { |
| + SkDebugf("GlyphCache [ used budget ]\n"); |
|
ssid
2015/08/07 23:42:11
We are looking to add these memory statistics to c
reed1
2015/08/11 13:44:19
SkGlyphCache::Dump() exists just as a client of th
|
| + SkDebugf(" bytes [ %8zu %8zu ]\n", |
| + SkGraphics::GetFontCacheUsed(), SkGraphics::GetFontCacheLimit()); |
| + SkDebugf(" count [ %8zu %8zu ]\n", |
| + SkGraphics::GetFontCacheCountUsed(), SkGraphics::GetFontCacheCountLimit()); |
| + |
| + int counter = 0; |
| + SkGlyphCache::VisitAll(dump_visitor, &counter); |
| +} |
| + |
| +void SkGlyphCache::VisitAll(Visitor visitor, void* context) { |
| SkGlyphCache_Globals& globals = get_globals(); |
| AutoAcquire ac(globals.fLock); |
| SkGlyphCache* cache; |
| globals.validate(); |
| - SkDebugf("SkGlyphCache strikes:%d memory:%d\n", |
| - globals.getCacheCountUsed(), (int)globals.getTotalMemoryUsed()); |
| - |
| for (cache = globals.internalGetHead(); cache != NULL; cache = cache->fNext) { |
| - cache->dump(); |
| + visitor(*cache, context); |
| } |
| } |