Simplify formatutils.h by exposing the info structures.

Removed all the separate query functions and simply expose the internal
info structures.  This reduces the number of std::map/std::set operations
that were hidden behind the API.

Moved the validation tables for ES3 format combinations and effective
internal formats into validationES3.cpp so that formatutils.h only has
generic GL format queries.

BUG=angle:658

Change-Id: Ieb60d42b8eafcdb4f21dcbec130b39478ce5f7c5
Reviewed-on: https://chromium-review.googlesource.com/206835
Reviewed-by: Nicolas Capens <capn@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 5561c7b..73f4572 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -716,7 +716,8 @@
             return;
         }
 
-        if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height))
+        const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
+        if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
         {
             return gl::error(GL_INVALID_VALUE);
         }
@@ -774,7 +775,8 @@
             return;
         }
 
-        if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height))
+        const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
+        if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
         {
             return gl::error(GL_INVALID_VALUE);
         }
@@ -1602,6 +1604,7 @@
 
         GLenum internalFormat = texture->getBaseLevelInternalFormat();
         const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
+        const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
 
         // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
         // unsized formats or that are color renderable and filterable.  Since we do not track if
@@ -1615,14 +1618,14 @@
                       internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
                       internalFormat == GL_ALPHA8_EXT;
 
-        if (gl::GetDepthBits(internalFormat) > 0 || gl::GetStencilBits(internalFormat) > 0 || !formatCaps.filterable ||
-            (!formatCaps.renderable && !isLUMA) || gl::IsFormatCompressed(internalFormat))
+        if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
+            (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
         {
             return gl::error(GL_INVALID_OPERATION);
         }
 
         // GL_EXT_sRGB does not support mipmap generation on sRGB textures
-        if (context->getClientVersion() == 2 && gl::GetColorEncoding(internalFormat) == GL_SRGB)
+        if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
         {
             return gl::error(GL_INVALID_OPERATION);
         }
@@ -4974,7 +4977,8 @@
             return gl::error(GL_INVALID_OPERATION);
         }
 
-        if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height))
+        const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
+        if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
         {
             return gl::error(GL_INVALID_VALUE);
         }
@@ -5024,7 +5028,8 @@
             return gl::error(GL_INVALID_OPERATION);
         }
 
-        if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height))
+        const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
+        if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
         {
             return gl::error(GL_INVALID_VALUE);
         }