GLES: Expose OES_mapbuffer in GLES2 on GLES3.

This extension is mandatory for EXT_map_buffer_range support. We can
emulate it using GLES 3.0 core map functionality.

BUG=angleproject:1751

Change-Id: Idba09ce7276603d5556039f4a49aa0b87cae22aa
Reviewed-on: https://chromium-review.googlesource.com/431826
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/gl/BufferGL.cpp b/src/libANGLE/renderer/gl/BufferGL.cpp
index 9dfd076..2de2b3e 100644
--- a/src/libANGLE/renderer/gl/BufferGL.cpp
+++ b/src/libANGLE/renderer/gl/BufferGL.cpp
@@ -115,11 +115,18 @@
     {
         *mapPtr = mShadowCopy.data();
     }
-    else
+    else if (mFunctions->mapBuffer)
     {
         mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID);
         *mapPtr = mFunctions->mapBuffer(DestBufferOperationTarget, access);
     }
+    else
+    {
+        ASSERT(mFunctions->mapBufferRange && access == GL_WRITE_ONLY_OES);
+        mStateManager->bindBuffer(DestBufferOperationTarget, mBufferID);
+        *mapPtr =
+            mFunctions->mapBufferRange(DestBufferOperationTarget, 0, mBufferSize, GL_MAP_WRITE_BIT);
+    }
 
     mIsMapped = true;
     mMapOffset = 0;
diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 26f44da..217ac77 100644
--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -788,6 +788,7 @@
     extensions->readFormatBGRA = functions->isAtLeastGL(gl::Version(1, 2)) || functions->hasGLExtension("GL_EXT_bgra") ||
                                  functions->hasGLESExtension("GL_EXT_read_format_bgra");
     extensions->mapBuffer = functions->isAtLeastGL(gl::Version(1, 5)) ||
+                            functions->isAtLeastGLES(gl::Version(3, 0)) ||
                             functions->hasGLESExtension("GL_OES_mapbuffer");
     extensions->mapBufferRange = functions->isAtLeastGL(gl::Version(3, 0)) || functions->hasGLExtension("GL_ARB_map_buffer_range") ||
                                  functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_EXT_map_buffer_range");
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 3d9dba3..3607de6 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -1230,7 +1230,7 @@
             if (!extensions.mapBuffer)
             {
                 context->handleError(
-                    Error(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0 or GL_OES_map_buffer."));
+                    Error(GL_INVALID_ENUM, "pname requires OpenGL ES 3.0 or GL_OES_mapbuffer."));
                 return false;
             }
             break;
@@ -1242,7 +1242,7 @@
             {
                 context->handleError(Error(
                     GL_INVALID_ENUM,
-                    "pname requires OpenGL ES 3.0, GL_OES_map_buffer or GL_EXT_map_buffer_range."));
+                    "pname requires OpenGL ES 3.0, GL_OES_mapbuffer or GL_EXT_map_buffer_range."));
                 return false;
             }
             break;
@@ -4366,7 +4366,7 @@
     {
         context->handleError(
             Error(GL_INVALID_OPERATION,
-                  "Context does not support OpenGL ES 3.0 or GL_OES_map_buffer is not enabled."));
+                  "Context does not support OpenGL ES 3.0 or GL_OES_mapbuffer is not enabled."));
         return false;
     }