Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
| index 05b44afeecfd5cafb1e9c844f7cd0c26a4a74dae..9c53a0cc4c04c2d4e0a374b4e5f07d9d1832f7e8 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc |
| @@ -2207,20 +2207,138 @@ TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) { |
| TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { |
| scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
| GetImageManager()->AddImage(image.get(), 1); |
| - DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); |
| + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| - bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); |
| + EXPECT_CALL(*gl_, GetError()) |
| + .WillOnce(Return(GL_NO_ERROR)) |
| + .RetiresOnSaturation(); |
| + EXPECT_CALL(*gl_, GetError()) |
| + .WillOnce(Return(GL_NO_ERROR)) |
| + .RetiresOnSaturation(); |
| + bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| - EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| + EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| + |
| + TextureRef* texture_ref = |
| + group().texture_manager()->GetTexture(client_texture_id_); |
| + ASSERT_TRUE(texture_ref != NULL); |
| + Texture* texture = texture_ref->texture(); |
| + EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
| DoTexImage2D( |
| GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| + EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| +} |
| + |
| +TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) { |
| + ASSERT_FALSE( |
|
no sievers
2015/02/25 21:52:48
nit: put comment "this specifically tests that we
|
| + feature_info()->workarounds().texsubimage2d_faster_than_teximage2d); |
| + |
| + scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
| + GetImageManager()->AddImage(image.get(), 1); |
| + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| + |
| + GLenum target = GL_TEXTURE_2D; |
| + GLint level = 0; |
| + GLint xoffset = 0; |
| + GLint yoffset = 0; |
| + GLsizei width = 1; |
| + GLsizei height = 1; |
| + GLint border = 0; |
| + GLenum format = GL_RGBA; |
| + GLenum type = GL_UNSIGNED_BYTE; |
| + uint32_t pixels_shm_id = kSharedMemoryId; |
| + uint32_t pixels_shm_offset = 0; |
|
no sievers
2015/02/25 21:52:49
kSharedMemoryOffset
|
| + GLboolean internal = 0; |
| + |
| + // Define texture first. |
| + DoTexImage2D(target, level, format, width, height, border, format, type, |
| + pixels_shm_id, pixels_shm_offset); |
| + |
| + // Bind texture to GLImage. |
| + BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
|
no sievers
2015/02/25 21:52:48
nit: line 2260-2276 seems to be duplicated a few t
|
| + bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| + EXPECT_CALL(*gl_, GetError()) |
| + .WillOnce(Return(GL_NO_ERROR)) |
| + .RetiresOnSaturation(); |
| + EXPECT_CALL(*gl_, GetError()) |
| + .WillOnce(Return(GL_NO_ERROR)) |
| + .RetiresOnSaturation(); |
| + EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| + EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| + |
| + // Check binding. |
| TextureRef* texture_ref = |
| group().texture_manager()->GetTexture(client_texture_id_); |
| ASSERT_TRUE(texture_ref != NULL); |
| Texture* texture = texture_ref->texture(); |
| - EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); |
| + EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
| + |
| + // TexSubImage2D should not unbind GLImage. |
| + EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, |
| + height, format, type, _)) |
| + .Times(1) |
| + .RetiresOnSaturation(); |
| + cmds::TexSubImage2D tex_sub_image_2d_cmd; |
| + tex_sub_image_2d_cmd.Init(target, level, xoffset, yoffset, width, height, |
| + format, type, pixels_shm_id, pixels_shm_offset, |
| + internal); |
| + EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd)); |
| + EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
| +} |
| + |
| +TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) { |
| + scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); |
| + GetImageManager()->AddImage(image.get(), 1); |
| + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| + |
| + GLenum target = GL_TEXTURE_2D; |
| + GLint level = 0; |
| + GLint xoffset = 0; |
| + GLint yoffset = 0; |
| + GLsizei width = 1; |
| + GLsizei height = 1; |
| + GLint border = 0; |
| + GLenum format = GL_RGBA; |
| + GLenum type = GL_UNSIGNED_BYTE; |
| + uint32_t pixels_shm_id = kSharedMemoryId; |
| + uint32_t pixels_shm_offset = 0; |
|
no sievers
2015/02/25 21:52:48
kSharedMemoryOffset
|
| + |
| + // Define texture first. |
| + DoTexImage2D(target, level, format, width, height, border, format, type, |
| + pixels_shm_id, pixels_shm_offset); |
| + |
| + // Bind texture to GLImage. |
| + BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; |
| + bind_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); |
| + EXPECT_CALL(*gl_, GetError()) |
| + .WillOnce(Return(GL_NO_ERROR)) |
| + .RetiresOnSaturation(); |
| + EXPECT_CALL(*gl_, GetError()) |
| + .WillOnce(Return(GL_NO_ERROR)) |
| + .RetiresOnSaturation(); |
| + EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); |
| + EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| + |
| + // Check binding. |
| + TextureRef* texture_ref = |
| + group().texture_manager()->GetTexture(client_texture_id_); |
| + ASSERT_TRUE(texture_ref != NULL); |
| + Texture* texture = texture_ref->texture(); |
| + EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
| + |
| + // ClearLevel use glTexSubImage2D to avoid unbinding GLImage. |
|
no sievers
2015/02/25 21:52:48
nit: 'should use'
|
| + EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
| + .Times(2) |
| + .RetiresOnSaturation(); |
| + EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, |
| + height, format, type, _)) |
| + .Times(1) |
| + .RetiresOnSaturation(); |
| + GetDecoder()->ClearLevel(texture, target, level, format, format, type, width, |
| + height, false); |
| + EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); |
| } |
| TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { |