Index: src/core/SkGlyphCache.cpp |
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp |
index 309707c66fede82e8ee775b7d545b3984e44001f..f83aab5942f1cc3741c064a8bd5256acb3216c1b 100644 |
--- a/src/core/SkGlyphCache.cpp |
+++ b/src/core/SkGlyphCache.cpp |
@@ -119,40 +119,40 @@ |
const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) { |
VALIDATE(); |
- return *this->lookupByChar(charCode); |
+ return *this->lookupByChar(charCode, kJustAdvance_MetricsType); |
} |
const SkGlyph& SkGlyphCache::getGlyphIDAdvance(uint16_t glyphID) { |
VALIDATE(); |
PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID); |
- return *this->lookupByPackedGlyphID(packedGlyphID); |
+ return *this->lookupByPackedGlyphID(packedGlyphID, kJustAdvance_MetricsType); |
} |
/////////////////////////////////////////////////////////////////////////////// |
const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode) { |
VALIDATE(); |
- return *this->lookupByChar(charCode); |
+ return *this->lookupByChar(charCode, kFull_MetricsType); |
} |
const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode, SkFixed x, SkFixed y) { |
VALIDATE(); |
- return *this->lookupByChar(charCode, x, y); |
+ return *this->lookupByChar(charCode, kFull_MetricsType, x, y); |
} |
const SkGlyph& SkGlyphCache::getGlyphIDMetrics(uint16_t glyphID) { |
VALIDATE(); |
PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID); |
- return *this->lookupByPackedGlyphID(packedGlyphID); |
+ return *this->lookupByPackedGlyphID(packedGlyphID, kFull_MetricsType); |
} |
const SkGlyph& SkGlyphCache::getGlyphIDMetrics(uint16_t glyphID, SkFixed x, SkFixed y) { |
VALIDATE(); |
PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID, x, y); |
- return *this->lookupByPackedGlyphID(packedGlyphID); |
-} |
- |
-SkGlyph* SkGlyphCache::lookupByChar(SkUnichar charCode, SkFixed x, SkFixed y) { |
+ return *this->lookupByPackedGlyphID(packedGlyphID, kFull_MetricsType); |
+} |
+ |
+SkGlyph* SkGlyphCache::lookupByChar(SkUnichar charCode, MetricsType type, SkFixed x, SkFixed y) { |
PackedUnicharID id = SkGlyph::MakeID(charCode, x, y); |
CharGlyphRec* rec = this->getCharGlyphRec(id); |
if (rec->fPackedUnicharID != id) { |
@@ -161,21 +161,26 @@ |
// this ID is based on the glyph index |
PackedGlyphID combinedID = SkGlyph::MakeID(fScalerContext->charToGlyphID(charCode), x, y); |
rec->fPackedGlyphID = combinedID; |
- return this->lookupByPackedGlyphID(combinedID); |
+ return this->lookupByPackedGlyphID(combinedID, type); |
} else { |
- return this->lookupByPackedGlyphID(rec->fPackedGlyphID); |
- } |
-} |
- |
-SkGlyph* SkGlyphCache::lookupByPackedGlyphID(PackedGlyphID packedGlyphID) { |
+ return this->lookupByPackedGlyphID(rec->fPackedGlyphID, type); |
+ } |
+} |
+ |
+SkGlyph* SkGlyphCache::lookupByPackedGlyphID(PackedGlyphID packedGlyphID, MetricsType type) { |
SkGlyph* glyph = fGlyphMap.find(packedGlyphID); |
+ |
if (nullptr == glyph) { |
- glyph = this->allocateNewGlyph(packedGlyphID); |
+ glyph = this->allocateNewGlyph(packedGlyphID, type); |
+ } else { |
+ if (type == kFull_MetricsType && glyph->isJustAdvance()) { |
+ fScalerContext->getMetrics(glyph); |
+ } |
} |
return glyph; |
} |
-SkGlyph* SkGlyphCache::allocateNewGlyph(PackedGlyphID packedGlyphID) { |
+SkGlyph* SkGlyphCache::allocateNewGlyph(PackedGlyphID packedGlyphID, MetricsType mtype) { |
fMemoryUsed += sizeof(SkGlyph); |
SkGlyph* glyphPtr; |
@@ -184,7 +189,13 @@ |
glyph.initGlyphFromCombinedID(packedGlyphID); |
glyphPtr = fGlyphMap.set(glyph); |
} |
- fScalerContext->getMetrics(glyphPtr); |
+ |
+ if (kJustAdvance_MetricsType == mtype) { |
+ fScalerContext->getAdvance(glyphPtr); |
+ } else { |
+ SkASSERT(kFull_MetricsType == mtype); |
+ fScalerContext->getMetrics(glyphPtr); |
+ } |
SkASSERT(glyphPtr->fID != SkGlyph::kImpossibleID); |
return glyphPtr; |