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

Unified Diff: src/core/SkGlyphCache.cpp

Issue 1346993006: Strip font name of special characters before dumping (Closed) Base URL: https://chromium.googlesource.com/skia.git@resource
Patch Set: Nits. Created 5 years, 3 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 | « no previous file | src/core/SkResourceCache.cpp » ('j') | src/core/SkResourceCache.cpp » ('J')
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 51ed657861eeefea0bd5c965a82ef5acfc8ef607..a8de2c6e5e5ff103aa3962436e796dedd98efe61 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -14,6 +14,8 @@
#include "SkTraceMemoryDump.h"
#include "SkTypeface.h"
+#include <string>
+
//#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) {
reed1 2015/09/23 13:21:29 What is the formal requirement for strings in your
ssid 2015/09/23 13:30:22 Ah yes. So the dump name is required to be seperat
+ 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());
« no previous file with comments | « no previous file | src/core/SkResourceCache.cpp » ('j') | src/core/SkResourceCache.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698