introduce a direct to GrAtlasTextOp text drawing system

By pass the GrTextBlobCache, and create the op directly, with
the op owning the GrAtlasSubRun.

The new types of SubRuns have the GrAtlasTextOp's Geometry
embedded in them because there is a 1-to-1 correspondence
between the SubRun and the Geometry.

There is a lot of duplicate code. I wanted to keep the
implementation similar before I started top optimize
the direct code path.

Change-Id: I86162a527613e092c184932f4496f59c07793d55
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336445
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrSurfaceDrawContext.cpp b/src/gpu/GrSurfaceDrawContext.cpp
index 9fec1ba..0d22a9a 100644
--- a/src/gpu/GrSurfaceDrawContext.cpp
+++ b/src/gpu/GrSurfaceDrawContext.cpp
@@ -324,21 +324,31 @@
     return GrMipmapped::kNo;
 }
 
-void GrSurfaceDrawContext::drawGlyphRunList(const GrClip* clip,
-                                            const SkMatrixProvider& viewMatrix,
-                                            const SkGlyphRunList& glyphRunList) {
-    ASSERT_SINGLE_OWNER
-    RETURN_IF_ABANDONED
-    SkDEBUGCODE(this->validate();)
-    GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceDrawContext", "drawGlyphRunList", fContext);
+void GrSurfaceDrawContext::drawGlyphRunListNoCache(const GrClip* clip,
+                                                   const SkMatrixProvider& viewMatrix,
+                                                   const SkGlyphRunList& glyphRunList) {
+    GrSDFTControl control =
+            fContext->priv().getSDFTControl(fSurfaceProps.isUseDeviceIndependentFonts());
+    const SkPoint drawOrigin = glyphRunList.origin();
+    SkMatrix drawMatrix = viewMatrix.localToDevice();
+    drawMatrix.preTranslate(drawOrigin.x(), drawOrigin.y());
+    GrSubRunAllocator* const alloc = this->recordingContext()->priv().recordTimeSubRunAllocator();
 
-    // Drawing text can cause us to do inline uploads. This is not supported for wrapped vulkan
-    // secondary command buffers because it would require stopping and starting a render pass which
-    // we don't have access to.
-    if (this->wrapsVkSecondaryCB()) {
-        return;
+    for (auto& glyphRun : glyphRunList) {
+        GrSubRunNoCachePainter painter{this, alloc, clip, viewMatrix, glyphRunList};
+
+        // Make and add the text ops.
+        fGlyphPainter.processGlyphRun(glyphRun,
+                                      drawMatrix,
+                                      glyphRunList.paint(),
+                                      control,
+                                      &painter);
     }
+}
 
+void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
+                                                     const SkMatrixProvider& viewMatrix,
+                                                     const SkGlyphRunList& glyphRunList) {
     SkMatrix drawMatrix(viewMatrix.localToDevice());
     drawMatrix.preTranslate(glyphRunList.origin().x(), glyphRunList.origin().y());
 
@@ -382,6 +392,31 @@
     }
 }
 
+// choose to use the GrTextBlob cache or not.
+bool gGrDrawTextNoCache = false;
+void GrSurfaceDrawContext::drawGlyphRunList(const GrClip* clip,
+                                            const SkMatrixProvider& viewMatrix,
+                                            const SkGlyphRunList& glyphRunList) {
+    ASSERT_SINGLE_OWNER
+    RETURN_IF_ABANDONED
+    SkDEBUGCODE(this->validate();)
+    GR_CREATE_TRACE_MARKER_CONTEXT("GrSurfaceDrawContext", "drawGlyphRunList", fContext);
+
+    // Drawing text can cause us to do inline uploads. This is not supported for wrapped vulkan
+    // secondary command buffers because it would require stopping and starting a render pass which
+    // we don't have access to.
+    if (this->wrapsVkSecondaryCB()) {
+        return;
+    }
+
+    if (gGrDrawTextNoCache) {
+        // drawGlyphRunListNoCache lives in GrTextBlob.cpp to share sub run implementation code.
+        this->drawGlyphRunListNoCache(clip, viewMatrix, glyphRunList);
+    } else {
+        this->drawGlyphRunListWithCache(clip, viewMatrix, glyphRunList);
+    }
+}
+
 void GrSurfaceDrawContext::drawPaint(const GrClip* clip,
                                      GrPaint&& paint,
                                      const SkMatrix& viewMatrix) {