A small text cleanup

BUG=skia:

Review URL: https://codereview.chromium.org/1508853005
diff --git a/src/gpu/GrAtlasTextBlob.cpp b/src/gpu/GrAtlasTextBlob.cpp
index 21f2975..3ccca49 100644
--- a/src/gpu/GrAtlasTextBlob.cpp
+++ b/src/gpu/GrAtlasTextBlob.cpp
@@ -7,17 +7,34 @@
 
 #include "GrAtlasTextBlob.h"
 
-void GrAtlasTextBlob::appendGlyph(Run* run,
-                                  Run::SubRunInfo* subRun,
-                                  const SkRect& positions, GrColor color,
-                                  size_t vertexStride, bool useVertexColor,
+void GrAtlasTextBlob::appendGlyph(int runIndex,
+                                  const SkRect& positions,
+                                  GrColor color,
+                                  GrBatchTextStrike* strike,
                                   GrGlyph* glyph) {
-    run->fVertexBounds.joinNonEmptyArg(positions);
-    run->fColor = color;
+    Run& run = fRuns[runIndex];
+    GrMaskFormat format = glyph->fMaskFormat;
+
+    Run::SubRunInfo* subRun = &run.fSubRunInfo.back();
+    if (run.fInitialized && subRun->maskFormat() != format) {
+        subRun = &run.push_back();
+        subRun->setStrike(strike);
+    } else if (!run.fInitialized) {
+        subRun->setStrike(strike);
+    }
+
+    run.fInitialized = true;
+
+    size_t vertexStride = GetVertexStride(format);
+
+    subRun->setMaskFormat(format);
+
+    run.fVertexBounds.joinNonEmptyArg(positions);
+    run.fColor = color;
 
     intptr_t vertex = reinterpret_cast<intptr_t>(this->fVertices + subRun->vertexEndIndex());
 
-    if (useVertexColor) {
+    if (kARGB_GrMaskFormat != glyph->fMaskFormat) {
         // V0
         SkPoint* position = reinterpret_cast<SkPoint*>(vertex);
         position->set(positions.fLeft, positions.fTop);
diff --git a/src/gpu/GrAtlasTextBlob.h b/src/gpu/GrAtlasTextBlob.h
index 0d414b4..6f92c1e 100644
--- a/src/gpu/GrAtlasTextBlob.h
+++ b/src/gpu/GrAtlasTextBlob.h
@@ -280,12 +280,27 @@
         }
     }
 
-    void appendGlyph(Run* run,
-                     Run::SubRunInfo* subRun,
-                     const SkRect& positions, GrColor color,
-                     size_t vertexStride, bool useVertexColor,
+    void appendGlyph(int runIndex,
+                     const SkRect& positions,
+                     GrColor color,
+                     GrBatchTextStrike* strike,
                      GrGlyph* glyph);
 
+    static size_t GetVertexStride(GrMaskFormat maskFormat) {
+        switch (maskFormat) {
+            case kA8_GrMaskFormat:
+                return kGrayTextVASize;
+            case kARGB_GrMaskFormat:
+                return kColorTextVASize;
+            default:
+                return kLCDTextVASize;
+        }
+    }
+
+    // position + local coord
+    static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
+    static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof(SkIPoint16);
+    static const size_t kLCDTextVASize = kGrayTextVASize;
     static const int kVerticesPerGlyph = 4;
 
 #ifdef CACHE_SANITY_CHECK
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index fbbcdb6..d7ccce5 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -55,8 +55,8 @@
     , fDistanceAdjustTable(new DistanceAdjustTable) {
     // We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
     // vertexStride
-    static_assert(GrAtlasTextBatch::kGrayTextVASize >= GrAtlasTextBatch::kColorTextVASize &&
-                  GrAtlasTextBatch::kGrayTextVASize >= GrAtlasTextBatch::kLCDTextVASize,
+    static_assert(GrAtlasTextBlob::kGrayTextVASize >= GrAtlasTextBlob::kColorTextVASize &&
+                  GrAtlasTextBlob::kGrayTextVASize >= GrAtlasTextBlob::kLCDTextVASize,
                   "vertex_attribute_changed");
     fCurrStrike = nullptr;
     fCache = context->getTextBlobCache();
@@ -349,7 +349,7 @@
             // but we'd have to clear the subrun information
             fCache->remove(cacheBlob);
             cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, skPaint,
-                                                           GrAtlasTextBatch::kGrayTextVASize)));
+                                                           GrAtlasTextBlob::kGrayTextVASize)));
             this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix,
                                      blob, x, y, drawFilter, clip);
         } else {
@@ -377,9 +377,9 @@
     } else {
         if (canCache) {
             cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, skPaint,
-                                                           GrAtlasTextBatch::kGrayTextVASize)));
+                                                           GrAtlasTextBlob::kGrayTextVASize)));
         } else {
-            cacheBlob.reset(fCache->createBlob(blob, GrAtlasTextBatch::kGrayTextVASize));
+            cacheBlob.reset(fCache->createBlob(blob, GrAtlasTextBlob::kGrayTextVASize));
         }
         this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix,
                                  blob, x, y, drawFilter, clip);
@@ -624,7 +624,7 @@
 GrAtlasTextContext::setupDFBlob(int glyphCount, const SkPaint& origPaint,
                                 const SkMatrix& viewMatrix, SkPaint* dfPaint,
                                 SkScalar* textRatio) {
-    GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASize);
+    GrAtlasTextBlob* blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
 
     *dfPaint = origPaint;
     this->initDistanceFieldPaint(blob, dfPaint, textRatio, viewMatrix);
@@ -662,7 +662,7 @@
                                       fallbackTxt, fallbackPos, 2, offset);
         }
     } else {
-        blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASize);
+        blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
         blob->fViewMatrix = viewMatrix;
 
         SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
@@ -698,7 +698,7 @@
                                       fallbackTxt, fallbackPos, scalarsPerPosition, offset);
         }
     } else {
-        blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBatch::kGrayTextVASize);
+        blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
         blob->fViewMatrix = viewMatrix;
         SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
         this->internalDrawBMPPosText(blob, 0, cache, skPaint, paint.getColor(), viewMatrix, text,
@@ -967,7 +967,6 @@
 void GrAtlasTextContext::bmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
                                         const SkGlyph& skGlyph,
                                         int vx, int vy, GrColor color, GrFontScaler* scaler) {
-    Run& run = blob->fRuns[runIndex];
     if (!fCurrStrike) {
         fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
     }
@@ -994,28 +993,13 @@
         return;
     }
 
-    GrMaskFormat format = glyph->fMaskFormat;
-
-    PerSubRunInfo* subRun = &run.fSubRunInfo.back();
-    if (run.fInitialized && subRun->maskFormat() != format) {
-        subRun = &run.push_back();
-        subRun->setStrike(fCurrStrike);
-    } else if (!run.fInitialized) {
-        subRun->setStrike(fCurrStrike);
-    }
-
-    run.fInitialized = true;
-
-    size_t vertexStride = GrAtlasTextBatch::GetVertexStride(format);
-
     SkRect r;
     r.fLeft = SkIntToScalar(x);
     r.fTop = SkIntToScalar(y);
     r.fRight = r.fLeft + SkIntToScalar(width);
     r.fBottom = r.fTop + SkIntToScalar(height);
-    subRun->setMaskFormat(format);
-    blob->appendGlyph(&run, subRun, r, color, vertexStride,
-                      kARGB_GrMaskFormat != format, glyph);
+
+    blob->appendGlyph(runIndex, r, color, fCurrStrike, glyph);
 }
 
 bool GrAtlasTextContext::dfAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
@@ -1023,7 +1007,6 @@
                                        SkScalar sx, SkScalar sy, GrColor color,
                                        GrFontScaler* scaler,
                                        SkScalar textRatio, const SkMatrix& viewMatrix) {
-    Run& run = blob->fRuns[runIndex];
     if (!fCurrStrike) {
         fCurrStrike = fContext->getBatchFontCache()->getStrike(scaler);
     }
@@ -1063,17 +1046,7 @@
         return true;
     }
 
-    PerSubRunInfo* subRun = &run.fSubRunInfo.back();
-    if (!run.fInitialized) {
-        subRun->setStrike(fCurrStrike);
-    }
-    run.fInitialized = true;
-    SkASSERT(glyph->fMaskFormat == kA8_GrMaskFormat);
-    subRun->setMaskFormat(kA8_GrMaskFormat);
-
-    size_t vertexStride = GrAtlasTextBatch::GetVertexStride(kA8_GrMaskFormat);
-
-    blob->appendGlyph(&run, subRun, glyphRect, color, vertexStride, true, glyph);
+    blob->appendGlyph(runIndex, glyphRect, color, fCurrStrike, glyph);
     return true;
 }
 
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp
index 685cddc..3f3a521 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -331,7 +331,7 @@
     FlushInfo flushInfo;
     flushInfo.fGlyphsToFlush = 0;
     size_t vertexStride = gp->getVertexStride();
-    SkASSERT(vertexStride == GetVertexStride(maskFormat));
+    SkASSERT(vertexStride == GrAtlasTextBlob::GetVertexStride(maskFormat));
 
     target->initDraw(gp, this->pipeline());
 
diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h
index 95abbf4..5fd3d61 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -16,10 +16,6 @@
 public:
     DEFINE_BATCH_CLASS_ID
 
-    // position + local coord
-    static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
-    static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof(SkIPoint16);
-    static const size_t kLCDTextVASize = kGrayTextVASize;
     static const int kVerticesPerGlyph = GrAtlasTextBlob::kVerticesPerGlyph;
     static const int kIndicesPerGlyph = 6;
 
@@ -102,17 +98,6 @@
 
     SkString dumpInfo() const override;
 
-    static size_t GetVertexStride(GrMaskFormat maskFormat) {
-        switch (maskFormat) {
-            case kA8_GrMaskFormat:
-                return kGrayTextVASize;
-            case kARGB_GrMaskFormat:
-                return kColorTextVASize;
-            default:
-                return kLCDTextVASize;
-        }
-    }
-
 protected:
     void computePipelineOptimizations(GrInitInvariantOutput* color, 
                                       GrInitInvariantOutput* coverage,