diff options
author | ssid <ssid@chromium.org> | 2015-10-01 12:41:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-01 12:41:35 -0700 |
commit | 60df542afc3b792c6d563db2dfe233f65a2c3632 (patch) | |
tree | 0d1dba947bc107ef600b78ca5238628a6696db40 /src/core/SkGlyphCache.cpp | |
parent | 77a53de20d723ca21cc824fd97e68aaa60e022ea (diff) |
Strip font name of special characters before dumping
The font name can contain special characters in some OS that is
considered as delimiters ('/') by the traces. This causes error in the
dump name. This CL strips the fone name obtained before adding it to
traces.
This also adds discardable memory size for resources in cache.
BUG=532838
Review URL: https://codereview.chromium.org/1346993006
Diffstat (limited to 'src/core/SkGlyphCache.cpp')
-rw-r--r-- | src/core/SkGlyphCache.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index 3f64d6ed48..ed158d3600 100644 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -14,6 +14,8 @@ #include "SkTraceMemoryDump.h" #include "SkTypeface.h" +#include <cctype> + //#define SPEW_PURGE_STATUS namespace { @@ -427,12 +429,19 @@ static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { *counter += 1; const SkTypeface* face = cache.getScalerContext()->getTypeface(); + const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); + SkString fontName; face->getFamilyName(&fontName); - const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); + // 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_%3d/index_%d", - gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, index); + SkString dumpName = SkStringPrintf("%s/%s_%d/index_%d", + gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, index); dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUsed()); dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.countCachedGlyphs()); |