diff options
author | mtklein <mtklein@google.com> | 2015-01-27 15:39:19 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-27 15:39:19 -0800 |
commit | 25b76119e949fb064c840003a2e92633c25e8cdf (patch) | |
tree | df0f3cd69bb54761fd04e42f622bcb6938d442cf /src | |
parent | d5a7db4a867c7e6ccf8451a053d987b470099198 (diff) |
Revert of patch from issue 885453002 at patchset 20001 (http://crrev.com/885453002#ps20001) (patchset #1 id:1 of https://codereview.chromium.org/881953002/)
Reason for revert:
==32435==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x621000d8cd00
Lots of info here:
http://build.chromium.org/p/client.skia/builders/Test-Ubuntu13.10-GCE-NoGPU-x86_64-Debug-ASAN/builds/1198/steps/dm/logs/stdio
Original issue's description:
> patch from issue 885453002 at patchset 20001 (http://crrev.com/885453002#ps20001)
>
> Make the char cache dynamic in SkGlyphCache
> because it is rarely used.
>
> Landing on behalf of Herb.
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/95faa61d63a6f62916f6f7be58c4624da8357e3b
TBR=mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/881023003
Diffstat (limited to 'src')
-rwxr-xr-x | src/core/SkGlyphCache.cpp | 26 | ||||
-rw-r--r-- | src/core/SkGlyphCache.h | 5 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index bf63ab26ea..1cbfcd8e6e 100755 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -86,7 +86,9 @@ 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); @@ -114,8 +116,8 @@ SkGlyphCache::~SkGlyphCache() { } } - 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 @@ 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 @@ -154,7 +146,7 @@ SkGlyphCache::CharGlyphRec* SkGlyphCache::getCharGlyphRec(uint32_t id) { 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 @@ unsigned SkGlyphCache::getGlyphCount() { 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::getGlyphIDAdvance(uint16_t glyphID) { 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 @@ const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode, 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); diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h index a0d4afbc46..bb34a7d977 100644 --- a/src/core/SkGlyphCache.h +++ b/src/core/SkGlyphCache.h @@ -202,10 +202,7 @@ private: SkGlyph* fGlyph; }; // no reason to use the same kHashCount as fGlyphHash, but we do for now - // Dynamically allocated when chars are encountered. - SkAutoTDelete<CharGlyphRec> fCharToGlyphHash; - - CharGlyphRec* getCharGlyphRec(uint32_t id); + CharGlyphRec fCharToGlyphHash[kHashCount]; static inline unsigned ID2HashIndex(uint32_t id) { id ^= id >> 16; |