Revert of Implement support for using GL ES 3.0 with command buffer (patchset #6 id:100001 of https://codereview.chromium.org/1684413003/ )

Reason for revert:
The dependency, ES3 implementation in command_buffer_gles2, got reverted.

Original issue's description:
> Implement support for using GL ES 3.0 with command buffer
>
> Adds a new 'api': --config gpu(api=commandbuffer3) for dm/nanobench.
>
> BUG=skia:4943
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1684413003
>
> Committed: https://skia.googlesource.com/skia/+/45c2c8166bbd84a87e29fdd344b39e36e8a28a3f

TBR=bsalomon@google.com
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=skia:4943
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1744963002

Review URL: https://codereview.chromium.org/1744963002
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index 3f7fd4a..b7e4825 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -95,11 +95,8 @@
             break;
 #endif
 #if SK_COMMAND_BUFFER
-        case kCommandBufferES2_GLContextType:
-            glCtx.reset(SkCommandBufferGLContext::CreateES2());
-            break;
-        case kCommandBufferES3_GLContextType:
-            glCtx.reset(SkCommandBufferGLContext::CreateES3());
+        case kCommandBuffer_GLContextType:
+            glCtx.reset(SkCommandBufferGLContext::Create());
             break;
 #endif
 #if SK_MESA
diff --git a/src/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h
index ca4420e..7afa310 100644
--- a/src/gpu/GrContextFactory.h
+++ b/src/gpu/GrContextFactory.h
@@ -34,9 +34,7 @@
         kANGLE_GL_GLContextType, //! ANGLE on OpenGL OpenGL ES context.
 #endif
 #if SK_COMMAND_BUFFER
-        kCommandBufferES2_GLContextType, //! Chromium command buffer OpenGL ES 2.0 context.
-        kCommandBufferES3_GLContextType, //! Chromium command buffer OpenGL ES 3.0 context.
-                                         //! Not ready for production.
+        kCommandBuffer_GLContextType, //! Chromium command buffer OpenGL ES context.
 #endif
 #if SK_MESA
         kMESA_GLContextType,  //! MESA OpenGL context
@@ -84,10 +82,8 @@
                 return "angle-gl";
 #endif
 #if SK_COMMAND_BUFFER
-            case kCommandBufferES2_GLContextType:
+            case kCommandBuffer_GLContextType:
                 return "commandbuffer";
-            case kCommandBufferES3_GLContextType:
-                return "commandbuffer3";
 #endif
 #if SK_MESA
             case kMESA_GLContextType:
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 22aa13f..5baed59 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -363,12 +363,12 @@
     } else {
         // Unextended GLES2 doesn't have any buffer mapping.
         fMapBufferFlags = kNone_MapBufferType;
-        if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) {
-            fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
-            fMapBufferType = kMapBufferRange_MapBufferType;
-        } else if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) {
+        if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) {
             fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
             fMapBufferType = kChromium_MapBufferType;
+        } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) {
+            fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
+            fMapBufferType = kMapBufferRange_MapBufferType;
         } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) {
             fMapBufferFlags = kCanMap_MapFlag;
             fMapBufferType = kMapBuffer_MapBufferType;
@@ -523,16 +523,6 @@
         fTextureSwizzleSupport = false;
     }
 
-    // TODO: remove after command buffer supports full ES 3.0.
-    if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3, 0) &&
-        kChromium_GrGLDriver == ctxInfo.driver()) {
-        fSupportsInstancedDraws = false;
-        fTextureSwizzleSupport = false;
-        SkASSERT(ctxInfo.hasExtension("GL_CHROMIUM_map_sub"));
-        fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
-        fMapBufferType = kChromium_MapBufferType;
-    }
-
     // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have
     // already been detected.
     this->initConfigTable(ctxInfo, gli, glslCaps);
diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp
index 7c77447..84c51fb 100644
--- a/src/gpu/gl/GrGLInterface.cpp
+++ b/src/gpu/gl/GrGLInterface.cpp
@@ -216,15 +216,6 @@
     if (GR_GL_INVALID_VER == glVer) {
         RETURN_FALSE_INTERFACE
     }
-    // TODO: Remove this once command buffer implements full ES3.
-    bool ALLOW_MISSING_FUNCTIONS_FOR_INCOMPLETE_COMMAND_BUFFER_ES3 = false;
-    if (kGLES_GrGLStandard == fStandard && glVer >= GR_GL_VER(3,0)) {
-        const GrGLubyte* rendererUByte;
-        GR_GL_CALL_RET(this, rendererUByte, GetString(GR_GL_RENDERER));
-        const char* renderer = reinterpret_cast<const char*>(rendererUByte);
-        ALLOW_MISSING_FUNCTIONS_FOR_INCOMPLETE_COMMAND_BUFFER_ES3 =
-                0 == strcmp(renderer, "Chromium");
-    }
 
     // Now check that baseline ES/Desktop fns not covered above are present
     // and that we have fn pointers for any advertised fExtensions that we will
@@ -315,10 +306,8 @@
             }
         }
     } else if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_texture_storage")) {
-        if (!ALLOW_MISSING_FUNCTIONS_FOR_INCOMPLETE_COMMAND_BUFFER_ES3) {
-            if (nullptr == fFunctions.fTexStorage2D) {
-                RETURN_FALSE_INTERFACE
-            }
+        if (nullptr == fFunctions.fTexStorage2D) {
+            RETURN_FALSE_INTERFACE
         }
     }
 
@@ -491,11 +480,9 @@
     if (glVer >= GR_GL_VER(3,0) ||
         (kGLES_GrGLStandard == fStandard && fExtensions.has("GL_EXT_map_buffer_range")) ||
         (kGL_GrGLStandard == fStandard && fExtensions.has("GL_ARB_map_buffer_range"))) {
-        if (!ALLOW_MISSING_FUNCTIONS_FOR_INCOMPLETE_COMMAND_BUFFER_ES3) {
-            if (nullptr == fFunctions.fMapBufferRange ||
-                nullptr == fFunctions.fFlushMappedBufferRange) {
-                RETURN_FALSE_INTERFACE;
-            }
+        if (nullptr == fFunctions.fMapBufferRange ||
+            nullptr == fFunctions.fFlushMappedBufferRange) {
+            RETURN_FALSE_INTERFACE;
         }
     }
 
@@ -583,16 +570,14 @@
                 nullptr == fFunctions.fDrawElementsInstanced) {
                 RETURN_FALSE_INTERFACE
             }
-        }
+        }    
     } else if (kGLES_GrGLStandard == fStandard) {
-        if (!ALLOW_MISSING_FUNCTIONS_FOR_INCOMPLETE_COMMAND_BUFFER_ES3) {
-            if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_draw_instanced")) {
-                if (nullptr == fFunctions.fDrawArraysInstanced ||
-                    nullptr == fFunctions.fDrawElementsInstanced) {
-                    RETURN_FALSE_INTERFACE
-                }
+        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_draw_instanced")) {
+            if (nullptr == fFunctions.fDrawArraysInstanced ||
+                nullptr == fFunctions.fDrawElementsInstanced) {
+                RETURN_FALSE_INTERFACE
             }
-        }
+        }    
     }
 
     if (kGL_GrGLStandard == fStandard) {
@@ -600,15 +585,13 @@
             if (nullptr == fFunctions.fVertexAttribDivisor) {
                 RETURN_FALSE_INTERFACE
             }
-        }
+        }    
     } else if (kGLES_GrGLStandard == fStandard) {
-        if (!ALLOW_MISSING_FUNCTIONS_FOR_INCOMPLETE_COMMAND_BUFFER_ES3) {
-            if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_instanced_arrays")) {
-                if (nullptr == fFunctions.fVertexAttribDivisor) {
-                    RETURN_FALSE_INTERFACE
-                }
+        if (glVer >= GR_GL_VER(3,0) || fExtensions.has("GL_EXT_instanced_arrays")) {
+            if (nullptr == fFunctions.fVertexAttribDivisor) {
+                RETURN_FALSE_INTERFACE
             }
-        }
+        }    
     }
 
     if ((kGL_GrGLStandard == fStandard && glVer >= GR_GL_VER(4,3)) ||
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
index 946cd4a..cf9da93 100644
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
+++ b/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
@@ -33,7 +33,6 @@
 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
 #define EGL_SURFACE_TYPE 0x3033
 #define EGL_PBUFFER_BIT 0x0001
-#define EGL_WINDOW_BIT 0x0004
 #define EGL_RENDERABLE_TYPE 0x3040
 #define EGL_RED_SIZE 0x3024
 #define EGL_GREEN_SIZE 0x3023
@@ -53,11 +52,6 @@
 
 #endif
 
-#ifndef EGL_OPENGL_ES3_BIT
-// Part of EGL 1.5, typical headers are 1.4.
-#define EGL_OPENGL_ES3_BIT 0x0040
-#endif
-
 typedef EGLDisplay (*GetDisplayProc)(EGLNativeDisplayType display_id);
 typedef EGLBoolean (*InitializeProc)(EGLDisplay dpy, EGLint *major, EGLint *minor);
 typedef EGLBoolean (*TerminateProc)(EGLDisplay dpy);
@@ -143,15 +137,14 @@
     return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc);
 }
 
-SkCommandBufferGLContext::SkCommandBufferGLContext(ContextVersion minContextVersion)
+SkCommandBufferGLContext::SkCommandBufferGLContext()
     : fContext(EGL_NO_CONTEXT)
     , fDisplay(EGL_NO_DISPLAY)
     , fSurface(EGL_NO_SURFACE) {
 
     static const EGLint configAttribs[] = {
         EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
-        EGL_RENDERABLE_TYPE,  minContextVersion == kGLES3_ContextVersion ? EGL_OPENGL_ES3_BIT
-                                                                         : EGL_OPENGL_ES2_BIT,
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
         EGL_RED_SIZE, 8,
         EGL_GREEN_SIZE, 8,
         EGL_BLUE_SIZE, 8,
@@ -165,15 +158,13 @@
         EGL_NONE
     };
 
-    initializeGLContext(minContextVersion, nullptr, configAttribs, surfaceAttribs);
+    initializeGLContext(nullptr, configAttribs, surfaceAttribs);
 }
 
 SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount) {
     static const EGLint surfaceAttribs[] = { EGL_NONE };
 
     EGLint configAttribs[] = {
-        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
-        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
         EGL_RED_SIZE,       8,
         EGL_GREEN_SIZE,     8,
         EGL_BLUE_SIZE,      8,
@@ -188,11 +179,10 @@
         configAttribs[12] = EGL_NONE;
     }
 
-    initializeGLContext(kGLES2_ContextVersion, nativeWindow, configAttribs, surfaceAttribs);
+    initializeGLContext(nativeWindow, configAttribs, surfaceAttribs);
 }
 
-void SkCommandBufferGLContext::initializeGLContext(ContextVersion minContextVersion,
-                                                   void* nativeWindow, const int* configAttribs,
+void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs,
                                                    const int* surfaceAttribs) {
     LoadCommandBufferOnce();
     if (!gfFunctionsLoadedSuccessfully) {
@@ -201,14 +191,16 @@
     }
 
     // Make sure CHROMIUM_path_rendering is enabled for NVPR support.
-    sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering --enable-unsafe-es3-apis");
+    sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering");
     fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY);
     if (EGL_NO_DISPLAY == fDisplay) {
         SkDebugf("Command Buffer: Could not create EGL display.\n");
         return;
     }
 
-    if (!gfInitialize(fDisplay, nullptr, nullptr)) {
+    EGLint majorVersion;
+    EGLint minorVersion;
+    if (!gfInitialize(fDisplay, &majorVersion, &minorVersion)) {
         SkDebugf("Command Buffer: Could not initialize EGL display.\n");
         this->destroyGLContext();
         return;
@@ -216,7 +208,7 @@
 
     EGLint numConfigs;
     if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig*>(&fConfig), 1,
-                        &numConfigs) || numConfigs < 1) {
+                        &numConfigs) || numConfigs != 1) {
         SkDebugf("Command Buffer: Could not choose EGL config.\n");
         this->destroyGLContext();
         return;
@@ -239,7 +231,7 @@
     }
 
     static const EGLint contextAttribs[] = {
-        EGL_CONTEXT_CLIENT_VERSION, minContextVersion == kGLES3_ContextVersion ? 3 : 2,
+        EGL_CONTEXT_CLIENT_VERSION, 2,
         EGL_NONE
     };
     fContext = gfCreateContext(fDisplay, static_cast<EGLConfig>(fConfig), nullptr, contextAttribs);
@@ -279,28 +271,22 @@
     if (!gfFunctionsLoadedSuccessfully) {
         return;
     }
-    if (EGL_NO_DISPLAY == fDisplay) {
-        return;
-    }
+    if (fDisplay) {
+        gfMakeCurrent(fDisplay, 0, 0, 0);
 
-    if (EGL_NO_CONTEXT != fContext) {
-        gfDestroyContext(fDisplay, fContext);
-        fContext = EGL_NO_CONTEXT;
-    }
-    // Call MakeCurrent after destroying the context, so that the EGL implementation knows
-    // that the context is not used anymore after it is released from being current.
-    // This way command buffer does not need to abandon the context before destruction, and no
-    // client-side errors are printed.
-    gfMakeCurrent(fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        if (fContext) {
+            gfDestroyContext(fDisplay, fContext);
+            fContext = EGL_NO_CONTEXT;
+        }
 
-    if (EGL_NO_SURFACE != fSurface) {
-        gfDestroySurface(fDisplay, fSurface);
-        fSurface = EGL_NO_SURFACE;
+        if (fSurface) {
+            gfDestroySurface(fDisplay, fSurface);
+            fSurface = EGL_NO_SURFACE;
+        }
+
+        gfTerminate(fDisplay);
+        fDisplay = EGL_NO_DISPLAY;
     }
-    // The display is likely to be used again for another test, do not call gfTerminate.  Also,
-    // terminating could imply terminating the "host" EGL inside command buffer. This would
-    // terminate also EGL that this thread might use outside of command buffer.
-    fDisplay = EGL_NO_DISPLAY;
 }
 
 void SkCommandBufferGLContext::onPlatformMakeCurrent() const {