diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 23:54:04 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 23:54:04 +0000 |
commit | 7687479c74f5515a556b03f0c2982b71e8b03b63 (patch) | |
tree | a8cc85cc423563da9940e5f89232dfe08a095abf /gpu | |
parent | 197c07743ee0b4d614e1dfe4a0dc5ccc1faf9256 (diff) | |
download | chromium_src-7687479c74f5515a556b03f0c2982b71e8b03b63.zip chromium_src-7687479c74f5515a556b03f0c2982b71e8b03b63.tar.gz chromium_src-7687479c74f5515a556b03f0c2982b71e8b03b63.tar.bz2 |
Make genereteMipmap clear uncleared level 0
TEST=unit tests
BUG=128075
Review URL: https://chromiumcodereview.appspot.com/10386122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 5 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc | 30 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc | 2 |
3 files changed, 35 insertions, 2 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 951829d..33d35d7 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -3481,6 +3481,11 @@ void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) { return; } + if (!texture_manager()->ClearTextureLevel(this, info, target, 0)) { + SetGLError(GL_OUT_OF_MEMORY, "glGenerateMipmaps: dimensions too big"); + return; + } + CopyRealGLErrorsToWrapper(); // Workaround for Mac driver bug. In the large scheme of things setting // glTexParamter twice for glGenerateMipmap is probably not a lage performance diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index c489347..d939e27 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -1810,7 +1810,7 @@ TEST_F(GLES2DecoderTest, GenerateMipmapHandlesOutOfMemory) { EXPECT_FALSE(info->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); DoTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, - 0, 0); + kSharedMemoryId, kSharedMemoryOffset); EXPECT_CALL(*gl_, TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) .Times(1) @@ -1832,6 +1832,34 @@ TEST_F(GLES2DecoderTest, GenerateMipmapHandlesOutOfMemory) { EXPECT_FALSE(info->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); } +TEST_F(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { + EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) + .Times(0); + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); + DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, + 0, 0); + SetupClearTextureExpections( + kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, + 0, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); + EXPECT_CALL(*gl_, TexParameteri( + GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); + EXPECT_CALL(*gl_, TexParameteri( + GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GetError()) + .WillOnce(Return(GL_NO_ERROR)) + .WillOnce(Return(GL_NO_ERROR)) + .RetiresOnSaturation(); + GenerateMipmap cmd; + cmd.Init(GL_TEXTURE_2D); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); +} + TEST_F(GLES2DecoderWithShaderTest, Uniform1iValidArgs) { EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2)); Uniform1i cmd; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc index 1155bc7..0484183 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc @@ -38,7 +38,7 @@ void GLES2DecoderTestBase::SpecializedSetup<GenerateMipmap, 0>( DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); DoTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, - 0, 0); + kSharedMemoryId, kSharedMemoryOffset); if (valid) { EXPECT_CALL(*gl_, TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST)) |