Use packed enums for the texture types and targets, part 1

In OpenGL there are two enum "sets" used by the API that are very
similar: texture types (or bind point) and texture targets. They only
differ in that texture types have GL_TEXTURE_CUBEMAP and target have
GL_TEXTURE_CUBEMAP_[POSITIVE|NEGATIVE]_[X|Y|Z].

This is a problem because in ANGLE we use GLenum to pass around both
types of data, making it difficult to know which of type and target a
variable is.

In addition these enums are placed somewhat randomly in the space of
OpenGL enums, making it slow to have a mapping from texture types to
some data. Such a mapping is in hot-code with gl::State::mTextures.

This commit stack makes the texture types and target enums be
translated to internal packed enums right at the OpenGL entry point
and used throughout ANGLE to have type safety and performance gains.

This is the first of two commit which does the refactor for all of the
validation and stops inside gl::Context. This was the best place to
split patches without having many conversions from packed enums to GL
enums.

BUG=angleproject:2169

Change-Id: Ib43da7e71c253bd9fe210fb0ec0de61bc286e6d3
Reviewed-on: https://chromium-review.googlesource.com/758835
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES31.cpp b/src/libANGLE/validationES31.cpp
index a7e0083..d67c3b3 100644
--- a/src/libANGLE/validationES31.cpp
+++ b/src/libANGLE/validationES31.cpp
@@ -854,7 +854,7 @@
 }
 
 bool ValidateGetTexLevelParameterBase(Context *context,
-                                      GLenum target,
+                                      TextureTarget target,
                                       GLint level,
                                       GLenum pname,
                                       GLsizei *length)
@@ -870,20 +870,21 @@
         *length = 0;
     }
 
-    if (!ValidTexLevelDestinationTarget(context, target))
+    TextureType type = TextureTargetToType(target);
+
+    if (!ValidTexLevelDestinationTarget(context, type))
     {
         ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureTarget);
         return false;
     }
 
-    if (context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target) ==
-        nullptr)
+    if (context->getTargetTexture(type) == nullptr)
     {
         context->handleError(InvalidEnum() << "No texture bound.");
         return false;
     }
 
-    if (!ValidMipLevel(context, target, level))
+    if (!ValidMipLevel(context, type, level))
     {
         context->handleError(InvalidValue());
         return false;
@@ -928,7 +929,7 @@
 }
 
 bool ValidateGetTexLevelParameterfv(Context *context,
-                                    GLenum target,
+                                    TextureTarget target,
                                     GLint level,
                                     GLenum pname,
                                     GLfloat *params)
@@ -937,7 +938,7 @@
 }
 
 bool ValidateGetTexLevelParameteriv(Context *context,
-                                    GLenum target,
+                                    TextureTarget target,
                                     GLint level,
                                     GLenum pname,
                                     GLint *params)
@@ -946,7 +947,7 @@
 }
 
 bool ValidateTexStorage2DMultisample(Context *context,
-                                     GLenum target,
+                                     TextureType target,
                                      GLsizei samples,
                                      GLint internalFormat,
                                      GLsizei width,
@@ -959,7 +960,7 @@
         return false;
     }
 
-    if (target != GL_TEXTURE_2D_MULTISAMPLE)
+    if (target != TextureType::_2DMultisample)
     {
         context->handleError(InvalidEnum() << "Target must be TEXTURE_2D_MULTISAMPLE.");
         return false;