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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/core/SkGlyphCache.h ('k') | src/core/SkMaskCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkGlyphCache.h" 8 #include "SkGlyphCache.h"
9 #include "SkGlyphCache_Globals.h" 9 #include "SkGlyphCache_Globals.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return SkGlyph::ID2Code(rec.fPackedGlyphID); 97 return SkGlyph::ID2Code(rec.fPackedGlyphID);
98 } else { 98 } else {
99 return fScalerContext->charToGlyphID(charCode); 99 return fScalerContext->charToGlyphID(charCode);
100 } 100 }
101 } 101 }
102 102
103 SkUnichar SkGlyphCache::glyphToUnichar(uint16_t glyphID) { 103 SkUnichar SkGlyphCache::glyphToUnichar(uint16_t glyphID) {
104 return fScalerContext->glyphIDToChar(glyphID); 104 return fScalerContext->glyphIDToChar(glyphID);
105 } 105 }
106 106
107 unsigned SkGlyphCache::getGlyphCount() { 107 unsigned SkGlyphCache::getGlyphCount() const {
108 return fScalerContext->getGlyphCount(); 108 return fScalerContext->getGlyphCount();
109 } 109 }
110 110
111 int SkGlyphCache::countCachedGlyphs() const {
112 return fGlyphMap.count();
113 }
114
111 /////////////////////////////////////////////////////////////////////////////// 115 ///////////////////////////////////////////////////////////////////////////////
112 116
113 const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) { 117 const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) {
114 VALIDATE(); 118 VALIDATE();
115 return *this->lookupByChar(charCode, kJustAdvance_MetricsType); 119 return *this->lookupByChar(charCode, kJustAdvance_MetricsType);
116 } 120 }
117 121
118 const SkGlyph& SkGlyphCache::getGlyphIDAdvance(uint16_t glyphID) { 122 const SkGlyph& SkGlyphCache::getGlyphIDAdvance(uint16_t glyphID) {
119 VALIDATE(); 123 VALIDATE();
120 PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID); 124 PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 return cache; 399 return cache;
396 } 400 }
397 401
398 void SkGlyphCache::AttachCache(SkGlyphCache* cache) { 402 void SkGlyphCache::AttachCache(SkGlyphCache* cache) {
399 SkASSERT(cache); 403 SkASSERT(cache);
400 SkASSERT(cache->fNext == NULL); 404 SkASSERT(cache->fNext == NULL);
401 405
402 get_globals().attachCacheToHead(cache); 406 get_globals().attachCacheToHead(cache);
403 } 407 }
404 408
409 static void dump_visitor(const SkGlyphCache& cache, void* context) {
410 int* counter = (int*)context;
411 int index = *counter;
412 *counter += 1;
413
414 const SkScalerContextRec& rec = cache.getScalerContext()->getRec();
415
416 SkDebugf("[%3d] ID %3d, glyphs %3d, size %g, scale %g, skew %g, [%g %g %g %g ]\n",
417 index, rec.fFontID, cache.countCachedGlyphs(),
418 rec.fTextSize, rec.fPreScaleX, rec.fPreSkewX,
419 rec.fPost2x2[0][0], rec.fPost2x2[0][1], rec.fPost2x2[1][0], rec.fPo st2x2[1][1]);
420 }
421
405 void SkGlyphCache::Dump() { 422 void SkGlyphCache::Dump() {
423 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
424 SkDebugf(" bytes [ %8zu %8zu ]\n",
425 SkGraphics::GetFontCacheUsed(), SkGraphics::GetFontCacheLimit());
426 SkDebugf(" count [ %8zu %8zu ]\n",
427 SkGraphics::GetFontCacheCountUsed(), SkGraphics::GetFontCacheCountL imit());
428
429 int counter = 0;
430 SkGlyphCache::VisitAll(dump_visitor, &counter);
431 }
432
433 void SkGlyphCache::VisitAll(Visitor visitor, void* context) {
406 SkGlyphCache_Globals& globals = get_globals(); 434 SkGlyphCache_Globals& globals = get_globals();
407 AutoAcquire ac(globals.fLock); 435 AutoAcquire ac(globals.fLock);
408 SkGlyphCache* cache; 436 SkGlyphCache* cache;
409 437
410 globals.validate(); 438 globals.validate();
411 439
412 SkDebugf("SkGlyphCache strikes:%d memory:%d\n",
413 globals.getCacheCountUsed(), (int)globals.getTotalMemoryUsed());
414
415 for (cache = globals.internalGetHead(); cache != NULL; cache = cache->fNext) { 440 for (cache = globals.internalGetHead(); cache != NULL; cache = cache->fNext) {
416 cache->dump(); 441 visitor(*cache, context);
417 } 442 }
418 } 443 }
419 444
420 /////////////////////////////////////////////////////////////////////////////// 445 ///////////////////////////////////////////////////////////////////////////////
421 446
422 void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) { 447 void SkGlyphCache_Globals::attachCacheToHead(SkGlyphCache* cache) {
423 AutoAcquire ac(fLock); 448 AutoAcquire ac(fLock);
424 449
425 this->validate(); 450 this->validate();
426 cache->validate(); 451 cache->validate();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 612 }
588 613
589 void SkGraphics::PurgeFontCache() { 614 void SkGraphics::PurgeFontCache() {
590 get_globals().purgeAll(); 615 get_globals().purgeAll();
591 SkTypefaceCache::PurgeAll(); 616 SkTypefaceCache::PurgeAll();
592 } 617 }
593 618
594 // TODO(herb): clean up TLS apis. 619 // TODO(herb): clean up TLS apis.
595 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; } 620 size_t SkGraphics::GetTLSFontCacheLimit() { return 0; }
596 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { } 621 void SkGraphics::SetTLSFontCacheLimit(size_t bytes) { }
OLDNEW
« 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