aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-08-17 13:51:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-17 13:51:54 -0700
commit1ae57b37bd718418f564e13675b5cfebe499f7db (patch)
tree65b5bbc39e829ca144401fa35e193add3b0468ca /src
parent0e7bddfb340a558f1ef0f554e64b4339ca939aea (diff)
Eagerly update the unichar to glyphID mapping.
In addition, some small cleanups. BUG=chromium:635005 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2249063005 Review-Url: https://codereview.chromium.org/2249063005
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGlyphCache.cpp13
-rw-r--r--src/core/SkGlyphCache.h5
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);