move drawTextPaths from RTC to SubRun

Move drawing text as paths to the SubRun in anticipation of producing
a virtual draw() interface.

Change-Id: Iba9f948a8036a955a0205a098279825a72dc95c1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302261
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 59f9c06..22f18d6 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -424,61 +424,6 @@
     return canonicalColor;
 }
 
-void GrRenderTargetContext::drawTextPaths(const GrClip* clip,
-                                          const SkMatrixProvider& viewMatrix,
-                                          const SkGlyphRunList& glyphRunList,
-                                          GrTextBlob::SubRun* subRun) {
-    SkASSERT(!subRun->paths().empty());
-    SkPoint drawOrigin = glyphRunList.origin();
-    const SkPaint& drawPaint = glyphRunList.paint();
-    SkPaint runPaint{drawPaint};
-    runPaint.setAntiAlias(subRun->isAntiAliased());
-    // If there are shaders, blurs or styles, the path must be scaled into source
-    // space independently of the CTM. This allows the CTM to be correct for the
-    // different effects.
-    GrStyle style(runPaint);
-
-    bool needsExactCTM = runPaint.getShader()
-                         || style.applies()
-                         || runPaint.getMaskFilter();
-
-    // Calculate the matrix that maps the path glyphs from their size in the strike to
-    // the graphics source space.
-    SkScalar scale = subRun->strikeSpec().strikeToSourceRatio();
-    SkMatrix strikeToSource = SkMatrix::Scale(scale, scale);
-    strikeToSource.postTranslate(drawOrigin.x(), drawOrigin.y());
-    if (!needsExactCTM) {
-        for (const auto& pathPos : subRun->paths()) {
-            const SkPath& path = pathPos.fPath;
-            const SkPoint pos = pathPos.fOrigin;  // Transform the glyph to source space.
-            SkMatrix pathMatrix = strikeToSource;
-            pathMatrix.postTranslate(pos.x(), pos.y());
-            SkPreConcatMatrixProvider strikeToDevice(viewMatrix, pathMatrix);
-
-            GrStyledShape shape(path, drawPaint);
-            GrBlurUtils::drawShapeWithMaskFilter(
-                    this->fContext, this, clip, runPaint, strikeToDevice, shape);
-        }
-    } else {
-        // Transform the path to device because the deviceMatrix must be unchanged to
-        // draw effect, filter or shader paths.
-        for (const auto& pathPos : subRun->paths()) {
-            const SkPath& path = pathPos.fPath;
-            const SkPoint pos = pathPos.fOrigin;
-            // Transform the glyph to source space.
-            SkMatrix pathMatrix = strikeToSource;
-            pathMatrix.postTranslate(pos.x(), pos.y());
-
-            SkPath deviceOutline;
-            path.transform(pathMatrix, &deviceOutline);
-            deviceOutline.setIsVolatile(true);
-            GrStyledShape shape(deviceOutline, drawPaint);
-            GrBlurUtils::drawShapeWithMaskFilter(
-                    this->fContext, this, clip, runPaint, viewMatrix, shape);
-        }
-    }
-}
-
 void GrRenderTargetContext::drawGlyphRunList(const GrClip* clip,
                                              const SkMatrixProvider& viewMatrix,
                                              const SkGlyphRunList& glyphRunList) {
@@ -560,7 +505,7 @@
 
     for (GrTextBlob::SubRun* subRun : blob->subRunList()) {
         if (subRun->drawAsPaths()) {
-            this->drawTextPaths(clip, viewMatrix, glyphRunList, subRun);
+            subRun->drawPaths(clip, viewMatrix, glyphRunList, this);
         } else {
             auto [drawingClip, op] = subRun->makeAtlasTextOp(clip, viewMatrix, glyphRunList, this);
             if (op != nullptr) {