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/renderer/renderer_utils.cpp b/src/libANGLE/renderer/renderer_utils.cpp
index 4737af9..2d74f66 100644
--- a/src/libANGLE/renderer/renderer_utils.cpp
+++ b/src/libANGLE/renderer/renderer_utils.cpp
@@ -477,22 +477,23 @@
     // Clear incomplete textures.
     for (auto &incompleteTexture : mIncompleteTextures)
     {
-        ANGLE_SWALLOW_ERR(incompleteTexture.second->onDestroy(context));
-        incompleteTexture.second.set(context, nullptr);
+        if (incompleteTexture.get() != nullptr)
+        {
+            ANGLE_SWALLOW_ERR(incompleteTexture->onDestroy(context));
+            incompleteTexture.set(context, nullptr);
+        }
     }
-    mIncompleteTextures.clear();
 }
 
 gl::Error IncompleteTextureSet::getIncompleteTexture(
     const gl::Context *context,
-    GLenum type,
+    gl::TextureType type,
     MultisampleTextureInitializer *multisampleInitializer,
     gl::Texture **textureOut)
 {
-    auto iter = mIncompleteTextures.find(type);
-    if (iter != mIncompleteTextures.end())
+    *textureOut = mIncompleteTextures[type].get();
+    if (*textureOut != nullptr)
     {
-        *textureOut = iter->second.get();
         return gl::NoError();
     }
 
@@ -505,12 +506,12 @@
     const gl::Box area(0, 0, 0, 1, 1, 1);
 
     // If a texture is external use a 2D texture for the incomplete texture
-    GLenum createType = (type == GL_TEXTURE_EXTERNAL_OES) ? GL_TEXTURE_2D : type;
+    gl::TextureType createType = (type == gl::TextureType::External) ? gl::TextureType::_2D : type;
 
     gl::Texture *tex = new gl::Texture(implFactory, std::numeric_limits<GLuint>::max(), createType);
     angle::UniqueObjectPointer<gl::Texture, gl::Context> t(tex, context);
 
-    if (createType == GL_TEXTURE_2D_MULTISAMPLE)
+    if (createType == gl::TextureType::_2DMultisample)
     {
         ANGLE_TRY(t->setStorageMultisample(context, createType, 1, GL_RGBA8, colorSize, true));
     }
@@ -519,24 +520,23 @@
         ANGLE_TRY(t->setStorage(context, createType, 1, GL_RGBA8, colorSize));
     }
 
-    if (type == GL_TEXTURE_CUBE_MAP)
+    if (type == gl::TextureType::CubeMap)
     {
-        for (GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
-             face++)
+        for (gl::TextureTarget face : gl::AllCubeFaceTextureTargets())
         {
             ANGLE_TRY(
                 t->setSubImage(context, unpack, face, 0, area, GL_RGBA, GL_UNSIGNED_BYTE, color));
         }
     }
-    else if (type == GL_TEXTURE_2D_MULTISAMPLE)
+    else if (type == gl::TextureType::_2DMultisample)
     {
         // Call a specialized clear function to init a multisample texture.
         ANGLE_TRY(multisampleInitializer->initializeMultisampleTextureToBlack(context, t.get()));
     }
     else
     {
-        ANGLE_TRY(
-            t->setSubImage(context, unpack, createType, 0, area, GL_RGBA, GL_UNSIGNED_BYTE, color));
+        ANGLE_TRY(t->setSubImage(context, unpack, gl::NonCubeTextureTypeToTarget(createType), 0,
+                                 area, GL_RGBA, GL_UNSIGNED_BYTE, color));
     }
 
     t->syncState();