From c7b4d1de98037d4984b1af9fe9eb109d3e283a2c Mon Sep 17 00:00:00 2001 From: "sievers@chromium.org" Date: Wed, 5 Dec 2012 03:50:15 +0000 Subject: Add unit test to verify a texture can be reused with stream textures. Verify that a stream's gl texture bound and destroyed previously can be used to create a new stream texture. Review URL: https://chromiumcodereview.appspot.com/8676048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171151 0039d316-1c4b-4281-b951-d872f2087c98 --- .../service/gles2_cmd_decoder_unittest.cc | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'gpu') diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index cee68f4..de780a4 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -5868,6 +5868,55 @@ TEST_F(GLES2DecoderManualInitTest, StreamTextureCHROMIUMNullMgr) { GetGLError(); // ignore internal error } +TEST_F(GLES2DecoderManualInitTest, ReCreateStreamTextureCHROMIUM) { + const GLuint kObjectId = 123; + InitDecoder( + "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions + false, // has alpha + false, // has depth + false, // has stencil + false, // request alpha + false, // request depth + false, // request stencil + true); // bind generates resource + + StrictMock manager; + StrictMock texture; + decoder_->SetStreamTextureManager(&manager); + + EXPECT_CALL(manager, LookupStreamTexture(kServiceTextureId)) + .WillOnce(Return(&texture)) + .RetiresOnSaturation(); + EXPECT_CALL(texture, Update()) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(manager, DestroyStreamTexture(kServiceTextureId)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(manager, CreateStreamTexture(kServiceTextureId, + client_texture_id_)) + .WillOnce(Return(kObjectId)) + .RetiresOnSaturation(); + + TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); + info->SetStreamTexture(true); + + DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + + DestroyStreamTextureCHROMIUM cmd; + cmd.Init(client_texture_id_); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + EXPECT_FALSE(info->IsStreamTexture()); + + CreateStreamTextureCHROMIUM cmd2; + cmd2.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); + EXPECT_EQ(GL_NO_ERROR, GetGLError()); + EXPECT_TRUE(info->IsStreamTexture()); +} + TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { InitDecoder( "GL_ARB_texture_rectangle", // extensions -- cgit v1.1