diff options
author | mtklein <mtklein@chromium.org> | 2015-09-01 12:32:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-01 12:32:24 -0700 |
commit | 518a2923f11b819fa44ed5cff54155326959540f (patch) | |
tree | 00d70a7cc7549bdddd462c4b557f728e1290b15c /src/core/SkGlyphCache.cpp | |
parent | 86e90fafe17321964d975e9a6e2f242df280e74e (diff) |
Stop using SkScalerContext::getAdvance() in SkGlyphCache.
We think it'll simplify things to just always get the full metrics.
On most platforms, it's no different, and we think the platforms that
do differ (FreeType) will be nearly just as cheap.
Removing this distinction helps us make SkGlyphCaches concurrent by
removing a state (we-have-only-advances) from its logical state machine.
We see no significant changes running SKPs before and after this CL.
That makes sense, of course, because the SKPs bake some of this into drawPosText.
BUG=skia:
Review URL: https://codereview.chromium.org/1321243004
Diffstat (limited to 'src/core/SkGlyphCache.cpp')
-rw-r--r-- | src/core/SkGlyphCache.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp index f83aab5942..309707c66f 100644 --- a/src/core/SkGlyphCache.cpp +++ b/src/core/SkGlyphCache.cpp @@ -119,40 +119,40 @@ int SkGlyphCache::countCachedGlyphs() const { const SkGlyph& SkGlyphCache::getUnicharAdvance(SkUnichar charCode) { VALIDATE(); - return *this->lookupByChar(charCode, kJustAdvance_MetricsType); + return *this->lookupByChar(charCode); } const SkGlyph& SkGlyphCache::getGlyphIDAdvance(uint16_t glyphID) { VALIDATE(); PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID); - return *this->lookupByPackedGlyphID(packedGlyphID, kJustAdvance_MetricsType); + return *this->lookupByPackedGlyphID(packedGlyphID); } /////////////////////////////////////////////////////////////////////////////// const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode) { VALIDATE(); - return *this->lookupByChar(charCode, kFull_MetricsType); + return *this->lookupByChar(charCode); } const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode, SkFixed x, SkFixed y) { VALIDATE(); - return *this->lookupByChar(charCode, kFull_MetricsType, x, y); + return *this->lookupByChar(charCode, x, y); } const SkGlyph& SkGlyphCache::getGlyphIDMetrics(uint16_t glyphID) { VALIDATE(); PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID); - return *this->lookupByPackedGlyphID(packedGlyphID, kFull_MetricsType); + return *this->lookupByPackedGlyphID(packedGlyphID); } const SkGlyph& SkGlyphCache::getGlyphIDMetrics(uint16_t glyphID, SkFixed x, SkFixed y) { VALIDATE(); PackedGlyphID packedGlyphID = SkGlyph::MakeID(glyphID, x, y); - return *this->lookupByPackedGlyphID(packedGlyphID, kFull_MetricsType); + return *this->lookupByPackedGlyphID(packedGlyphID); } -SkGlyph* SkGlyphCache::lookupByChar(SkUnichar charCode, MetricsType type, SkFixed x, SkFixed y) { +SkGlyph* SkGlyphCache::lookupByChar(SkUnichar charCode, SkFixed x, SkFixed y) { PackedUnicharID id = SkGlyph::MakeID(charCode, x, y); CharGlyphRec* rec = this->getCharGlyphRec(id); if (rec->fPackedUnicharID != id) { @@ -161,26 +161,21 @@ SkGlyph* SkGlyphCache::lookupByChar(SkUnichar charCode, MetricsType type, SkFixe // this ID is based on the glyph index PackedGlyphID combinedID = SkGlyph::MakeID(fScalerContext->charToGlyphID(charCode), x, y); rec->fPackedGlyphID = combinedID; - return this->lookupByPackedGlyphID(combinedID, type); + return this->lookupByPackedGlyphID(combinedID); } else { - return this->lookupByPackedGlyphID(rec->fPackedGlyphID, type); + return this->lookupByPackedGlyphID(rec->fPackedGlyphID); } } -SkGlyph* SkGlyphCache::lookupByPackedGlyphID(PackedGlyphID packedGlyphID, MetricsType type) { +SkGlyph* SkGlyphCache::lookupByPackedGlyphID(PackedGlyphID packedGlyphID) { SkGlyph* glyph = fGlyphMap.find(packedGlyphID); - if (nullptr == glyph) { - glyph = this->allocateNewGlyph(packedGlyphID, type); - } else { - if (type == kFull_MetricsType && glyph->isJustAdvance()) { - fScalerContext->getMetrics(glyph); - } + glyph = this->allocateNewGlyph(packedGlyphID); } return glyph; } -SkGlyph* SkGlyphCache::allocateNewGlyph(PackedGlyphID packedGlyphID, MetricsType mtype) { +SkGlyph* SkGlyphCache::allocateNewGlyph(PackedGlyphID packedGlyphID) { fMemoryUsed += sizeof(SkGlyph); SkGlyph* glyphPtr; @@ -189,13 +184,7 @@ SkGlyph* SkGlyphCache::allocateNewGlyph(PackedGlyphID packedGlyphID, MetricsType glyph.initGlyphFromCombinedID(packedGlyphID); glyphPtr = fGlyphMap.set(glyph); } - - if (kJustAdvance_MetricsType == mtype) { - fScalerContext->getAdvance(glyphPtr); - } else { - SkASSERT(kFull_MetricsType == mtype); - fScalerContext->getMetrics(glyphPtr); - } + fScalerContext->getMetrics(glyphPtr); SkASSERT(glyphPtr->fID != SkGlyph::kImpossibleID); return glyphPtr; |