Refactor More Validation Error Messages

Replace many error string literals with variables existing in
ErrorStrings.h

BUG=:angleproject:1644

Change-Id: If5665a6787a1fa8d789811d774711c3705dfb0ab
Reviewed-on: https://chromium-review.googlesource.com/598588
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index e7c95ff..ec41db3 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -94,13 +94,13 @@
     // The type and format are valid if any supported internal format has that type and format
     if (!ValidES3Format(format))
     {
-        context->handleError(InvalidEnum() << "Invalid format.");
+        ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFormat);
         return false;
     }
 
     if (!ValidES3Type(type))
     {
-        context->handleError(InvalidEnum() << "Invalid type.");
+        ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidType);
         return false;
     }
 
@@ -110,7 +110,7 @@
     // the validation codepaths for glTexImage2D/3D, we record a GL_INVALID_VALUE error.
     if (!ValidES3InternalFormat(internalFormat))
     {
-        context->handleError(InvalidValue() << "Invalid internalFormat.");
+        ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidInternalFormat);
         return false;
     }
 
@@ -1125,7 +1125,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Operation only supported on ES 3.0 and above");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -1141,7 +1141,7 @@
             defaultFramebuffer = context->getGLState().getReadFramebuffer()->id() == 0;
             break;
         default:
-            context->handleError(InvalidEnum() << "Invalid framebuffer target");
+            ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget);
             return false;
     }
 
@@ -1176,7 +1176,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -1566,7 +1566,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -1777,7 +1777,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2051,7 +2051,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
     if (count < 0)
@@ -2066,7 +2066,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
     switch (primitiveMode)
@@ -2152,7 +2152,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2166,7 +2166,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2297,7 +2297,7 @@
 {
     if (context->getClientVersion() < ES_3_0)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.0");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
     return ValidateIndexedStateQuery(context, target, index, nullptr);
@@ -2312,7 +2312,7 @@
 {
     if (context->getClientVersion() < ES_3_0)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.0");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2338,7 +2338,7 @@
 {
     if (context->getClientVersion() < ES_3_0)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.0");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
     return ValidateIndexedStateQuery(context, target, index, nullptr);
@@ -2353,7 +2353,7 @@
 {
     if (context->getClientVersion() < ES_3_0)
     {
-        context->handleError(InvalidOperation() << "Context does not support GLES3.0");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2384,7 +2384,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "CopyBufferSubData requires ES 3 or greater");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2466,8 +2466,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation()
-                             << "glGetStringi requires OpenGL ES 3.0 or higher.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2485,7 +2484,7 @@
         case GL_REQUESTABLE_EXTENSIONS_ANGLE:
             if (!context->getExtensions().requestExtension)
             {
-                context->handleError(InvalidEnum() << "Invalid name.");
+                ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidName);
                 return false;
             }
             if (index >= context->getRequestableExtensionStringCount())
@@ -2498,7 +2497,7 @@
             break;
 
         default:
-            context->handleError(InvalidEnum() << "Invalid name.");
+            ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidName);
             return false;
     }
 
@@ -2556,8 +2555,7 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation()
-                             << "VertexAttribIPointer requires OpenGL ES 3.0 or higher.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
@@ -2568,7 +2566,7 @@
 
     if (stride < 0)
     {
-        context->handleError(InvalidValue() << "stride cannot be negative.");
+        ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeStride);
         return false;
     }
 
@@ -2626,13 +2624,13 @@
 {
     if (context->getClientMajorVersion() < 3)
     {
-        context->handleError(InvalidOperation() << "GetSynciv requires OpenGL ES 3.0 or higher.");
+        ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
         return false;
     }
 
     if (bufSize < 0)
     {
-        context->handleError(InvalidValue() << "bufSize cannot be negative.");
+        ANGLE_VALIDATION_ERR(context, InvalidValue(), NegativeBufferSize);
         return false;
     }
 
@@ -2652,7 +2650,7 @@
             break;
 
         default:
-            context->handleError(InvalidEnum() << "Invalid pname.");
+            ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidPname);
             return false;
     }