Add GrContextOptions flag to disable distance field path renderer.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339213002

Review-Url: https://codereview.chromium.org/2339213002
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index b274895..a9c8561 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -11,73 +11,64 @@
 #include "SkTypes.h"
 
 struct GrContextOptions {
-    GrContextOptions()
-        : fSuppressPrints(false)
-        , fMaxTextureSizeOverride(SK_MaxS32)
-        , fMaxTileSizeOverride(0)
-        , fSuppressDualSourceBlending(false)
-        , fBufferMapThreshold(-1)
-        , fUseDrawInsteadOfPartialRenderTargetWrite(false)
-        , fImmediateMode(false)
-        , fClipBatchToBounds(false)
-        , fDrawBatchBounds(false)
-        , fMaxBatchLookback(-1)
-        , fMaxBatchLookahead(-1)
-        , fUseShaderSwizzling(false)
-        , fDoManualMipmapping(false)
-        , fEnableInstancedRendering(false) {}
+    GrContextOptions() {};
 
     // Suppress prints for the GrContext.
-    bool fSuppressPrints;
+    bool fSuppressPrints = false;
 
     /** Overrides: These options override feature detection using backend API queries. These
         overrides can only reduce the feature set or limits, never increase them beyond the
         detected values. */
 
-    int  fMaxTextureSizeOverride;
+    int  fMaxTextureSizeOverride = SK_MaxS32;
+
     /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
         by SkGpuDevice. */
-    int  fMaxTileSizeOverride;
-    bool fSuppressDualSourceBlending;
+    int  fMaxTileSizeOverride = 0;
+    bool fSuppressDualSourceBlending = false;
 
     /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index
         buffers to CPU memory in order to update them.  A value of -1 means the GrContext should
         deduce the optimal value for this platform. */
-    int  fBufferMapThreshold;
+    int  fBufferMapThreshold = -1;
 
     /** some gpus have problems with partial writes of the rendertarget */
-    bool fUseDrawInsteadOfPartialRenderTargetWrite;
+    bool fUseDrawInsteadOfPartialRenderTargetWrite = false;
 
     /** The GrContext operates in immediate mode. It will issue all draws to the backend API
         immediately. Intended to ease debugging. */
-    bool fImmediateMode;
+    bool fImmediateMode = false;
 
     /** For debugging purposes turn each GrBatch's bounds into a clip rect. This is used to
         verify that the clip bounds are conservative. */
-    bool fClipBatchToBounds;
+    bool fClipBatchToBounds = false;
 
     /** For debugging purposes draw a wireframe device bounds rect for each GrBatch. The wire
         frame rect is draw before the GrBatch in order to visualize batches that draw outside
         of their dev bounds. */
-    bool fDrawBatchBounds;
+    bool fDrawBatchBounds = false;
 
     /** For debugging, override the default maximum look-back or look-ahead window for GrBatch
         combining. */
-    int fMaxBatchLookback;
-    int fMaxBatchLookahead;
+    int fMaxBatchLookback = -1;
+    int fMaxBatchLookahead = -1;
 
     /** Force us to do all swizzling manually in the shader and don't rely on extensions to do
         swizzling. */
-    bool fUseShaderSwizzling;
+    bool fUseShaderSwizzling = false;
 
     /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when
         the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap
         level and LOD control (ie desktop or ES3). */
-    bool fDoManualMipmapping;
+    bool fDoManualMipmapping = false;
 
     /** Enable instanced rendering as long as all required functionality is supported by the HW.
         Instanced rendering is still experimental at this point and disabled by default. */
-    bool fEnableInstancedRendering;
+    bool fEnableInstancedRendering = false;
+
+    /** Disables distance field rendering for paths. Distance field computation can be expensive
+        and yields no benefit if a path is not rendered multiple times with different transforms */
+    bool fDisableDistanceFieldPaths = false;
 };
 
 #endif
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 47fb323..fbb59a3 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -95,7 +95,9 @@
     dtOptions.fDrawBatchBounds = options.fDrawBatchBounds;
     dtOptions.fMaxBatchLookback = options.fMaxBatchLookback;
     dtOptions.fMaxBatchLookahead = options.fMaxBatchLookahead;
-    fDrawingManager.reset(new GrDrawingManager(this, dtOptions, options.fImmediateMode,
+    GrPathRendererChain::Options prcOptions;
+    prcOptions.fDisableDistanceFieldRenderer = options.fDisableDistanceFieldPaths;
+    fDrawingManager.reset(new GrDrawingManager(this, dtOptions, prcOptions, options.fImmediateMode,
                                                &fSingleOwner));
 
     // GrBatchFontCache will eventually replace GrFontCache
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index e8cea75..606a9abd 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -197,7 +197,7 @@
                                                   GrPathRenderer::StencilSupport* stencilSupport) {
 
     if (!fPathRendererChain) {
-        fPathRendererChain = new GrPathRendererChain(fContext);
+        fPathRendererChain = new GrPathRendererChain(fContext, fOptionsForPathRendererChain);
     }
 
     GrPathRenderer* pr = fPathRendererChain->getPathRenderer(args, drawType, stencilSupport);
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 56e46ef..9fced38 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -64,9 +64,11 @@
 
 private:
     GrDrawingManager(GrContext* context, const GrDrawTarget::Options& optionsForDrawTargets,
+                     const GrPathRendererChain::Options& optionsForPathRendererChain,
                      bool isImmediateMode, GrSingleOwner* singleOwner)
         : fContext(context)
         , fOptionsForDrawTargets(optionsForDrawTargets)
+        , fOptionsForPathRendererChain(optionsForPathRendererChain)
         , fSingleOwner(singleOwner)
         , fAbandoned(false)
         , fAtlasTextContext(nullptr)
@@ -90,6 +92,7 @@
 
     GrContext*                        fContext;
     GrDrawTarget::Options             fOptionsForDrawTargets;
+    GrPathRendererChain::Options      fOptionsForPathRendererChain;
 
     // In debug builds we guard against improper thread handling
     GrSingleOwner*                    fSingleOwner;
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index ac1c4a6..12ad51e 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -25,7 +25,7 @@
 #include "batches/GrStencilAndCoverPathRenderer.h"
 #include "batches/GrTessellatingPathRenderer.h"
 
-GrPathRendererChain::GrPathRendererChain(GrContext* context) {
+GrPathRendererChain::GrPathRendererChain(GrContext* context, const Options& options) {
     const GrCaps& caps = *context->caps();
     this->addPathRenderer(new GrDashLinePathRenderer)->unref();
 
@@ -44,7 +44,9 @@
     if (caps.shaderCaps()->plsPathRenderingSupport()) {
         this->addPathRenderer(new GrPLSPathRenderer)->unref();
     }
-    this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref();
+    if (!options.fDisableDistanceFieldRenderer) {
+        this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref();
+    }
     this->addPathRenderer(new GrTessellatingPathRenderer)->unref();
     this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(),
                                                     caps.stencilWrapOpsSupport()))->unref();
diff --git a/src/gpu/GrPathRendererChain.h b/src/gpu/GrPathRendererChain.h
index ade3055..2a11a19 100644
--- a/src/gpu/GrPathRendererChain.h
+++ b/src/gpu/GrPathRendererChain.h
@@ -23,7 +23,10 @@
  */
 class GrPathRendererChain : public SkNoncopyable {
 public:
-    GrPathRendererChain(GrContext* context);
+    struct Options {
+        bool fDisableDistanceFieldRenderer = false;
+    };
+    GrPathRendererChain(GrContext* context, const Options&);
 
     ~GrPathRendererChain();