Separate cache lookup from run font setup

Seperate concerns so that cache lookup and run setup are different code.
This will allow the common code in painter to do the caache lookup.

Change-Id: I30a208ebc715c07f5720a7a8fc8240aabfda869d
Reviewed-on: https://skia-review.googlesource.com/c/180928
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index ad3bf1a..73a47fe 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -58,27 +58,32 @@
     return blob;
 }
 
-GrTextBlob::BothCaches GrTextBlob::Run::setupCache(const SkPaint& paint,
-                                                   const SkFont& font,
-                                                   const SkSurfaceProps& props,
-                                                   SkScalerContextFlags scalerContextFlags,
-                                                   const SkMatrix& viewMatrix,
-                                                   GrGlyphCache* grGlyphCache) {
-    // if we have an override descriptor for the run, then we should use that
-    SkAutoDescriptor* desc = fARGBFallbackDescriptor.get() ? fARGBFallbackDescriptor.get() : &fDescriptor;
-    SkScalerContextEffects effects;
-    SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
-        font, paint, props, scalerContextFlags, viewMatrix, desc, &effects);
-    fTypeface = SkFontPriv::RefTypefaceOrDefault(font);
-    fPathEffect = sk_ref_sp(effects.fPathEffect);
-    fMaskFilter = sk_ref_sp(effects.fMaskFilter);
-
-    SkExclusiveStrikePtr skCache =
-            SkStrikeCache::FindOrCreateStrikeExclusive(*desc->getDesc(), effects, *fTypeface);
+GrTextBlob::BothCaches GrTextBlob::Run::lookupCache(const SkPaint& skPaint,
+                                                    const SkFont& skFont,
+                                                    const SkSurfaceProps& props,
+                                                    SkScalerContextFlags scalerContextFlags,
+                                                    const SkMatrix& viewMatrix,
+                                                    GrGlyphCache* grGlyphCache) {
+    auto skCache = SkStrikeCache::FindOrCreateStrikeExclusive(
+            skFont, skPaint, props, scalerContextFlags, viewMatrix);
     sk_sp<GrTextStrike> grCache = grGlyphCache->getStrike(skCache.get());
     return {std::move(skCache), std::move(grCache)};
 }
 
+void GrTextBlob::Run::setupFont(const SkPaint& skPaint,
+                                const SkFont& skFont,
+                                const SkDescriptor& cacheDescriptor) {
+    fTypeface = SkFontPriv::RefTypefaceOrDefault(skFont);
+    SkScalerContextEffects effects{skPaint};
+    fPathEffect = sk_ref_sp(effects.fPathEffect);
+    fMaskFilter = sk_ref_sp(effects.fMaskFilter);
+    // if we have an override descriptor for the run, then we should use that
+    SkAutoDescriptor* desc =
+            fARGBFallbackDescriptor.get() ? fARGBFallbackDescriptor.get() : &fDescriptor;
+    // Set up the descriptor for possible cache lookups during regen.
+    desc->reset(cacheDescriptor);
+}
+
 void GrTextBlob::Run::appendPathGlyph(const SkPath& path, SkPoint position,
                                       SkScalar scale, bool preTransformed) {
     fPathGlyphs.push_back(PathGlyph(path, position.x(), position.y(), scale, preTransformed));