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/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