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

This completes the refactor by using the packed enums in the gl:: layer
and in the backends.

The packed enum code generation is modified to support explicitly
assigning values to the packed enums so that the TextureTarget cube map
faces are in the correct order and easy to iterate over.

BUG=angleproject:2169

Change-Id: I5903235e684ccf382e92a8a1e10c5c85b4b16a04
Reviewed-on: https://chromium-review.googlesource.com/939994
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index bd4d479..b35dbdf 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -2453,7 +2453,7 @@
         if (readColorAttachment && drawColorAttachment)
         {
             if (!(readColorAttachment->type() == GL_TEXTURE &&
-                  readColorAttachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
+                  readColorAttachment->getTextureImageIndex().type == TextureType::_2D) &&
                 readColorAttachment->type() != GL_RENDERBUFFER &&
                 readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT)
             {
@@ -2469,7 +2469,7 @@
                 if (attachment)
                 {
                     if (!(attachment->type() == GL_TEXTURE &&
-                          attachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
+                          attachment->getTextureImageIndex().type == TextureType::_2D) &&
                         attachment->type() != GL_RENDERBUFFER &&
                         attachment->type() != GL_FRAMEBUFFER_DEFAULT)
                     {
@@ -4098,19 +4098,20 @@
         return false;
     }
 
-    if (source->getTarget() != GL_TEXTURE_2D)
+    if (source->getType() != TextureType::_2D)
     {
         context->handleError(InvalidValue() << "Source texture must be of type GL_TEXTURE_2D.");
         return false;
     }
 
-    if (source->getWidth(GL_TEXTURE_2D, 0) == 0 || source->getHeight(GL_TEXTURE_2D, 0) == 0)
+    if (source->getWidth(TextureTarget::_2D, 0) == 0 ||
+        source->getHeight(TextureTarget::_2D, 0) == 0)
     {
         context->handleError(InvalidValue() << "Source texture must level 0 defined.");
         return false;
     }
 
-    const gl::Format &sourceFormat = source->getFormat(GL_TEXTURE_2D, 0);
+    const gl::Format &sourceFormat = source->getFormat(TextureTarget::_2D, 0);
     if (!sourceFormat.info->compressed)
     {
         context->handleError(InvalidOperation()
@@ -4126,7 +4127,7 @@
         return false;
     }
 
-    if (dest->getTarget() != GL_TEXTURE_2D)
+    if (dest->getType() != TextureType::_2D)
     {
         context->handleError(InvalidValue()
                              << "Destination texture must be of type GL_TEXTURE_2D.");
@@ -6007,7 +6008,7 @@
                     context->handleError(InvalidValue());
                     return false;
                 }
-                if (tex->getTarget() != GL_TEXTURE_2D)
+                if (tex->getType() != TextureType::_2D)
                 {
                     ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidTextureTarget);
                     return false;
@@ -6022,7 +6023,7 @@
                     context->handleError(InvalidValue());
                     return false;
                 }
-                if (tex->getTarget() != GL_TEXTURE_RECTANGLE_ANGLE)
+                if (tex->getType() != TextureType::Rectangle)
                 {
                     context->handleError(InvalidOperation()
                                          << "Textarget must match the texture target type.");
@@ -6043,7 +6044,7 @@
                     context->handleError(InvalidValue());
                     return false;
                 }
-                if (tex->getTarget() != GL_TEXTURE_CUBE_MAP)
+                if (tex->getType() != TextureType::CubeMap)
                 {
                     context->handleError(InvalidOperation()
                                          << "Textarget must match the texture target type.");
@@ -6065,7 +6066,7 @@
                     ANGLE_VALIDATION_ERR(context, InvalidValue(), LevelNotZero);
                     return false;
                 }
-                if (tex->getTarget() != GL_TEXTURE_2D_MULTISAMPLE)
+                if (tex->getType() != TextureType::_2DMultisample)
                 {
                     context->handleError(InvalidOperation()
                                          << "Textarget must match the texture target type.");