Rename enums in GrContextFactory to remove "GL"

Also, remove kNative as a separate context type and instead make it an alias for kGL or kGLES based on OS.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1845923004

Committed: https://skia.googlesource.com/skia/+/2d9c6f81353597aebf5934547e5cba7a872196fb

Review URL: https://codereview.chromium.org/1845923004
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 973f14e..0847ae5 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -211,47 +211,43 @@
 }
 static bool parse_option_gpu_api(const SkString& value,
                                  SkCommandLineConfigGpu::ContextType* outContextType) {
-    if (value.equals("native")) {
-        *outContextType = GrContextFactory::kNative_GLContextType;
-        return true;
-    }
     if (value.equals("gl")) {
-        *outContextType = GrContextFactory::kGL_GLContextType;
+        *outContextType = GrContextFactory::kGL_ContextType;
         return true;
     }
     if (value.equals("gles")) {
-        *outContextType = GrContextFactory::kGLES_GLContextType;
+        *outContextType = GrContextFactory::kGLES_ContextType;
         return true;
     }
     if (value.equals("debug")) {
-        *outContextType = GrContextFactory::kDebug_GLContextType;
+        *outContextType = GrContextFactory::kDebugGL_ContextType;
         return true;
     }
     if (value.equals("null")) {
-        *outContextType = GrContextFactory::kNull_GLContextType;
+        *outContextType = GrContextFactory::kNullGL_ContextType;
         return true;
     }
 #if SK_ANGLE
 #ifdef SK_BUILD_FOR_WIN
     if (value.equals("angle")) {
-        *outContextType = GrContextFactory::kANGLE_GLContextType;
+        *outContextType = GrContextFactory::kANGLE_ContextType;
         return true;
     }
 #endif
     if (value.equals("angle-gl")) {
-        *outContextType = GrContextFactory::kANGLE_GL_GLContextType;
+        *outContextType = GrContextFactory::kANGLE_GL_ContextType;
         return true;
     }
 #endif
 #if SK_COMMAND_BUFFER
     if (value.equals("commandbuffer")) {
-        *outContextType = GrContextFactory::kCommandBuffer_GLContextType;
+        *outContextType = GrContextFactory::kCommandBuffer_ContextType;
         return true;
     }
 #endif
 #if SK_MESA
     if (value.equals("mesa")) {
-        *outContextType = GrContextFactory::kMESA_GLContextType;
+        *outContextType = GrContextFactory::kMESA_ContextType;
         return true;
     }
 #endif
@@ -283,7 +279,7 @@
                                                       const SkString& options) {
     // Defaults for GPU backend.
     bool seenAPI = false;
-    SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNative_GLContextType;
+    SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
     bool seenUseNVPR = false;
     bool useNVPR = false;
     bool seenUseDIText =false;
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index abf5946..5d95ef1 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -50,7 +50,7 @@
 // * backends that represent a shorthand of above (such as "msaa16" representing "gpu(samples=16)")
 class SkCommandLineConfigGpu : public SkCommandLineConfig {
   public:
-    typedef sk_gpu_test::GrContextFactory::GLContextType ContextType;
+    typedef sk_gpu_test::GrContextFactory::ContextType ContextType;
     SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
                            ContextType contextType, bool useNVPR, bool useDIText, int samples,
                            SkColorType colorType, SkColorProfileType profileType);
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index c232121..18fbef8 100755
--- a/tools/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -74,8 +74,16 @@
     }
 }
 
-GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType type,
-                                                               GLContextOptions options) {
+#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
+const GrContextFactory::ContextType GrContextFactory::kNativeGL_ContextType =
+    GrContextFactory::kGL_ContextType;
+#else
+const GrContextFactory::ContextType GrContextFactory::kNativeGL_ContextType =
+    GrContextFactory::kGLES_ContextType;
+#endif
+
+GrContextFactory::ContextInfo GrContextFactory::getContextInfo(ContextType type,
+                                                               ContextOptions options) {
     for (int i = 0; i < fContexts.count(); ++i) {
         Context& context = fContexts[i];
         if (!context.fGLContext) {
@@ -90,39 +98,36 @@
     SkAutoTDelete<GLTestContext> glCtx;
     SkAutoTUnref<GrContext> grCtx;
     switch (type) {
-        case kNative_GLContextType:
-            glCtx.reset(CreatePlatformGLTestContext(kNone_GrGLStandard));
-            break;
-        case kGL_GLContextType:
+        case kGL_ContextType:
             glCtx.reset(CreatePlatformGLTestContext(kGL_GrGLStandard));
             break;
-        case kGLES_GLContextType:
+        case kGLES_ContextType:
             glCtx.reset(CreatePlatformGLTestContext(kGLES_GrGLStandard));
             break;
 #if SK_ANGLE
 #ifdef SK_BUILD_FOR_WIN
-        case kANGLE_GLContextType:
+        case kANGLE_ContextType:
             glCtx.reset(CreateANGLEDirect3DGLTestContext());
             break;
 #endif
-        case kANGLE_GL_GLContextType:
+        case kANGLE_GL_ContextType:
             glCtx.reset(CreateANGLEOpenGLGLTestContext());
             break;
 #endif
 #if SK_COMMAND_BUFFER
-        case kCommandBuffer_GLContextType:
+        case kCommandBuffer_ContextType:
             glCtx.reset(CommandBufferGLTestContext::Create());
             break;
 #endif
 #if SK_MESA
-        case kMESA_GLContextType:
+        case kMESA_ContextType:
             glCtx.reset(CreateMesaGLTestContext());
             break;
 #endif
-        case kNull_GLContextType:
+        case kNullGL_ContextType:
             glCtx.reset(CreateNullGLTestContext());
             break;
-        case kDebug_GLContextType:
+        case kDebugGL_ContextType:
             glCtx.reset(CreateDebugGLTestContext());
             break;
     }
@@ -134,7 +139,7 @@
 
     // Block NVPR from non-NVPR types.
     SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
-    if (!(kEnableNVPR_GLContextOptions & options)) {
+    if (!(kEnableNVPR_ContextOptions & options)) {
         glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
         if (!glInterface) {
             return ContextInfo();
@@ -143,7 +148,7 @@
 
     glCtx->makeCurrent();
 #ifdef SK_VULKAN
-    if (kEnableNVPR_GLContextOptions & options) {
+    if (kEnableNVPR_ContextOptions & options) {
         return ContextInfo();
     } else {
         GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(GrVkBackendContext::Create());
@@ -156,12 +161,12 @@
     if (!grCtx.get()) {
         return ContextInfo();
     }
-    if (kEnableNVPR_GLContextOptions & options) {
+    if (kEnableNVPR_ContextOptions & options) {
         if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
             return ContextInfo();
         }
     }
-    if (kRequireSRGBSupport_GLContextOptions & options) {
+    if (kRequireSRGBSupport_ContextOptions & options) {
         if (!grCtx->caps()->srgbSupport()) {
             return ContextInfo();
         }
diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
index 16f6fb2..7c49faa 100644
--- a/tools/gpu/GrContextFactory.h
+++ b/tools/gpu/GrContextFactory.h
@@ -24,76 +24,76 @@
  */
 class GrContextFactory : SkNoncopyable {
 public:
-    enum GLContextType {
-        kNative_GLContextType,  //! OpenGL or OpenGL ES context.
-        kGL_GLContextType,      //! OpenGL context.
-        kGLES_GLContextType,    //! OpenGL ES context.
+    enum ContextType {
+        kGL_ContextType,            //! OpenGL context.
+        kGLES_ContextType,          //! OpenGL ES context.
 #if SK_ANGLE
 #ifdef SK_BUILD_FOR_WIN
-        kANGLE_GLContextType,    //! ANGLE on DirectX OpenGL ES context.
+        kANGLE_ContextType,         //! ANGLE on DirectX OpenGL ES context.
 #endif
-        kANGLE_GL_GLContextType, //! ANGLE on OpenGL OpenGL ES context.
+        kANGLE_GL_ContextType,      //! ANGLE on OpenGL OpenGL ES context.
 #endif
 #if SK_COMMAND_BUFFER
-        kCommandBuffer_GLContextType, //! Chromium command buffer OpenGL ES context.
+        kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES context.
 #endif
 #if SK_MESA
-        kMESA_GLContextType,  //! MESA OpenGL context
+        kMESA_ContextType,          //! MESA OpenGL context
 #endif
-        kNull_GLContextType,  //! Non-rendering OpenGL mock context.
-        kDebug_GLContextType, //! Non-rendering, state verifying OpenGL context.
-        kLastGLContextType = kDebug_GLContextType
+        kNullGL_ContextType,        //! Non-rendering OpenGL mock context.
+        kDebugGL_ContextType,       //! Non-rendering, state verifying OpenGL context.
+        kLastContextType = kDebugGL_ContextType
     };
 
-    static const int kGLContextTypeCnt = kLastGLContextType + 1;
+    //! OpenGL or OpenGL ES context depending on the platform. To be removed.
+    static const ContextType kNativeGL_ContextType;
+
+    static const int kContextTypeCnt = kLastContextType + 1;
 
     /**
      * Options for GL context creation. For historical and testing reasons the options will default
      * to not using GL_NV_path_rendering extension  even when the driver supports it.
      */
-    enum GLContextOptions {
-        kNone_GLContextOptions = 0,
-        kEnableNVPR_GLContextOptions = 0x1,
-        kRequireSRGBSupport_GLContextOptions = 0x2,
+    enum ContextOptions {
+        kNone_ContextOptions                = 0x0,
+        kEnableNVPR_ContextOptions          = 0x1,
+        kRequireSRGBSupport_ContextOptions  = 0x2,
     };
 
-    static bool IsRenderingGLContext(GLContextType type) {
+    static bool IsRenderingContext(ContextType type) {
         switch (type) {
-            case kNull_GLContextType:
-            case kDebug_GLContextType:
+            case kNullGL_ContextType:
+            case kDebugGL_ContextType:
                 return false;
             default:
                 return true;
         }
     }
 
-    static const char* GLContextTypeName(GLContextType type) {
+    static const char* ContextTypeName(ContextType type) {
         switch (type) {
-            case kNative_GLContextType:
-                return "native";
-            case kGL_GLContextType:
+            case kGL_ContextType:
                 return "gl";
-            case kGLES_GLContextType:
+            case kGLES_ContextType:
                 return "gles";
 #if SK_ANGLE
 #ifdef SK_BUILD_FOR_WIN
-            case kANGLE_GLContextType:
+            case kANGLE_ContextType:
                 return "angle";
 #endif
-            case kANGLE_GL_GLContextType:
+            case kANGLE_GL_ContextType:
                 return "angle-gl";
 #endif
 #if SK_COMMAND_BUFFER
-            case kCommandBuffer_GLContextType:
+            case kCommandBuffer_ContextType:
                 return "commandbuffer";
 #endif
 #if SK_MESA
-            case kMESA_GLContextType:
+            case kMESA_ContextType:
                 return "mesa";
 #endif
-            case kNull_GLContextType:
+            case kNullGL_ContextType:
                 return "null";
-            case kDebug_GLContextType:
+            case kDebugGL_ContextType:
                 return "debug";
             default:
                 SkFAIL("Unknown GL Context type.");
@@ -122,22 +122,21 @@
     /**
      * Get a context initialized with a type of GL context. It also makes the GL context current.
      */
-    ContextInfo getContextInfo(GLContextType type,
-                               GLContextOptions options = kNone_GLContextOptions);
+    ContextInfo getContextInfo(ContextType type,
+                               ContextOptions options = kNone_ContextOptions);
     /**
      * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
      */
-    GrContext* get(GLContextType type,
-                   GLContextOptions options = kNone_GLContextOptions) {
+    GrContext* get(ContextType type, ContextOptions options = kNone_ContextOptions) {
         return this->getContextInfo(type, options).fGrContext;
     }
     const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
 
 private:
     struct Context {
-        GLContextType       fType;
-        GLContextOptions    fOptions;
-        GLTestContext*          fGLContext;
+        ContextType         fType;
+        ContextOptions      fOptions;
+        GLTestContext*      fGLContext; //  null if non-GL
         GrContext*          fGrContext;
     };
     SkTArray<Context, true> fContexts;
diff --git a/tools/kilobench/kilobench.cpp b/tools/kilobench/kilobench.cpp
index f4c2999..dc7f938 100644
--- a/tools/kilobench/kilobench.cpp
+++ b/tools/kilobench/kilobench.cpp
@@ -175,8 +175,8 @@
     }
 
     bool init(Benchmark* bench, GrContextFactory* factory, bool useDfText,
-              GrContextFactory::GLContextType ctxType,
-              GrContextFactory::GLContextOptions ctxOptions, int numSamples) {
+              GrContextFactory::ContextType ctxType,
+              GrContextFactory::ContextOptions ctxOptions, int numSamples) {
         GrContext* context = factory->get(ctxType, ctxOptions);
         int maxRTSize = context->caps()->maxRenderTargetSize();
         SkImageInfo info = SkImageInfo::Make(SkTMin(bench->getSize().fX, maxRTSize),
@@ -478,8 +478,8 @@
         fCtxFactory.reset(new GrContextFactory(grContextOpts));
 
         SkAssertResult(fTarget.init(bench, fCtxFactory, false,
-                                    GrContextFactory::kNative_GLContextType,
-                                    GrContextFactory::kNone_GLContextOptions, 0));
+                                    GrContextFactory::kNativeGL_ContextType,
+                                    GrContextFactory::kNone_ContextOptions, 0));
 
         fCanvas = fTarget.getCanvas();
         fTarget.setup();
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 225ca39..7534b1d 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -65,8 +65,8 @@
 SkCanvas* Request::getCanvas() {
 #if SK_SUPPORT_GPU
     GrContextFactory* factory = fContextFactory;
-    GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
-                                            GrContextFactory::kNone_GLContextOptions).fGLContext;
+    GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_ContextType,
+                                            GrContextFactory::kNone_ContextOptions).fGLContext;
     gl->makeCurrent();
 #endif
     SkASSERT(fDebugCanvas);
@@ -109,8 +109,8 @@
 
 GrContext* Request::getContext() {
 #if SK_SUPPORT_GPU
-  return fContextFactory->get(GrContextFactory::kNative_GLContextType,
-                              GrContextFactory::kNone_GLContextOptions);
+  return fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
+                              GrContextFactory::kNone_ContextOptions);
 #else
   return nullptr;
 #endif