Make NVPR a GL context option instead of a GL context

Make NVPR a GL context option instead of a GL context.
This may enable NVPR to be run with command buffer
interface.

No functionality change in DM or nanobench. NVPR can
only be run with normal GL APIs.

BUG=skia:2992

Committed: https://skia.googlesource.com/skia/+/eeebdb538d476c1bfc8b63a946094ca1b505ecd1

Committed: https://skia.googlesource.com/skia/+/64492c43c3faee7ab0f69b1c84e0267616f85e52

Review URL: https://codereview.chromium.org/1448883002
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index a4453f9..f1841e5 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -170,10 +170,13 @@
         uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag :
                                                   0;
         SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
-        this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->config.ctxType),
+        this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->config.ctxType,
+                                                                       kNone_GrGLStandard,
+                                                                       this->config.ctxOptions),
                                                          SkSurface::kNo_Budgeted, info,
                                                          this->config.samples, &props));
-        this->gl = gGrFactory->getContextInfo(this->config.ctxType)->fGLContext;
+        this->gl = gGrFactory->getContextInfo(this->config.ctxType, kNone_GrGLStandard,
+                                              this->config.ctxOptions)->fGLContext;
         if (!this->surface.get()) {
             return false;
         }
@@ -385,11 +388,12 @@
 
 #if SK_SUPPORT_GPU
 static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextType ctxType,
+                                  GrContextFactory::GLContextOptions ctxOptions,
                                   int sampleCnt) {
     if (!is_cpu_config_allowed(name)) {
         return false;
     }
-    if (const GrContext* ctx = gGrFactory->get(ctxType)) {
+    if (const GrContext* ctx = gGrFactory->get(ctxType, kNone_GrGLStandard, ctxOptions)) {
         return sampleCnt <= ctx->caps()->maxSampleCount();
     }
     return false;
@@ -398,17 +402,20 @@
 
 #if SK_SUPPORT_GPU
 #define kBogusGLContextType GrContextFactory::kNative_GLContextType
+#define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions
 #else
 #define kBogusGLContextType 0
+#define kBogusGLContextOptions 0
 #endif
 
 // Append all configs that are enabled and supported.
 static void create_configs(SkTDArray<Config>* configs) {
-    #define CPU_CONFIG(name, backend, color, alpha)                       \
-        if (is_cpu_config_allowed(#name)) {                               \
-            Config config = { #name, Benchmark::backend, color, alpha, 0, \
-                              kBogusGLContextType, false };               \
-            configs->push(config);                                        \
+    #define CPU_CONFIG(name, backend, color, alpha)                        \
+        if (is_cpu_config_allowed(#name)) {                                \
+            Config config = { #name, Benchmark::backend, color, alpha, 0,  \
+                              kBogusGLContextType, kBogusGLContextOptions, \
+                              false };                                     \
+            configs->push(config);                                         \
         }
 
     if (FLAGS_cpu) {
@@ -418,8 +425,9 @@
     }
 
 #if SK_SUPPORT_GPU
-    #define GPU_CONFIG(name, ctxType, samples, useDFText)                        \
-        if (is_gpu_config_allowed(#name, GrContextFactory::ctxType, samples)) {  \
+    #define GPU_CONFIG(name, ctxType, ctxOptions, samples, useDFText)            \
+        if (is_gpu_config_allowed(#name, GrContextFactory::ctxType,              \
+                                  GrContextFactory::ctxOptions, samples)) {      \
             Config config = {                                                    \
                 #name,                                                           \
                 Benchmark::kGPU_Backend,                                         \
@@ -427,28 +435,29 @@
                 kPremul_SkAlphaType,                                             \
                 samples,                                                         \
                 GrContextFactory::ctxType,                                       \
+                GrContextFactory::ctxOptions,                                    \
                 useDFText };                                                     \
             configs->push(config);                                               \
         }
 
     if (FLAGS_gpu) {
-        GPU_CONFIG(gpu, kNative_GLContextType, 0, false)
-        GPU_CONFIG(msaa4, kNative_GLContextType, 4, false)
-        GPU_CONFIG(msaa16, kNative_GLContextType, 16, false)
-        GPU_CONFIG(nvprmsaa4, kNVPR_GLContextType, 4, false)
-        GPU_CONFIG(nvprmsaa16, kNVPR_GLContextType, 16, false)
-        GPU_CONFIG(gpudft, kNative_GLContextType, 0, true)
-        GPU_CONFIG(debug, kDebug_GLContextType, 0, false)
-        GPU_CONFIG(nullgpu, kNull_GLContextType, 0, false)
+        GPU_CONFIG(gpu, kNative_GLContextType, kNone_GLContextOptions, 0, false)
+        GPU_CONFIG(msaa4, kNative_GLContextType, kNone_GLContextOptions, 4, false)
+        GPU_CONFIG(msaa16, kNative_GLContextType, kNone_GLContextOptions, 16, false)
+        GPU_CONFIG(nvprmsaa4, kNative_GLContextType, kEnableNVPR_GLContextOptions, 4, false)
+        GPU_CONFIG(nvprmsaa16, kNative_GLContextType, kEnableNVPR_GLContextOptions, 16, false)
+        GPU_CONFIG(gpudft, kNative_GLContextType, kNone_GLContextOptions, 0, true)
+        GPU_CONFIG(debug, kDebug_GLContextType, kNone_GLContextOptions, 0, false)
+        GPU_CONFIG(nullgpu, kNull_GLContextType, kNone_GLContextOptions, 0, false)
 #ifdef SK_ANGLE
-        GPU_CONFIG(angle, kANGLE_GLContextType, 0, false)
-        GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, 0, false)
+        GPU_CONFIG(angle, kANGLE_GLContextType, kNone_GLContextOptions, 0, false)
+        GPU_CONFIG(angle-gl, kANGLE_GL_GLContextType, kNone_GLContextOptions, 0, false)
 #endif
 #ifdef SK_COMMAND_BUFFER
-        GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, 0, false)
+        GPU_CONFIG(commandbuffer, kCommandBuffer_GLContextType, kNone_GLContextOptions, 0, false)
 #endif
 #if SK_MESA
-        GPU_CONFIG(mesa, kMESA_GLContextType, 0, false)
+        GPU_CONFIG(mesa, kMESA_GLContextType, kNone_GLContextOptions, 0, false)
 #endif
     }
 #endif
@@ -456,7 +465,8 @@
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
     if (is_cpu_config_allowed("hwui")) {
         Config config = { "hwui", Benchmark::kHWUI_Backend, kRGBA_8888_SkColorType,
-                          kPremul_SkAlphaType, 0, kBogusGLContextType, false };
+                          kPremul_SkAlphaType, 0, kBogusGLContextType, kBogusGLContextOptions,
+                          false };
         configs->push(config);
     }
 #endif
@@ -1268,8 +1278,10 @@
 
 #if SK_SUPPORT_GPU
             if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) {
-                gGrFactory->get(configs[i].ctxType)->printCacheStats();
-                gGrFactory->get(configs[i].ctxType)->printGpuStats();
+                GrContext* context = gGrFactory->get(configs[i].ctxType,
+                                                     kNone_GrGLStandard, configs[i].ctxOptions);
+                context->printCacheStats();
+                context->printGpuStats();
             }
 #endif