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

Unified Diff: src/core/SkGlyphCache.cpp

Issue 881953002: patch from issue 885453002 at patchset 20001 (http://crrev.com/885453002#ps20001) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | « src/core/SkGlyphCache.h ('k') | 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 1cbfcd8e6e9fa235610a0c459b469a1e8a4ff718..bf63ab26eacf9408fddc8ab8dda15a8352926cad 100755
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -86,9 +86,7 @@ SkGlyphCache::SkGlyphCache(SkTypeface* typeface, const SkDescriptor* desc, SkSca
// 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);
@@ -116,8 +114,8 @@ SkGlyphCache::~SkGlyphCache() {
}
}
- 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);
+ 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);
}
#endif
@@ -135,6 +133,16 @@ SkGlyphCache::~SkGlyphCache() {
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
@@ -146,7 +154,7 @@ SkGlyphCache::~SkGlyphCache() {
uint16_t SkGlyphCache::unicharToGlyph(SkUnichar charCode) {
VALIDATE();
uint32_t id = SkGlyph::MakeID(charCode);
- const CharGlyphRec& rec = fCharToGlyphHash[ID2HashIndex(id)];
+ const CharGlyphRec& rec = *this->getCharGlyphRec(id);
if (rec.fID == id) {
return rec.fGlyph->getGlyphID();
@@ -168,7 +176,7 @@ unsigned SkGlyphCache::getGlyphCount() {
const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) {
VALIDATE();
uint32_t id = SkGlyph::MakeID(charCode);
- CharGlyphRec* rec = &fCharToGlyphHash[ID2HashIndex(id)];
+ CharGlyphRec* rec = this->getCharGlyphRec(id);
if (rec->fID != id) {
// this ID is based on the UniChar
@@ -198,7 +206,7 @@ const SkGlyph& SkGlyphCache::getGlyphIDAdvance(uint16_t glyphID) {
const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode) {
VALIDATE();
uint32_t id = SkGlyph::MakeID(charCode);
- CharGlyphRec* rec = &fCharToGlyphHash[ID2HashIndex(id)];
+ CharGlyphRec* rec = this->getCharGlyphRec(id);
if (rec->fID != id) {
RecordHashCollisionIf(rec->fGlyph != NULL);
@@ -221,7 +229,7 @@ const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode,
SkFixed x, SkFixed y) {
VALIDATE();
uint32_t id = SkGlyph::MakeID(charCode, x, y);
- CharGlyphRec* rec = &fCharToGlyphHash[ID2HashIndex(id)];
+ CharGlyphRec* rec = this->getCharGlyphRec(id);
if (rec->fID != id) {
RecordHashCollisionIf(rec->fGlyph != NULL);
« no previous file with comments | « src/core/SkGlyphCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698