simplify loop in updateTextureCoordinates

Change-Id: I436da4596c9bb24c5ab1fb5c11edba47e8664d65
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293837
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 92133d9..3a9cddd 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -305,6 +305,10 @@
     return fType == kTransformedPath || fType == kTransformedMask;
 }
 
+auto GrTextBlob::SubRun::vertexData() const -> SkSpan<const VertexData> {
+    return fVertexData;
+}
+
 bool GrTextBlob::SubRun::hasW() const {
     if (fType == kTransformedSDFT) {
         return fBlob->hasPerspective() || fBlob->forceWForDistanceFields();
@@ -912,8 +916,11 @@
 // 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.
 GrDrawOpAtlas::ErrorCode VR::addGlyphToAtlas(const SkGlyph& skGlyph, GrGlyph* grGlyph) {
+    if (skGlyph.image() == nullptr) {
+        return GrDrawOpAtlas::ErrorCode::kError;
+    }
+
     SkASSERT(grGlyph != nullptr);
-    SkASSERT(skGlyph.image() != nullptr);
 
     GrMaskFormat expectedMaskFormat = fFullAtlasManager->resolveMaskFormat(fSubRun->maskFormat());
     int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat);
@@ -964,30 +971,27 @@
     SkBulkGlyphMetricsAndImages metricsAndImages{fSubRun->strikeSpec()};
 
     // Update the atlas information in the GrStrike.
-    auto code = GrDrawOpAtlas::ErrorCode::kSucceeded;
     auto tokenTracker = fUploadTarget->tokenTracker();
-    int i = begin;
-    for (; i < end; i++) {
-        GrGlyph* grGlyph = fSubRun->grGlyph(i);
+    auto vertexData = fSubRun->vertexData().subspan(begin, end - begin);
+    int glyphsPlacedInAtlas = 0;
+    for (auto [glyph, pos, rect] : vertexData) {
+        GrGlyph* grGlyph = glyph.grGlyph;
         SkASSERT(grGlyph != nullptr);
 
         if (!fFullAtlasManager->hasGlyph(fSubRun->maskFormat(), grGlyph)) {
             const SkGlyph& skGlyph = *metricsAndImages.glyph(grGlyph->fPackedID);
-            if (skGlyph.image() == nullptr) {
-                return {false, 0};
-            }
-            code = this->addGlyphToAtlas(skGlyph, grGlyph);
+            auto code = this->addGlyphToAtlas(skGlyph, grGlyph);
             if (code != GrDrawOpAtlas::ErrorCode::kSucceeded) {
-                break;
+                return {code != GrDrawOpAtlas::ErrorCode::kError, glyphsPlacedInAtlas};
             }
         }
         fFullAtlasManager->addGlyphToBulkAndSetUseToken(
                 fSubRun->bulkUseToken(), fSubRun->maskFormat(), grGlyph,
                 tokenTracker->nextDrawToken());
+        glyphsPlacedInAtlas++;
     }
-    int glyphsPlacedInAtlas = i - begin;
 
-    return {code != GrDrawOpAtlas::ErrorCode::kError, glyphsPlacedInAtlas};
+    return {true, glyphsPlacedInAtlas};
 }
 
 std::tuple<bool, int> GrTextBlob::VertexRegenerator::regenerate(int begin, int end) {
diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h
index befec4a..4ca06e8 100644
--- a/src/gpu/text/GrTextBlob.h
+++ b/src/gpu/text/GrTextBlob.h
@@ -337,6 +337,8 @@
     bool drawAsDistanceFields() const;
     bool needsTransform() const;
     bool needsPadding() const;
+    SkSpan<const VertexData> vertexData() const;
+
 
     // Acquire a GrTextStrike and convert the SkPackedGlyphIDs to GrGlyphs for this run
     void prepareGrGlyphs(GrStrikeCache*);