Make glGenerateMipmap handle out of memory

TEST=unit tests
BUG=127590


Review URL: https://chromiumcodereview.appspot.com/10377116

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136730 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 81719d5..916d792 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -3470,11 +3470,13 @@
 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
   TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
   if (!info ||
-      !texture_manager()->MarkMipmapsGenerated(info)) {
+      !texture_manager()->CanGenerateMipmaps(info)) {
     SetGLError(GL_INVALID_OPERATION,
                "glGenerateMipmaps: Can not generate mips");
     return;
   }
+
+  CopyRealGLErrorsToWrapper();
   // Workaround for Mac driver bug. In the large scheme of things setting
   // glTexParamter twice for glGenerateMipmap is probably not a lage performance
   // hit so there's probably no need to make this conditional. The bug appears
@@ -3488,6 +3490,10 @@
   if (!disable_workarounds_) {
     glTexParameteri(target, GL_TEXTURE_MIN_FILTER, info->min_filter());
   }
+  GLenum error = PeekGLError();
+  if (error == GL_NO_ERROR) {
+    texture_manager()->MarkMipmapsGenerated(info);
+  }
 }
 
 bool GLES2DecoderImpl::GetHelper(