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

Unified Diff: src/core/SkGlyphCache.cpp

Issue 2249063005: Eagerly update the unichar to glyphID mapping. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: What was I thinking? Created 4 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 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 6d978a6b5fd2d53302b9724693e9b48868c6b7c8..40d599717d0423031680f760b123c8f89ef100f4 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;
}
}
« 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