diff options
author | joshualitt <joshualitt@chromium.org> | 2015-11-23 14:09:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-23 14:09:55 -0800 |
commit | 50aa15b88ab149952dbc69e849139887e8a82410 (patch) | |
tree | 632a024fc836d85139bcc891667fda9f4974cbf3 /src/gpu | |
parent | 898e02e17575b72565a831035bf007158dff43ea (diff) |
Remove unecessary GetGlyphIdMetrics call
BUG=skia:
Review URL: https://codereview.chromium.org/1467133003
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBatchFontCache.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrBatchFontCache.h | 11 | ||||
-rw-r--r-- | src/gpu/batches/GrAtlasTextBatch.cpp | 17 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/gpu/GrBatchFontCache.cpp b/src/gpu/GrBatchFontCache.cpp index f3844cecba..ad76e4d71f 100644 --- a/src/gpu/GrBatchFontCache.cpp +++ b/src/gpu/GrBatchFontCache.cpp @@ -196,8 +196,9 @@ void GrBatchTextStrike::removeID(GrBatchAtlas::AtlasID id) { } } -bool GrBatchTextStrike::addGlyphToAtlas(GrDrawBatch::Target* target, GrGlyph* glyph, - GrFontScaler* scaler, const SkGlyph& skGlyph, +bool GrBatchTextStrike::addGlyphToAtlas(GrDrawBatch::Target* target, + GrGlyph* glyph, + GrFontScaler* scaler, GrMaskFormat expectedMaskFormat) { SkASSERT(glyph); SkASSERT(scaler); @@ -210,6 +211,7 @@ bool GrBatchTextStrike::addGlyphToAtlas(GrDrawBatch::Target* target, GrGlyph* gl size_t size = glyph->fBounds.area() * bytesPerPixel; SkAutoSMalloc<1024> storage(size); + const SkGlyph& skGlyph = scaler->grToSkGlyph(glyph->fPackedID); if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedID)) { if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->height(), storage.get())) { diff --git a/src/gpu/GrBatchFontCache.h b/src/gpu/GrBatchFontCache.h index 946356656b..46ab1c8274 100644 --- a/src/gpu/GrBatchFontCache.h +++ b/src/gpu/GrBatchFontCache.h @@ -43,10 +43,15 @@ public: // that the maskformat of the glyph differs from what we expect. In these cases we will just // draw a clear square. // skbug:4143 crbug:510931 - inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, - GrMaskFormat expectedMaskFormat, GrFontScaler* scaler) { + inline GrGlyph* getGlyph(GrGlyph::PackedID packed, + GrMaskFormat expectedMaskFormat, + GrFontScaler* scaler) { GrGlyph* glyph = fCache.find(packed); if (nullptr == glyph) { + // We could return this to the caller, but in practice it adds code complexity for + // potentially little benefit(ie, if the glyph is not in our font cache, then its not + // in the atlas and we're going to be doing a texture upload anyways). + const SkGlyph& skGlyph = scaler->grToSkGlyph(packed); glyph = this->generateGlyph(skGlyph, packed, scaler); glyph->fMaskFormat = expectedMaskFormat; } @@ -58,7 +63,7 @@ public: // happen. // TODO we can handle some of these cases if we really want to, but the long term solution is to // get the actual glyph image itself when we get the glyph metrics. - bool addGlyphToAtlas(GrDrawBatch::Target*, GrGlyph*, GrFontScaler*, const SkGlyph&, + bool addGlyphToAtlas(GrDrawBatch::Target*, GrGlyph*, GrFontScaler*, GrMaskFormat expectedMaskFormat); // testing diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp index 9d408f997a..710b155a45 100644 --- a/src/gpu/batches/GrAtlasTextBatch.cpp +++ b/src/gpu/batches/GrAtlasTextBatch.cpp @@ -168,24 +168,18 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl if (regenTexCoords) { size_t glyphOffset = glyphIdx + info->fGlyphStartIndex; - glyph = blob->fGlyphs[glyphOffset]; - GrGlyph::PackedID id = glyph->fPackedID; - const SkGlyph& skGlyph = (*scaler)->grToSkGlyph(id); if (regenGlyphs) { // Get the id from the old glyph, and use the new strike to lookup // the glyph. - blob->fGlyphs[glyphOffset] = strike->getGlyph(skGlyph, id, this->maskFormat(), - *scaler); + GrGlyph::PackedID id = blob->fGlyphs[glyphOffset]->fPackedID; + blob->fGlyphs[glyphOffset] = strike->getGlyph(id, this->maskFormat(), *scaler); + SkASSERT(id == blob->fGlyphs[glyphOffset]->fPackedID); } glyph = blob->fGlyphs[glyphOffset]; - SkASSERT(glyph); - SkASSERT(id == glyph->fPackedID); - // We want to be able to assert this but cannot for testing purposes. - // once skbug:4143 has landed we can revist this assert - //SkASSERT(glyph->fMaskFormat == this->maskFormat()); + SkASSERT(glyph && glyph->fMaskFormat == this->maskFormat()); if (!fFontCache->hasGlyph(glyph) && - !strike->addGlyphToAtlas(target, glyph, *scaler, skGlyph, this->maskFormat())) { + !strike->addGlyphToAtlas(target, glyph, *scaler, this->maskFormat())) { this->flush(target, flushInfo); target->initDraw(gp, this->pipeline()); brokenRun = glyphIdx > 0; @@ -193,7 +187,6 @@ inline void GrAtlasTextBatch::regenBlob(Target* target, FlushInfo* flushInfo, Bl SkDEBUGCODE(bool success =) strike->addGlyphToAtlas(target, glyph, *scaler, - skGlyph, this->maskFormat()); SkASSERT(success); } |