Rename GrAtlasTextBatch->GrAtlasTextOp and sk_sp

Change-Id: I409048988cccb68daaeb66828e2772fcb6a0cb06
Reviewed-on: https://skia-review.googlesource.com/6104
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/batches/GrAtlasTextOp.cpp b/src/gpu/batches/GrAtlasTextOp.cpp
index 0b692d1..d576789 100644
--- a/src/gpu/batches/GrAtlasTextOp.cpp
+++ b/src/gpu/batches/GrAtlasTextOp.cpp
@@ -28,7 +28,7 @@
 
 static const int kDistanceAdjustLumShift = 5;
 
-SkString GrAtlasTextBatch::dumpInfo() const {
+SkString GrAtlasTextOp::dumpInfo() const {
     SkString str;
 
     for (int i = 0; i < fGeoCount; ++i) {
@@ -45,13 +45,13 @@
     return str;
 }
 
-void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color,
-                                                    GrInitInvariantOutput* coverage,
-                                                    GrBatchToXPOverrides* overrides) const {
+void GrAtlasTextOp::computePipelineOptimizations(GrInitInvariantOutput* color,
+                                                 GrInitInvariantOutput* coverage,
+                                                 GrBatchToXPOverrides* overrides) const {
     if (kColorBitmapMask_MaskType == fMaskType) {
         color->setUnknownFourComponents();
     } else {
-        color->setKnownFourComponents(fBatch.fColor);
+        color->setKnownFourComponents(fColor);
     }
     switch (fMaskType) {
         case kGrayscaleDistanceField_MaskType:
@@ -68,21 +68,20 @@
     }
 }
 
-void GrAtlasTextBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) {
+void GrAtlasTextOp::initBatchTracker(const GrXPOverridesForBatch& overrides) {
     // Handle any color overrides
     if (!overrides.readsColor()) {
         fGeoData[0].fColor = GrColor_ILLEGAL;
     }
     overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
 
-    // setup batch properties
-    fBatch.fColorIgnored = !overrides.readsColor();
-    fBatch.fColor = fGeoData[0].fColor;
-    fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
-    fBatch.fCoverageIgnored = !overrides.readsCoverage();
+    fColorIgnored = !overrides.readsColor();
+    fColor = fGeoData[0].fColor;
+    fUsesLocalCoords = overrides.readsLocalCoords();
+    fCoverageIgnored = !overrides.readsCoverage();
 }
 
-void GrAtlasTextBatch::onPrepareDraws(Target* target) const {
+void GrAtlasTextOp::onPrepareDraws(Target* target) const {
     // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix.
     // TODO actually only invert if we don't have RGBA
     SkMatrix localMatrix;
@@ -102,15 +101,11 @@
     FlushInfo flushInfo;
     if (this->usesDistanceFields()) {
         flushInfo.fGeometryProcessor =
-            this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture);
+                this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture);
     } else {
         GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode);
-        flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(this->color(),
-                                                                 texture,
-                                                                 params,
-                                                                 maskFormat,
-                                                                 localMatrix,
-                                                                 this->usesLocalCoords());
+        flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
+                this->color(), texture, params, maskFormat, localMatrix, this->usesLocalCoords());
     }
 
     flushInfo.fGlyphsToFlush = 0;
@@ -120,10 +115,8 @@
     int glyphCount = this->numGlyphs();
     const GrBuffer* vertexBuffer;
 
-    void* vertices = target->makeVertexSpace(vertexStride,
-                                             glyphCount * kVerticesPerGlyph,
-                                             &vertexBuffer,
-                                             &flushInfo.fVertexOffset);
+    void* vertices = target->makeVertexSpace(
+            vertexStride, glyphCount * kVerticesPerGlyph, &vertexBuffer, &flushInfo.fVertexOffset);
     flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
     flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer());
     if (!vertices || !flushInfo.fVertexBuffer) {
@@ -152,7 +145,7 @@
         // bounds sanity check
         SkRect rect;
         rect.setLargestInverted();
-        SkPoint* vertex = (SkPoint*) ((char*)blobVertices);
+        SkPoint* vertex = (SkPoint*)((char*)blobVertices);
         rect.growToInclude(vertex, vertexStride, kVerticesPerGlyph * subRunGlyphCount);
 
         if (this->usesDistanceFields()) {
@@ -170,21 +163,20 @@
     this->flush(target, &flushInfo);
 }
 
-void GrAtlasTextBatch::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const {
+void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const {
     GrMesh mesh;
     int maxGlyphsPerDraw =
-        static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6);
+            static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6);
     mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer.get(),
-                       flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset,
-                       kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
-                       maxGlyphsPerDraw);
+                       flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset, kVerticesPerGlyph,
+                       kIndicesPerGlyph, flushInfo->fGlyphsToFlush, maxGlyphsPerDraw);
     target->draw(flushInfo->fGeometryProcessor.get(), mesh);
     flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
     flushInfo->fGlyphsToFlush = 0;
 }
 
-bool GrAtlasTextBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
-    GrAtlasTextBatch* that = t->cast<GrAtlasTextBatch>();
+bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
+    GrAtlasTextOp* that = t->cast<GrAtlasTextOp>();
     if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
                                 that->bounds(), caps)) {
         return false;
@@ -215,7 +207,7 @@
         }
     }
 
-    fBatch.fNumGlyphs += that->numGlyphs();
+    fNumGlyphs += that->numGlyphs();
 
     // Reallocate space for geo data if necessary and then import that's geo data.
     int newGeoCount = that->fGeoCount + fGeoCount;
@@ -229,9 +221,9 @@
         fGeoData.realloc(newAllocSize);
     }
 
-    memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry));
-    // We steal the ref on the blobs from the other TextBatch and set its count to 0 so that
+    // We steal the ref on the blobs from the other AtlasTextOp and set its count to 0 so that
     // it doesn't try to unref them.
+    memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry));
 #ifdef SK_DEBUG
     for (int i = 0; i < that->fGeoCount; ++i) {
         that->fGeoData.get()[i].fBlob = (Blob*)0x1;
@@ -246,10 +238,10 @@
 
 // TODO just use class params
 // TODO trying to figure out why lcd is so whack
-sk_sp<GrGeometryProcessor> GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix,
-                                                              SkColor filteredColor,
-                                                              GrColor color,
-                                                              GrTexture* texture) const {
+sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const SkMatrix& viewMatrix,
+                                                           SkColor filteredColor,
+                                                           GrColor color,
+                                                           GrTexture* texture) const {
     GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode);
     bool isLCD = this->isLCD();
     // set up any flags
@@ -265,50 +257,32 @@
         GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
 
         float redCorrection = fDistanceAdjustTable->getAdjustment(
-            GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift,
-            fUseGammaCorrectDistanceTable);
+                GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift,
+                fUseGammaCorrectDistanceTable);
         float greenCorrection = fDistanceAdjustTable->getAdjustment(
-            GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift,
-            fUseGammaCorrectDistanceTable);
+                GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift,
+                fUseGammaCorrectDistanceTable);
         float blueCorrection = fDistanceAdjustTable->getAdjustment(
-            GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift,
-            fUseGammaCorrectDistanceTable);
+                GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift,
+                fUseGammaCorrectDistanceTable);
         GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
-            GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection,
-                                                                greenCorrection,
-                                                                blueCorrection);
+                GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
+                        redCorrection, greenCorrection, blueCorrection);
 
-        return GrDistanceFieldLCDTextGeoProc::Make(color,
-                                                   viewMatrix,
-                                                   texture,
-                                                   params,
-                                                   widthAdjust,
-                                                   flags,
-                                                   this->usesLocalCoords());
+        return GrDistanceFieldLCDTextGeoProc::Make(
+                color, viewMatrix, texture, params, widthAdjust, flags, this->usesLocalCoords());
     } else {
 #ifdef SK_GAMMA_APPLY_TO_A8
         U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor);
-        float correction = fDistanceAdjustTable->getAdjustment(
-            lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable);
-        return GrDistanceFieldA8TextGeoProc::Make(color,
-                                                  viewMatrix,
-                                                  texture,
-                                                  params,
-                                                  correction,
-                                                  flags,
-                                                  this->usesLocalCoords());
+        float correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
+                                                               fUseGammaCorrectDistanceTable);
+        return GrDistanceFieldA8TextGeoProc::Make(
+                color, viewMatrix, texture, params, correction, flags, this->usesLocalCoords());
 #else
-        return GrDistanceFieldA8TextGeoProc::Make(color,
-                                                  viewMatrix,
-                                                  texture,
-                                                  params,
-                                                  flags,
-                                                  this->usesLocalCoords());
+        return GrDistanceFieldA8TextGeoProc::Make(
+                color, viewMatrix, texture, params, flags, this->usesLocalCoords());
 #endif
     }
-
 }
 
-void GrBlobRegenHelper::flush() {
-    fBatch->flush(fTarget, fFlushInfo);
-}
+void GrBlobRegenHelper::flush() { fOp->flush(fTarget, fFlushInfo); }
diff --git a/src/gpu/batches/GrAtlasTextOp.h b/src/gpu/batches/GrAtlasTextOp.h
index 313a78e..6cb269c 100644
--- a/src/gpu/batches/GrAtlasTextOp.h
+++ b/src/gpu/batches/GrAtlasTextOp.h
@@ -5,15 +5,15 @@
  * found in the LICENSE file.
  */
 
-#ifndef GrAtlasTextBatch_DEFINED
-#define GrAtlasTextBatch_DEFINED
+#ifndef GrAtlasTextOp_DEFINED
+#define GrAtlasTextOp_DEFINED
 
 #include "batches/GrMeshDrawOp.h"
 
 #include "text/GrAtlasTextContext.h"
 #include "text/GrDistanceFieldAdjustTable.h"
 
-class GrAtlasTextBatch final : public GrMeshDrawOp {
+class GrAtlasTextOp final : public GrMeshDrawOp {
 public:
     DEFINE_OP_CLASS_ID
 
@@ -31,57 +31,55 @@
         GrColor fColor;
     };
 
-    static GrAtlasTextBatch* CreateBitmap(GrMaskFormat maskFormat, int glyphCount,
-                                          GrBatchFontCache* fontCache) {
-        GrAtlasTextBatch* batch = new GrAtlasTextBatch;
+    static sk_sp<GrAtlasTextOp> MakeBitmap(GrMaskFormat maskFormat, int glyphCount,
+                                           GrBatchFontCache* fontCache) {
+        sk_sp<GrAtlasTextOp> op(new GrAtlasTextOp);
 
-        batch->fFontCache = fontCache;
+        op->fFontCache = fontCache;
         switch (maskFormat) {
             case kA8_GrMaskFormat:
-                batch->fMaskType = kGrayscaleCoverageMask_MaskType;
+                op->fMaskType = kGrayscaleCoverageMask_MaskType;
                 break;
             case kA565_GrMaskFormat:
-                batch->fMaskType = kLCDCoverageMask_MaskType;
+                op->fMaskType = kLCDCoverageMask_MaskType;
                 break;
             case kARGB_GrMaskFormat:
-                batch->fMaskType = kColorBitmapMask_MaskType;
+                op->fMaskType = kColorBitmapMask_MaskType;
                 break;
         }
-        batch->fBatch.fNumGlyphs = glyphCount;
-        batch->fGeoCount = 1;
-        batch->fFilteredColor = 0;
-        batch->fFontCache = fontCache;
-        batch->fUseBGR = false;
-        return batch;
+        op->fNumGlyphs = glyphCount;
+        op->fGeoCount = 1;
+        op->fFilteredColor = 0;
+        op->fFontCache = fontCache;
+        op->fUseBGR = false;
+        return op;
     }
 
-    static GrAtlasTextBatch* CreateDistanceField(
-                                              int glyphCount, GrBatchFontCache* fontCache,
-                                              const GrDistanceFieldAdjustTable* distanceAdjustTable,
-                                              bool useGammaCorrectDistanceTable,
-                                              SkColor filteredColor, bool isLCD,
-                                              bool useBGR) {
-        GrAtlasTextBatch* batch = new GrAtlasTextBatch;
+    static sk_sp<GrAtlasTextOp> MakeDistanceField(
+            int glyphCount, GrBatchFontCache* fontCache,
+            const GrDistanceFieldAdjustTable* distanceAdjustTable,
+            bool useGammaCorrectDistanceTable, SkColor filteredColor, bool isLCD, bool useBGR) {
+        sk_sp<GrAtlasTextOp> op(new GrAtlasTextOp);
 
-        batch->fFontCache = fontCache;
-        batch->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistanceField_MaskType;
-        batch->fDistanceAdjustTable.reset(SkRef(distanceAdjustTable));
-        batch->fUseGammaCorrectDistanceTable = useGammaCorrectDistanceTable;
-        batch->fFilteredColor = filteredColor;
-        batch->fUseBGR = useBGR;
-        batch->fBatch.fNumGlyphs = glyphCount;
-        batch->fGeoCount = 1;
-        return batch;
+        op->fFontCache = fontCache;
+        op->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistanceField_MaskType;
+        op->fDistanceAdjustTable.reset(SkRef(distanceAdjustTable));
+        op->fUseGammaCorrectDistanceTable = useGammaCorrectDistanceTable;
+        op->fFilteredColor = filteredColor;
+        op->fUseBGR = useBGR;
+        op->fNumGlyphs = glyphCount;
+        op->fGeoCount = 1;
+        return op;
     }
 
-    // to avoid even the initial copy of the struct, we have a getter for the first item which
-    // is used to seed the batch with its initial geometry.  After seeding, the client should call
-    // init() so the Batch can initialize itself
+    // To avoid even the initial copy of the struct, we have a getter for the first item which
+    // is used to seed the op with its initial geometry.  After seeding, the client should call
+    // init() so the op can initialize itself
     Geometry& geometry() { return fGeoData[0]; }
 
     void init() {
         const Geometry& geo = fGeoData[0];
-        fBatch.fColor = geo.fColor;
+        fColor = geo.fColor;
         SkRect bounds;
         geo.fBlob->computeSubRunBounds(&bounds, geo.fRun, geo.fSubRun, geo.fViewMatrix, geo.fX,
                                        geo.fY);
@@ -90,7 +88,7 @@
         this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
     }
 
-    const char* name() const override { return "TextBatch"; }
+    const char* name() const override { return "AtlasTextOp"; }
 
     SkString dumpInfo() const override;
 
@@ -99,23 +97,22 @@
                                       GrInitInvariantOutput* coverage,
                                       GrBatchToXPOverrides* overrides) const override;
 
-
 private:
     void initBatchTracker(const GrXPOverridesForBatch& overrides) override;
 
     struct FlushInfo {
-        sk_sp<const GrBuffer>      fVertexBuffer;
-        sk_sp<const GrBuffer>      fIndexBuffer;
+        sk_sp<const GrBuffer> fVertexBuffer;
+        sk_sp<const GrBuffer> fIndexBuffer;
         sk_sp<GrGeometryProcessor> fGeometryProcessor;
-        int                        fGlyphsToFlush;
-        int                        fVertexOffset;
+        int fGlyphsToFlush;
+        int fVertexOffset;
     };
 
     void onPrepareDraws(Target* target) const override;
 
-    GrAtlasTextBatch() : INHERITED(ClassID()) {} // initialized in factory functions.
+    GrAtlasTextOp() : INHERITED(ClassID()) {}  // initialized in factory functions.
 
-    ~GrAtlasTextBatch() {
+    ~GrAtlasTextOp() {
         for (int i = 0; i < fGeoCount; i++) {
             fGeoData[i].fBlob->unref();
         }
@@ -132,7 +129,7 @@
             case kLCDDistanceField_MaskType:
                 return kA8_GrMaskFormat;
         }
-        return kA8_GrMaskFormat; // suppress warning
+        return kA8_GrMaskFormat;  // suppress warning
     }
 
     bool usesDistanceFields() const {
@@ -141,16 +138,15 @@
     }
 
     bool isLCD() const {
-        return kLCDCoverageMask_MaskType == fMaskType ||
-               kLCDDistanceField_MaskType == fMaskType;
+        return kLCDCoverageMask_MaskType == fMaskType || kLCDDistanceField_MaskType == fMaskType;
     }
 
     inline void flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const;
 
-    GrColor color() const { return fBatch.fColor; }
+    GrColor color() const { return fColor; }
     const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
-    bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
-    int numGlyphs() const { return fBatch.fNumGlyphs; }
+    bool usesLocalCoords() const { return fUsesLocalCoords; }
+    int numGlyphs() const { return fNumGlyphs; }
 
     bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
 
@@ -159,15 +155,12 @@
     sk_sp<GrGeometryProcessor> setupDfProcessor(const SkMatrix& viewMatrix, SkColor filteredColor,
                                                 GrColor color, GrTexture* texture) const;
 
-    struct BatchTracker {
-        GrColor fColor;
-        bool fUsesLocalCoords;
-        bool fColorIgnored;
-        bool fCoverageIgnored;
-        int fNumGlyphs;
-    };
+    GrColor fColor;
+    bool fUsesLocalCoords;
+    bool fColorIgnored;
+    bool fCoverageIgnored;
+    int fNumGlyphs;
 
-    BatchTracker fBatch;
     // The minimum number of Geometry we will try to allocate.
     enum { kMinGeometryAllocated = 4 };
     SkAutoSTMalloc<kMinGeometryAllocated, Geometry> fGeoData;
@@ -180,7 +173,7 @@
         kGrayscaleDistanceField_MaskType,
         kLCDDistanceField_MaskType,
     } fMaskType;
-    bool fUseBGR; // fold this into the enum?
+    bool fUseBGR;  // fold this into the enum?
 
     GrBatchFontCache* fFontCache;
 
@@ -189,7 +182,7 @@
     SkColor fFilteredColor;
     bool fUseGammaCorrectDistanceTable;
 
-    friend class GrBlobRegenHelper; // Needs to trigger flushes
+    friend class GrBlobRegenHelper;  // Needs to trigger flushes
 
     typedef GrMeshDrawOp INHERITED;
 };
@@ -200,20 +193,18 @@
  */
 class GrBlobRegenHelper {
 public:
-    GrBlobRegenHelper(const GrAtlasTextBatch* batch, GrMeshDrawOp::Target* target,
-                      GrAtlasTextBatch::FlushInfo* flushInfo)
-        : fBatch(batch), fTarget(target), fFlushInfo(flushInfo) {}
+    GrBlobRegenHelper(const GrAtlasTextOp* op, GrMeshDrawOp::Target* target,
+                      GrAtlasTextOp::FlushInfo* flushInfo)
+            : fOp(op), fTarget(target), fFlushInfo(flushInfo) {}
 
     void flush();
 
-    void incGlyphCount(int glyphCount = 1) {
-        fFlushInfo->fGlyphsToFlush += glyphCount;
-    }
+    void incGlyphCount(int glyphCount = 1) { fFlushInfo->fGlyphsToFlush += glyphCount; }
 
 private:
-    const GrAtlasTextBatch* fBatch;
+    const GrAtlasTextOp* fOp;
     GrMeshDrawOp::Target* fTarget;
-    GrAtlasTextBatch::FlushInfo* fFlushInfo;
+    GrAtlasTextOp::FlushInfo* fFlushInfo;
 };
 
 #endif
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index e3c23d6..f2f0312 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -9,8 +9,8 @@
 
 #include "GrBlurUtils.h"
 #include "GrContext.h"
-#include "GrRenderTargetContext.h"
 #include "GrPipelineBuilder.h"
+#include "GrRenderTargetContext.h"
 #include "GrTextUtils.h"
 #include "SkColorFilter.h"
 #include "SkDrawFilter.h"
@@ -254,14 +254,11 @@
     return false;
 }
 
-inline GrDrawOp* GrAtlasTextBlob::createBatch(const Run::SubRunInfo& info,
-                                              int glyphCount, int run, int subRun,
-                                              const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
-                                              GrColor color,
-                                              const SkPaint& skPaint, const SkSurfaceProps& props,
-                                              const GrDistanceFieldAdjustTable* distanceAdjustTable,
-                                              bool useGammaCorrectDistanceTable,
-                                              GrBatchFontCache* cache) {
+inline sk_sp<GrDrawOp> GrAtlasTextBlob::makeOp(
+        const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
+        const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint,
+        const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable,
+        bool useGammaCorrectDistanceTable, GrBatchFontCache* cache) {
     GrMaskFormat format = info.maskFormat();
     GrColor subRunColor;
     if (kARGB_GrMaskFormat == format) {
@@ -271,7 +268,7 @@
         subRunColor = color;
     }
 
-    GrAtlasTextBatch* batch;
+    sk_sp<GrAtlasTextOp> batch;
     if (info.drawAsDistanceFields()) {
         SkColor filteredColor;
         SkColorFilter* colorFilter = skPaint.getColorFilter();
@@ -281,14 +278,13 @@
             filteredColor = skPaint.getColor();
         }
         bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
-        batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache,
-                                                      distanceAdjustTable,
-                                                      useGammaCorrectDistanceTable,
-                                                      filteredColor, info.hasUseLCDText(), useBGR);
+        batch = GrAtlasTextOp::MakeDistanceField(glyphCount, cache, distanceAdjustTable,
+                                                 useGammaCorrectDistanceTable, filteredColor,
+                                                 info.hasUseLCDText(), useBGR);
     } else {
-        batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache);
+        batch = GrAtlasTextOp::MakeBitmap(format, glyphCount, cache);
     }
-    GrAtlasTextBatch::Geometry& geometry = batch->geometry();
+    GrAtlasTextOp::Geometry& geometry = batch->geometry();
     geometry.fViewMatrix = viewMatrix;
     geometry.fBlob = SkRef(this);
     geometry.fRun = run;
@@ -298,7 +294,7 @@
     geometry.fY = y;
     batch->init();
 
-    return batch;
+    return std::move(batch);
 }
 
 inline
@@ -317,9 +313,9 @@
 
         GrColor color = grPaint.getColor();
 
-        sk_sp<GrDrawOp> op(this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color,
-                                             skPaint, props, distanceAdjustTable,
-                                             rtc->isGammaCorrect(), cache));
+        sk_sp<GrDrawOp> op(this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color,
+                                        skPaint, props, distanceAdjustTable, rtc->isGammaCorrect(),
+                                        cache));
         GrPipelineBuilder pipelineBuilder(grPaint, GrAAType::kNone);
 
         rtc->addDrawOp(pipelineBuilder, clip, std::move(op));
@@ -455,15 +451,15 @@
     this->flushBigGlyphs(context, rtc, clip, skPaint, viewMatrix, x, y, clipBounds);
 }
 
-GrDrawOp* GrAtlasTextBlob::test_createBatch(int glyphCount, int run, int subRun,
-                                            const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
-                                            GrColor color,
-                                            const SkPaint& skPaint, const SkSurfaceProps& props,
-                                            const GrDistanceFieldAdjustTable* distanceAdjustTable,
-                                            GrBatchFontCache* cache) {
+sk_sp<GrDrawOp> GrAtlasTextBlob::test_makeOp(int glyphCount, int run, int subRun,
+                                             const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
+                                             GrColor color, const SkPaint& skPaint,
+                                             const SkSurfaceProps& props,
+                                             const GrDistanceFieldAdjustTable* distanceAdjustTable,
+                                             GrBatchFontCache* cache) {
     const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
-    return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint,
-                             props, distanceAdjustTable, false, cache);
+    return this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, props,
+                        distanceAdjustTable, false, cache);
 }
 
 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) {
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 1801e25..9d19a70 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -279,11 +279,11 @@
 
     ////////////////////////////////////////////////////////////////////////////////////////////////
     // Internal test methods
-    GrDrawOp* test_createBatch(int glyphCount, int run, int subRun,
-                               const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
-                               const SkPaint& skPaint, const SkSurfaceProps& props,
-                               const GrDistanceFieldAdjustTable* distanceAdjustTable,
-                               GrBatchFontCache* cache);
+    sk_sp<GrDrawOp> test_makeOp(int glyphCount, int run, int subRun, const SkMatrix& viewMatrix,
+                                SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint,
+                                const SkSurfaceProps& props,
+                                const GrDistanceFieldAdjustTable* distanceAdjustTable,
+                                GrBatchFontCache* cache);
 
 private:
     GrAtlasTextBlob()
@@ -496,23 +496,15 @@
     };
 
     template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
-    void regenInBatch(GrDrawOp::Target* target,
-                      GrBatchFontCache* fontCache,
-                      GrBlobRegenHelper* helper,
-                      Run* run, Run::SubRunInfo* info,
-                      SkAutoGlyphCache*, int glyphCount,
-                      size_t vertexStride,
-                      GrColor color, SkScalar transX,
-                      SkScalar transY) const;
+    void regenInOp(GrDrawOp::Target* target, GrBatchFontCache* fontCache, GrBlobRegenHelper* helper,
+                   Run* run, Run::SubRunInfo* info, SkAutoGlyphCache*, int glyphCount,
+                   size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const;
 
-    inline GrDrawOp* createBatch(const Run::SubRunInfo& info,
-                                 int glyphCount, int run, int subRun,
-                                 const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
-                                 GrColor color,
-                                 const SkPaint& skPaint, const SkSurfaceProps& props,
-                                 const GrDistanceFieldAdjustTable* distanceAdjustTable,
-                                 bool useGammaCorrectDistanceTable,
-                                 GrBatchFontCache* cache);
+    inline sk_sp<GrDrawOp> makeOp(const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
+                                  const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
+                                  const SkPaint& skPaint, const SkSurfaceProps& props,
+                                  const GrDistanceFieldAdjustTable* distanceAdjustTable,
+                                  bool useGammaCorrectDistanceTable, GrBatchFontCache* cache);
 
     struct BigGlyph {
         BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool treatAsBMP)
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
index 1b54146..d1c4736 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
@@ -138,15 +138,10 @@
 }
 
 template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
-void GrAtlasTextBlob::regenInBatch(GrDrawOp::Target* target,
-                                   GrBatchFontCache* fontCache,
-                                   GrBlobRegenHelper *helper,
-                                   Run* run,
-                                   Run::SubRunInfo* info,
-                                   SkAutoGlyphCache* lazyCache,
-                                   int glyphCount, size_t vertexStride,
-                                   GrColor color, SkScalar transX,
-                                   SkScalar transY) const {
+void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrBatchFontCache* fontCache,
+                                GrBlobRegenHelper* helper, Run* run, Run::SubRunInfo* info,
+                                SkAutoGlyphCache* lazyCache, int glyphCount, size_t vertexStride,
+                                GrColor color, SkScalar transX, SkScalar transY) const {
     SkASSERT(lazyCache);
     static_assert(!regenGlyphs || regenTexCoords, "must regenTexCoords along regenGlyphs");
     GrBatchTextStrike* strike = nullptr;
@@ -208,7 +203,7 @@
 
         intptr_t vertex = reinterpret_cast<intptr_t>(fVertices);
         vertex += info->vertexStartIndex();
-        vertex += vertexStride * glyphIdx * GrAtlasTextBatch::kVerticesPerGlyph;
+        vertex += vertexStride * glyphIdx * GrAtlasTextOp::kVerticesPerGlyph;
         regen_vertices<regenPos, regenCol, regenTexCoords>(vertex, glyph, vertexStride,
                                                            info->drawAsDistanceFields(), transX,
                                                            transY, log2Width, log2Height, color);
@@ -286,19 +281,41 @@
     RegenMask regenMask = (RegenMask)regenMaskBits;
 
     switch (regenMask) {
-        case kRegenPos: this->regenInBatch<true, false, false, false>(REGEN_ARGS); break;
-        case kRegenCol: this->regenInBatch<false, true, false, false>(REGEN_ARGS); break;
-        case kRegenTex: this->regenInBatch<false, false, true, false>(REGEN_ARGS); break;
-        case kRegenGlyph: this->regenInBatch<false, false, true, true>(REGEN_ARGS); break;
+        case kRegenPos:
+            this->regenInOp<true, false, false, false>(REGEN_ARGS);
+            break;
+        case kRegenCol:
+            this->regenInOp<false, true, false, false>(REGEN_ARGS);
+            break;
+        case kRegenTex:
+            this->regenInOp<false, false, true, false>(REGEN_ARGS);
+            break;
+        case kRegenGlyph:
+            this->regenInOp<false, false, true, true>(REGEN_ARGS);
+            break;
 
-            // combinations
-        case kRegenPosCol: this->regenInBatch<true, true, false, false>(REGEN_ARGS); break;
-        case kRegenPosTex: this->regenInBatch<true, false, true, false>(REGEN_ARGS); break;
-        case kRegenPosTexGlyph: this->regenInBatch<true, false, true, true>(REGEN_ARGS); break;
-        case kRegenPosColTex: this->regenInBatch<true, true, true, false>(REGEN_ARGS); break;
-        case kRegenPosColTexGlyph: this->regenInBatch<true, true, true, true>(REGEN_ARGS); break;
-        case kRegenColTex: this->regenInBatch<false, true, true, false>(REGEN_ARGS); break;
-        case kRegenColTexGlyph: this->regenInBatch<false, true, true, true>(REGEN_ARGS); break;
+        // combinations
+        case kRegenPosCol:
+            this->regenInOp<true, true, false, false>(REGEN_ARGS);
+            break;
+        case kRegenPosTex:
+            this->regenInOp<true, false, true, false>(REGEN_ARGS);
+            break;
+        case kRegenPosTexGlyph:
+            this->regenInOp<true, false, true, true>(REGEN_ARGS);
+            break;
+        case kRegenPosColTex:
+            this->regenInOp<true, true, true, false>(REGEN_ARGS);
+            break;
+        case kRegenPosColTexGlyph:
+            this->regenInOp<true, true, true, true>(REGEN_ARGS);
+            break;
+        case kRegenColTex:
+            this->regenInOp<false, true, true, false>(REGEN_ARGS);
+            break;
+        case kRegenColTexGlyph:
+            this->regenInOp<false, true, true, true>(REGEN_ARGS);
+            break;
         case kNoRegen:
             helper->incGlyphCount(*glyphCount);
 
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 76bdfc8..2e2cf40 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -428,9 +428,10 @@
                                                gSurfaceProps, text,
                                                static_cast<size_t>(textLen), x, y));
 
-    return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPaint,
-                                  gSurfaceProps, gTextContext->dfAdjustTable(),
-                                  context->getBatchFontCache());
+    return blob
+            ->test_makeOp(textLen, 0, 0, viewMatrix, x, y, color, skPaint, gSurfaceProps,
+                          gTextContext->dfAdjustTable(), context->getBatchFontCache())
+            .release();
 }
 
 #endif