Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: src/core/SkGlyphCache.cpp

Issue 1271033002: private iterator to visit all resource cache entries (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add iter for fontcache Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkGlyphCache.h ('k') | src/core/SkMaskCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « src/core/SkGlyphCache.h ('k') | src/core/SkMaskCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698