Fix regression with r247334

GetLevelImage() does not handle GL_TEXTURE_CUBE_MAP.

[email protected]

Review URL: https://codereview.chromium.org/132333014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247382 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 729ab26d..d836515 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -5956,15 +5956,17 @@
           continue;
         }
 
-        Texture* texture = texture_ref->texture();
-        gfx::GLImage* image = texture->GetLevelImage(textarget, 0);
-        if (image && !texture->IsAttachedToFramebuffer()) {
-          ScopedGLErrorSuppressor suppressor(
-              "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState());
-          textures_set = true;
-          glActiveTexture(GL_TEXTURE0 + texture_unit_index);
-          image->WillUseTexImage();
-          continue;
+        if (textarget != GL_TEXTURE_CUBE_MAP) {
+          Texture* texture = texture_ref->texture();
+          gfx::GLImage* image = texture->GetLevelImage(textarget, 0);
+          if (image && !texture->IsAttachedToFramebuffer()) {
+            ScopedGLErrorSuppressor suppressor(
+                "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState());
+            textures_set = true;
+            glActiveTexture(GL_TEXTURE0 + texture_unit_index);
+            image->WillUseTexImage();
+            continue;
+          }
         }
       }
       // else: should this be an error?
@@ -5998,15 +6000,17 @@
           continue;
         }
 
-        Texture* texture = texture_ref->texture();
-        gfx::GLImage* image =
-            texture->GetLevelImage(texture_unit.bind_target, 0);
-        if (image && !texture->IsAttachedToFramebuffer()) {
-          ScopedGLErrorSuppressor suppressor(
-              "GLES2DecoderImpl::RestoreStateForTextures", GetErrorState());
-          glActiveTexture(GL_TEXTURE0 + texture_unit_index);
-          image->DidUseTexImage();
-          continue;
+        if (texture_unit.bind_target != GL_TEXTURE_CUBE_MAP) {
+          Texture* texture = texture_ref->texture();
+          gfx::GLImage* image =
+              texture->GetLevelImage(texture_unit.bind_target, 0);
+          if (image && !texture->IsAttachedToFramebuffer()) {
+            ScopedGLErrorSuppressor suppressor(
+                "GLES2DecoderImpl::RestoreStateForTextures", GetErrorState());
+            glActiveTexture(GL_TEXTURE0 + texture_unit_index);
+            image->DidUseTexImage();
+            continue;
+          }
         }
       }
     }