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

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: 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 | no next file » | 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 51ed657861eeefea0bd5c965a82ef5acfc8ef607..4bde762585ee88fdc006d25c3896dd5e65d4da50 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -5,6 +5,8 @@
* found in the LICENSE file.
*/
+#include <ctype.h>
Primiano Tucci (use gerrit) 2015/09/22 17:30:35 you don't need ctype, just <string>
ssid 2015/09/23 13:11:41 Done.
+
#include "SkGlyphCache.h"
#include "SkGlyphCache_Globals.h"
#include "SkGraphics.h"
@@ -427,12 +429,21 @@ 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();
+ // Dump only alpha numeric characters in font name, to avoid '/' or special chars.
+ SkString strippedName;
Primiano Tucci (use gerrit) 2015/09/22 17:30:35 you can make this more efficient giving a capacity
ssid 2015/09/23 13:11:40 Done.
+ for (int index = 0; index < fontName.size(); ++index) {
Primiano Tucci (use gerrit) 2015/09/22 17:30:35 nit: size_t
ssid 2015/09/23 13:11:40 Done.
+ if (isalnum(fontName[index])) {
Primiano Tucci (use gerrit) 2015/09/22 17:30:35 std::isalnum
ssid 2015/09/23 13:11:40 Done.
+ strippedName += fontName[index];
+ }
Primiano Tucci (use gerrit) 2015/09/22 17:30:35 else: += '_'
ssid 2015/09/23 13:11:40 Done.
+ }
- SkString dumpName = SkStringPrintf("%s/%s_%3d/index_%d",
- gGlyphCacheDumpName, fontName.c_str(), rec.fFontID, index);
+ SkString dumpName = SkStringPrintf("%s/%s_%d/index_%d",
+ gGlyphCacheDumpName, strippedName.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 | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698