Add the ability to enable/disable GPU path renderers

Adds a bitfield to GrContextOptions that masks out path renderers.
Adds commandline flags support to set this bitfield in tools apps.
Removes GrGLInterfaceRemoveNVPR since we can now accomplish the same
thing in the context options.

BUG=skia:

Change-Id: Icf2a4df36374b3ba2f69ebf0db56e8aedd6cf65f
Reviewed-on: https://skia-review.googlesource.com/8786
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index c25076f..5e3185b 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -16,6 +16,7 @@
 #include "SkColorSpace.h"
 #include "SkCommonFlags.h"
 #include "SkCommonFlagsConfig.h"
+#include "SkCommonFlagsPathRenderer.h"
 #include "SkData.h"
 #include "SkFontMgr.h"
 #include "SkGraphics.h"
@@ -77,6 +78,10 @@
 
 DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.");
 
+#if SK_SUPPORT_GPU
+DEFINE_pathrenderer_flag;
+#endif
+
 using namespace DM;
 using sk_gpu_test::GrContextFactory;
 using sk_gpu_test::GLTestContext;
@@ -838,13 +843,13 @@
 #endif
 }
 
-static Sink* create_sink(const SkCommandLineConfig* config) {
+static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLineConfig* config) {
 #if SK_SUPPORT_GPU
     if (gpu_supported()) {
         if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
             GrContextFactory::ContextType contextType = gpuConfig->getContextType();
             GrContextFactory::ContextOverrides contextOverrides = gpuConfig->getContextOverrides();
-            GrContextFactory testFactory;
+            GrContextFactory testFactory(grCtxOptions);
             if (!testFactory.get(contextType, contextOverrides)) {
                 info("WARNING: can not create GPU context for config '%s'. "
                      "GM tests will be skipped.\n", gpuConfig->getTag().c_str());
@@ -911,12 +916,12 @@
     return nullptr;
 }
 
-static bool gather_sinks() {
+static bool gather_sinks(const GrContextOptions& grCtxOptions) {
     SkCommandLineConfigArray configs;
     ParseConfigs(FLAGS_config, &configs);
     for (int i = 0; i < configs.count(); i++) {
         const SkCommandLineConfig& config = *configs[i];
-        Sink* sink = create_sink(&config);
+        Sink* sink = create_sink(grCtxOptions, &config);
         if (sink == nullptr) {
             info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
                  config.getTag().c_str());
@@ -1233,7 +1238,7 @@
     }
 }
 
-static void run_test(skiatest::Test test) {
+static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions) {
     struct : public skiatest::Reporter {
         void reportFailed(const skiatest::Failure& failure) override {
             fail(failure.toString());
@@ -1247,7 +1252,7 @@
 
     if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
         start("unit", "test", "", test.name);
-        GrContextFactory factory;
+        GrContextFactory factory(grCtxOptions);
         test.proc(&reporter, &factory);
     }
     done("unit", "test", "", test.name);
@@ -1307,6 +1312,11 @@
         gVLog = fopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w");
     }
 
+    GrContextOptions grCtxOptions;
+#if SK_SUPPORT_GPU
+    grCtxOptions.fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
+#endif
+
     JsonWriter::DumpJson();  // It's handy for the bots to assume this is ~never missing.
     SkAutoGraphics ag;
     SkTaskGroup::Enabler enabled(FLAGS_threads);
@@ -1325,7 +1335,7 @@
     if (!gather_srcs()) {
         return 1;
     }
-    if (!gather_sinks()) {
+    if (!gather_sinks(grCtxOptions)) {
         return 1;
     }
     gather_tests();
@@ -1356,12 +1366,12 @@
         }
     }
     for (auto test : gParallelTests) {
-        parallel.add([test] { run_test(test); });
+        parallel.add([test, grCtxOptions] { run_test(test, grCtxOptions); });
     }
 
     // With the parallel work running, run serial tasks and tests here on main thread.
     for (auto task : serial) { Task::Run(task); }
-    for (auto test : gSerialTests) { run_test(test); }
+    for (auto test : gSerialTests) { run_test(test, grCtxOptions); }
 
     // Wait for any remaining parallel work to complete (including any spun off of serial tasks).
     parallel.wait();