Use immutable level count in gl::Texture.

Instead of storing a binary flag indicating if we've created
immutable storage, store a level count. This indicates if or if
not we've created immutable storage, as well as avoiding the
call to the native storage to return the level count.

BUG=angle:781

Change-Id: I08a6bd086d00ddf3255262a7711628be5212b4b7
Reviewed-on: https://chromium-review.googlesource.com/222921
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 624f6ee..3a70d57 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -51,7 +51,7 @@
     : RefCountObject(id),
       mTexture(impl),
       mUsage(GL_NONE),
-      mImmutable(false),
+      mImmutableLevelCount(0),
       mTarget(target)
 {
 }
@@ -162,12 +162,12 @@
 
 bool Texture::isImmutable() const
 {
-    return mImmutable;
+    return (mImmutableLevelCount > 0);
 }
 
 int Texture::immutableLevelCount()
 {
-    return (mImmutable ? getNativeTexture()->getLevelCount() : 0);
+    return mImmutableLevelCount;
 }
 
 int Texture::mipLevels() const
@@ -290,7 +290,7 @@
         return error;
     }
 
-    mImmutable = true;
+    mImmutableLevelCount = levels;
 
     return Error(GL_NO_ERROR);
 }
@@ -551,7 +551,7 @@
         return error;
     }
 
-    mImmutable = true;
+    mImmutableLevelCount = levels;
 
     return Error(GL_NO_ERROR);
 }
@@ -760,7 +760,7 @@
         return error;
     }
 
-    mImmutable = true;
+    mImmutableLevelCount = levels;
 
     return Error(GL_NO_ERROR);
 }
@@ -927,7 +927,7 @@
         return error;
     }
 
-    mImmutable = true;
+    mImmutableLevelCount = levels;
 
     return Error(GL_NO_ERROR);
 }