Reland of Make draw* lines responsible for cache management (patchset #1 id:1 of https://codereview.chromium.org/1552513003/ )

Reason for revert:
might have been premature

Original issue's description:
> Revert of Make draw* lines responsible for cache management (patchset #1 id:1 of https://codereview.chromium.org/1521613002/ )
>
> Reason for revert:
> seeing crashes on android and linux
>
> Original issue's description:
> > Make draw* lines responsible for cache management
> >
> > TBR=bsalomon@google.com
> > BUG=skia:
> >
> > Committed: https://skia.googlesource.com/skia/+/66957946c0c418e71c0f36bb2904cc38c334eba4
>
> TBR=bsalomon@google.com,jvanverth@google.com,joshualitt@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/90e293dae4990a86cb952663ccde8fae55112d7d

TBR=bsalomon@google.com,jvanverth@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1551563003
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index dee6d13..f79f825 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -13,9 +13,25 @@
 #include "GrTextUtils.h"
 #include "SkColorFilter.h"
 #include "SkDrawFilter.h"
+#include "SkGlyphCache.h"
 #include "SkTextBlobRunIterator.h"
 #include "batches/GrAtlasTextBatch.h"
 
+SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex,
+                                          const SkSurfaceProps& props,
+                                          const SkPaint& skPaint,
+                                          const SkMatrix* viewMatrix,
+                                          bool noGamma) {
+    GrAtlasTextBlob::Run* run = &fRuns[runIndex];
+
+    // if we have an override descriptor for the run, then we should use that
+    SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDescriptor.get() :
+                                                              &run->fDescriptor;
+    skPaint.getScalerContextDescriptor(desc, props, viewMatrix, noGamma);
+    run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
+    return SkGlyphCache::DetachCache(run->fTypeface, desc->getDesc());
+}
+
 void GrAtlasTextBlob::appendGlyph(int runIndex,
                                   const SkRect& positions,
                                   GrColor color,