From f1b42a219fee68452ac0d618f2437b80b3a535c8 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Fri, 3 Jan 2020 17:15:08 -0500 Subject: [PATCH] Use fCurrGlyph as the looping variable. This clarifies the code instead of keeping fCurrGlyph and glyphIdx in sync. Change-Id: I2746eac3c681d14a1cb0eb73b91de920b5e6fbbc Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262151 Reviewed-by: Mike Klein Commit-Queue: Herb Derby --- src/gpu/text/GrTextBlob.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index 57d9e927b4..b040f9a84c 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -908,10 +908,9 @@ bool GrTextBlob::VertexRegenerator::doRegen(GrTextBlob::VertexRegenerator::Resul char* currVertex = fSubRun->fVertexData.data() + fCurrGlyph * kVerticesPerGlyph * vertexStride; result->fFirstVertex = currVertex; - for (int glyphIdx = fCurrGlyph; glyphIdx < (int)fSubRun->fGlyphs.size(); glyphIdx++) { - GrGlyph* glyph = nullptr; + for (; fCurrGlyph < (int)fSubRun->fGlyphs.size(); fCurrGlyph++) { if (fActions.regenTextureCoordinates) { - glyph = fSubRun->fGlyphs[glyphIdx]; + GrGlyph* glyph = fSubRun->fGlyphs[fCurrGlyph]; SkASSERT(glyph && glyph->fMaskFormat == fSubRun->maskFormat()); if (!fFullAtlasManager->hasGlyph(glyph)) { @@ -923,7 +922,10 @@ bool GrTextBlob::VertexRegenerator::doRegen(GrTextBlob::VertexRegenerator::Resul return false; } else if (GrDrawOpAtlas::ErrorCode::kTryAgain == code) { - fBrokenRun = glyphIdx > 0; + // If fCurrGlyph == 0, then no glyphs from this SubRun were put into the atlas, + // otherwise at least one glyph made it into the atlas, and this run needs + // special handling because of the atlas flush in the middle of it. + fBrokenRun = fCurrGlyph > 0; result->fFinished = false; return true; } @@ -934,12 +936,11 @@ bool GrTextBlob::VertexRegenerator::doRegen(GrTextBlob::VertexRegenerator::Resul } if (fActions.regenTextureCoordinates) { - fSubRun->updateTexCoord(glyphIdx); + fSubRun->updateTexCoord(fCurrGlyph); } currVertex += vertexStride * GrAtlasTextOp::kVerticesPerGlyph; ++result->fGlyphsRegenerated; - ++fCurrGlyph; } if (fActions.regenTextureCoordinates) {