Index: src/core/SkGlyphCache.cpp |
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp |
index bf63ab26eacf9408fddc8ab8dda15a8352926cad..1cbfcd8e6e9fa235610a0c459b469a1e8a4ff718 100755 |
--- a/src/core/SkGlyphCache.cpp |
+++ b/src/core/SkGlyphCache.cpp |
@@ -86,7 +86,9 @@ |
// init to 0 so that all of the pointers will be null |
memset(fGlyphHash, 0, sizeof(fGlyphHash)); |
- |
+ // init with 0xFF so that the charCode field will be -1, which is invalid |
+ memset(fCharToGlyphHash, 0xFF, sizeof(fCharToGlyphHash)); |
+ |
fMemoryUsed = sizeof(*this); |
fGlyphArray.setReserve(kMinGlyphCount); |
@@ -114,8 +116,8 @@ |
} |
} |
- SkDebugf("glyphPtrArray,%zu, Alloc,%zu, imageUsed,%zu, glyphUsed,%zu, glyphHashAlloc,%zu, glyphHashUsed,%zu, unicharHashAlloc,%zu, unicharHashUsed,%zu\n", |
- ptrMem, glyphAlloc, imageUsed, glyphUsed, sizeof(fGlyphHash), glyphHashUsed, sizeof(CharGlyphRec) * kHashCount, uniHashUsed); |
+ printf("glyphPtrArray,%zu, Alloc,%zu, imageUsed,%zu, glyphUsed,%zu, glyphHashAlloc,%zu, glyphHashUsed,%zu, unicharHashAlloc,%zu, unicharHashUsed,%zu\n", |
+ ptrMem, glyphAlloc, imageUsed, glyphUsed, sizeof(fGlyphHash), glyphHashUsed, sizeof(fCharToGlyphHash), uniHashUsed); |
} |
#endif |
@@ -133,16 +135,6 @@ |
this->invokeAndRemoveAuxProcs(); |
} |
-SkGlyphCache::CharGlyphRec* SkGlyphCache::getCharGlyphRec(uint32_t id) { |
- if (NULL == fCharToGlyphHash) { |
- fCharToGlyphHash.reset(new CharGlyphRec[kHashCount]); |
- // init with 0xFF so that the charCode field will be -1, which is invalid |
- memset(fCharToGlyphHash, 0xFF, sizeof(CharGlyphRec) * kHashCount); |
- } |
- |
- return &fCharToGlyphHash[ID2HashIndex(id)]; |
-} |
- |
/////////////////////////////////////////////////////////////////////////////// |
#ifdef SK_DEBUG |
@@ -154,7 +146,7 @@ |
uint16_t SkGlyphCache::unicharToGlyph(SkUnichar charCode) { |
VALIDATE(); |
uint32_t id = SkGlyph::MakeID(charCode); |
- const CharGlyphRec& rec = *this->getCharGlyphRec(id); |
+ const CharGlyphRec& rec = fCharToGlyphHash[ID2HashIndex(id)]; |
if (rec.fID == id) { |
return rec.fGlyph->getGlyphID(); |
@@ -176,7 +168,7 @@ |
const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) { |
VALIDATE(); |
uint32_t id = SkGlyph::MakeID(charCode); |
- CharGlyphRec* rec = this->getCharGlyphRec(id); |
+ CharGlyphRec* rec = &fCharToGlyphHash[ID2HashIndex(id)]; |
if (rec->fID != id) { |
// this ID is based on the UniChar |
@@ -206,7 +198,7 @@ |
const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode) { |
VALIDATE(); |
uint32_t id = SkGlyph::MakeID(charCode); |
- CharGlyphRec* rec = this->getCharGlyphRec(id); |
+ CharGlyphRec* rec = &fCharToGlyphHash[ID2HashIndex(id)]; |
if (rec->fID != id) { |
RecordHashCollisionIf(rec->fGlyph != NULL); |
@@ -229,7 +221,7 @@ |
SkFixed x, SkFixed y) { |
VALIDATE(); |
uint32_t id = SkGlyph::MakeID(charCode, x, y); |
- CharGlyphRec* rec = this->getCharGlyphRec(id); |
+ CharGlyphRec* rec = &fCharToGlyphHash[ID2HashIndex(id)]; |
if (rec->fID != id) { |
RecordHashCollisionIf(rec->fGlyph != NULL); |