Reland "Convert the CPU path case to use prepareForDrawing"

This is a reland of 8be917af4313f6021b9b8e5d2b3f4d5712967aa9

Original change's description:
> Convert the CPU path case to use prepareForDrawing
>
> Change-Id: I5babfc7f1fa9784d81896d5c036e3b50c2af8ca0
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207760
> Reviewed-by: Ben Wagner <bungeman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I307792b443d4738ee2ccb545cc40256bc94cacee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207887
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index d097888..4dc8d8f 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -166,22 +166,43 @@
             // The sub-pixel position will always happen when transforming to the screen.
             pathFont.setSubpixel(false);
 
-            auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive(
-                                pathFont, pathPaint, props,
-                                fScalerContextFlags, SkMatrix::I());
+            SkAutoDescriptor ad;
+            SkScalerContextEffects effects;
+            SkScalerContext::CreateDescriptorAndEffectsUsingPaint(pathFont,
+                                                                  pathPaint,
+                                                                  props,
+                                                                  fScalerContextFlags,
+                                                                  SkMatrix::I(),
+                                                                  &ad,
+                                                                  &effects);
+
+            SkScopedStrike strike =
+                    fStrikeCache->findOrCreateScopedStrike(
+                            *ad.getDesc(), effects,*pathFont.getTypefaceOrDefault());
+
+            auto glyphPosSpan = strike->prepareForDrawing(
+                    glyphRun.glyphsIDs().data(), fPositions, glyphRun.runSize(), 0, fGlyphPos);
 
             SkTDArray<SkPathPos> pathsAndPositions;
-            pathsAndPositions.setReserve(runSize);
-            SkPoint* positionCursor = fPositions;
-            for (auto glyphID : glyphRun.glyphsIDs()) {
-                SkPoint position = *positionCursor++;
-                if (check_glyph_position(position)) {
-                    const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0});
-                    if (!glyph.isEmpty()) {
-                        const SkPath* path = pathCache->findPath(glyph);
-                        if (path != nullptr) {
-                            pathsAndPositions.push_back(SkPathPos{path, position});
-                        }
+            pathsAndPositions.setReserve(glyphPosSpan.size());
+            for (const SkGlyphPos& glyphPos : glyphPosSpan) {
+                const SkGlyph& glyph = *glyphPos.glyph;
+                SkPoint position = glyphPos.position;
+                if (check_glyph_position(position)
+                    && !glyph.isEmpty()
+                    && glyph.fMaskFormat != SkMask::kARGB32_Format
+                    && strike->decideCouldDrawFromPath(glyph))
+                {
+                    // Only draw a path if it exists, and this is not a color glyph.
+                    pathsAndPositions.push_back(SkPathPos{glyph.path(), position});
+                } else {
+                    // TODO: this is here to have chrome layout tests pass. Remove this when
+                    //  fallback for CPU works.
+                    if (check_glyph_position(position)
+                        && !glyph.isEmpty()
+                        && strike->decideCouldDrawFromPath(glyph))
+                    {
+                        pathsAndPositions.push_back(SkPathPos{glyph.path(), position});
                     }
                 }
             }