diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkGlyphCache.cpp | 13 | ||||
-rw-r--r-- | src/core/SkGlyphCache.h | 5 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index 6d978a6b5f..40d599717d 100644 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -91,12 +91,17 @@ SkGlyphCache::CharGlyphRec* SkGlyphCache::getCharGlyphRec(PackedUnicharID packed uint16_t SkGlyphCache::unicharToGlyph(SkUnichar charCode) { VALIDATE(); PackedUnicharID packedUnicharID = SkGlyph::MakeID(charCode); - const CharGlyphRec& rec = *this->getCharGlyphRec(packedUnicharID); + CharGlyphRec* rec = this->getCharGlyphRec(packedUnicharID); - if (rec.fPackedUnicharID == packedUnicharID) { - return SkGlyph::ID2Code(rec.fPackedGlyphID); + if (rec->fPackedUnicharID == packedUnicharID) { + // The glyph exists in the unichar to glyph mapping cache. Return it. + return SkGlyph::ID2Code(rec->fPackedGlyphID); } else { - return fScalerContext->charToGlyphID(charCode); + // The glyph is not in the unichar to glyph mapping cache. Insert it. + rec->fPackedUnicharID = packedUnicharID; + uint16_t glyphID = fScalerContext->charToGlyphID(charCode); + rec->fPackedGlyphID = SkGlyph::MakeID(glyphID); + return glyphID; } } diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h index 2a96370045..84a32eb3ef 100644 --- a/src/core/SkGlyphCache.h +++ b/src/core/SkGlyphCache.h @@ -227,8 +227,7 @@ private: SkGlyph* lookupByChar(SkUnichar id, MetricsType type, SkFixed x = 0, SkFixed y = 0); // Return a new SkGlyph for the glyph ID and subpixel position id. Limit the amount - // of work - // using type. + // of work using type. SkGlyph* allocateNewGlyph(PackedGlyphID packedGlyphID, MetricsType type); static bool DetachProc(const SkGlyphCache*, void*) { return true; } @@ -238,8 +237,6 @@ private: void invokeAndRemoveAuxProcs(); - inline static SkGlyphCache* FindTail(SkGlyphCache* head); - static void OffsetResults(const SkGlyph::Intercept* intercept, SkScalar scale, SkScalar xPos, SkScalar* array, int* count); static void AddInterval(SkScalar val, SkGlyph::Intercept* intercept); |