Fix zero texture application.

Patch https://chromium-review.googlesource.com/#/c/227711/ would
allow NULL Textures sometimes from State::getSamplerTexture. Fix
this by always setting the zero "Default" textures instead of NULL
in the State.

This was breaking the ES2-CTS test 'framebuffer_objects' on Windows.

BUG=angle:826

Change-Id: Ie08a89cff0555f21c769759e0c0ed73456a2f91c
Reviewed-on: https://chromium-review.googlesource.com/228275
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 49ba73e..bc3876c 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -66,28 +66,24 @@
     // In order that access to these initial textures not be lost, they are treated as texture
     // objects all of whose names are 0.
 
-    ASSERT(mState.getActiveSampler() == 0);
-
     Texture2D *zeroTexture2D = new Texture2D(mRenderer->createTexture(GL_TEXTURE_2D), 0);
     mZeroTextures[GL_TEXTURE_2D].set(zeroTexture2D);
-    mState.setSamplerTexture(GL_TEXTURE_2D, zeroTexture2D);
 
     TextureCubeMap *zeroTextureCube = new TextureCubeMap(mRenderer->createTexture(GL_TEXTURE_CUBE_MAP), 0);
     mZeroTextures[GL_TEXTURE_CUBE_MAP].set(zeroTextureCube);
-    mState.setSamplerTexture(GL_TEXTURE_CUBE_MAP, zeroTextureCube);
 
     if (mClientVersion >= 3)
     {
         // TODO: These could also be enabled via extension
         Texture3D *zeroTexture3D = new Texture3D(mRenderer->createTexture(GL_TEXTURE_3D), 0);
         mZeroTextures[GL_TEXTURE_3D].set(zeroTexture3D);
-        mState.setSamplerTexture(GL_TEXTURE_3D, zeroTexture3D);
 
         Texture2DArray *zeroTexture2DArray = new Texture2DArray(mRenderer->createTexture(GL_TEXTURE_2D_ARRAY), 0);
         mZeroTextures[GL_TEXTURE_2D_ARRAY].set(zeroTexture2DArray);
-        mState.setSamplerTexture(GL_TEXTURE_2D_ARRAY, zeroTexture2DArray);
     }
 
+    mState.initializeZeroTextures(mZeroTextures);
+
     bindVertexArray(0);
     bindArrayBuffer(0);
     bindElementArrayBuffer(0);
@@ -1413,7 +1409,8 @@
         GLint textureUnit = programBinary->getSamplerMapping(type, i, getCaps());
         if (textureUnit != -1)
         {
-            Texture* texture = getSamplerTexture(textureUnit, textureType);
+            Texture *texture = getSamplerTexture(textureUnit, textureType);
+            ASSERT(texture);
             if (texture->getSamplerState().swizzleRequired())
             {
                 Error error = mRenderer->generateSwizzle(texture);
@@ -1459,6 +1456,7 @@
         if (textureUnit != -1)
         {
             Texture *texture = getSamplerTexture(textureUnit, textureType);
+            ASSERT(texture);
             SamplerState sampler = texture->getSamplerState();
 
             Sampler *samplerObject = mState.getSampler(textureUnit);
@@ -1999,7 +1997,7 @@
     // allocation map management either here or in the resource manager at detach time.
     // Zero textures are held by the Context, and we don't attempt to request them from
     // the State.
-    mState.detachTexture(texture);
+    mState.detachTexture(mZeroTextures, texture);
 }
 
 void Context::detachBuffer(GLuint buffer)