OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #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.
| |
9 | |
8 #include "SkGlyphCache.h" | 10 #include "SkGlyphCache.h" |
9 #include "SkGlyphCache_Globals.h" | 11 #include "SkGlyphCache_Globals.h" |
10 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
11 #include "SkOncePtr.h" | 13 #include "SkOncePtr.h" |
12 #include "SkPath.h" | 14 #include "SkPath.h" |
13 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
14 #include "SkTraceMemoryDump.h" | 16 #include "SkTraceMemoryDump.h" |
15 #include "SkTypeface.h" | 17 #include "SkTypeface.h" |
16 | 18 |
17 //#define SPEW_PURGE_STATUS | 19 //#define SPEW_PURGE_STATUS |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 } | 422 } |
421 | 423 |
422 static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { | 424 static void sk_trace_dump_visitor(const SkGlyphCache& cache, void* context) { |
423 SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*> (context); | 425 SkGlyphCacheDumpContext* dumpContext = static_cast<SkGlyphCacheDumpContext*> (context); |
424 SkTraceMemoryDump* dump = dumpContext->dump; | 426 SkTraceMemoryDump* dump = dumpContext->dump; |
425 int* counter = dumpContext->counter; | 427 int* counter = dumpContext->counter; |
426 int index = *counter; | 428 int index = *counter; |
427 *counter += 1; | 429 *counter += 1; |
428 | 430 |
429 const SkTypeface* face = cache.getScalerContext()->getTypeface(); | 431 const SkTypeface* face = cache.getScalerContext()->getTypeface(); |
432 const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); | |
433 | |
430 SkString fontName; | 434 SkString fontName; |
431 face->getFamilyName(&fontName); | 435 face->getFamilyName(&fontName); |
432 const SkScalerContextRec& rec = cache.getScalerContext()->getRec(); | 436 // Dump only alpha numeric characters in font name, to avoid '/' or special chars. |
437 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.
| |
438 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.
| |
439 if (isalnum(fontName[index])) { | |
Primiano Tucci (use gerrit)
2015/09/22 17:30:35
std::isalnum
ssid
2015/09/23 13:11:40
Done.
| |
440 strippedName += fontName[index]; | |
441 } | |
Primiano Tucci (use gerrit)
2015/09/22 17:30:35
else: += '_'
ssid
2015/09/23 13:11:40
Done.
| |
442 } | |
433 | 443 |
434 SkString dumpName = SkStringPrintf("%s/%s_%3d/index_%d", | 444 SkString dumpName = SkStringPrintf("%s/%s_%d/index_%d", |
435 gGlyphCacheDumpName, fontName.c_str(), r ec.fFontID, index); | 445 gGlyphCacheDumpName, strippedName.c_str() , rec.fFontID, |
446 index); | |
436 | 447 |
437 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUse d()); | 448 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", cache.getMemoryUse d()); |
438 dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.cou ntCachedGlyphs()); | 449 dump->dumpNumericValue(dumpName.c_str(), "glyph_count", "objects", cache.cou ntCachedGlyphs()); |
439 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); | 450 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |
440 } | 451 } |
441 | 452 |
442 void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 453 void SkGlyphCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
443 if (!(dump->getRequestedDetails() & (SkTraceMemoryDump::kMemoryTotals | | 454 if (!(dump->getRequestedDetails() & (SkTraceMemoryDump::kMemoryTotals | |
444 SkTraceMemoryDump::kMallocDetails))) { | 455 SkTraceMemoryDump::kMallocDetails))) { |
445 return; | 456 return; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 } | 656 } |
646 | 657 |
647 void SkGraphics::PurgeFontCache() { | 658 void SkGraphics::PurgeFontCache() { |
648 get_globals().purgeAll(); | 659 get_globals().purgeAll(); |
649 SkTypefaceCache::PurgeAll(); | 660 SkTypefaceCache::PurgeAll(); |
650 } | 661 } |
651 | 662 |
652 // TODO(herb): clean up TLS apis. | 663 // TODO(herb): clean up TLS apis. |
653 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } | 664 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } |
654 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } | 665 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } |
OLD | NEW |