aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphCache.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-08-19 12:25:40 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-19 12:25:41 -0700
commit216b643fc77e754a3fabbb0ed397e7cf55d1954d (patch)
tree32e75226963e5cbeab12a9e4acfd380a7ff7096d /src/core/SkGlyphCache.cpp
parentfea7763140ba74b78f2c30028452e250140b6f21 (diff)
private iterator to visit all resource cache entries
BUG=skia: TBR= Review URL: https://codereview.chromium.org/1271033002
Diffstat (limited to 'src/core/SkGlyphCache.cpp')
-rwxr-xr-xsrc/core/SkGlyphCache.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index 9b0199f6cf..e719c00b83 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");
+ 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);
}
}