Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc

Issue 1058833004: Make CreateAndConsumeTexture always associate client_id with a service_id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 994608cf5a894b14cb44b952d4db6820e5a6afd2..259072fbaf9e1254f3eb8df35dbb21ea754a9560 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
@@ -2039,6 +2039,95 @@ TEST_P(GLES2DecoderTest, ProduceTextureCHROMIUMInvalidTarget) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
+TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidMailbox) {
+ // Attempt to consume the mailbox when no texture has been produced with it.
+ Mailbox mailbox = Mailbox::Generate();
+ GLuint new_texture_id = kNewClientId;
+
+ EXPECT_CALL(*gl_, GenTextures(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, _))
+ .Times(2)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
+ .Times(1)
+ .RetiresOnSaturation();
+
+ CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd =
+ *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>();
+ consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name);
+ EXPECT_EQ(error::kNoError,
+ ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name)));
+
+ // CreateAndConsumeTexture should fail if the mailbox isn't associated with a
+ // texture.
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+
+ // Make sure the new client_id is associated with a texture ref even though
+ // CreateAndConsumeTexture failed.
+ TextureRef* texture_ref =
+ group().texture_manager()->GetTexture(new_texture_id);
+ ASSERT_TRUE(texture_ref != NULL);
+ Texture* texture = texture_ref->texture();
+ // New texture should have the correct target type.
+ EXPECT_TRUE(texture->target() == GL_TEXTURE_2D);
+ // New texture should have a valid service_id.
+ EXPECT_EQ(kNewServiceId, texture->service_id());
+}
+
+TEST_P(GLES2DecoderTest, CreateAndConsumeTextureCHROMIUMInvalidTarget) {
+ Mailbox mailbox = Mailbox::Generate();
+
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ TextureRef* texture_ref =
+ group().texture_manager()->GetTexture(client_texture_id_);
+ ASSERT_TRUE(texture_ref != NULL);
+
+ ProduceTextureDirectCHROMIUMImmediate& produce_cmd =
+ *GetImmediateAs<ProduceTextureDirectCHROMIUMImmediate>();
+ produce_cmd.Init(client_texture_id_, GL_TEXTURE_2D, mailbox.name);
+ EXPECT_EQ(error::kNoError,
+ ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name)));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+
+ EXPECT_CALL(*gl_, GenTextures(1, _))
+ .WillOnce(SetArgumentPointee<1>(kNewServiceId))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, _))
+ .Times(2)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
+ .Times(1)
+ .RetiresOnSaturation();
+
+ // Attempt to consume the mailbox with a different target.
+ GLuint new_texture_id = kNewClientId;
+ CreateAndConsumeTextureCHROMIUMImmediate& consume_cmd =
+ *GetImmediateAs<CreateAndConsumeTextureCHROMIUMImmediate>();
+ consume_cmd.Init(GL_TEXTURE_CUBE_MAP, new_texture_id, mailbox.name);
+ EXPECT_EQ(error::kNoError,
+ ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name)));
+
+ // CreateAndConsumeTexture should fail if the produced texture had a different
+ // target.
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+
+ // Make sure the new client_id is associated with a texture ref even though
+ // CreateAndConsumeTexture failed.
+ texture_ref = group().texture_manager()->GetTexture(new_texture_id);
+ ASSERT_TRUE(texture_ref != NULL);
+ Texture* texture = texture_ref->texture();
+ // New texture should have the correct target type.
+ EXPECT_TRUE(texture->target() == GL_TEXTURE_CUBE_MAP);
+ // New texture should have a valid service_id.
+ EXPECT_EQ(kNewServiceId, texture->service_id());
+
+ // Make sure the client_id did not become associated with the produced texture
+ // service_id.
+ EXPECT_NE(kServiceTextureId, texture->service_id());
+}
+
TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) {
InitState init;
init.extensions = "GL_ANGLE_depth_texture";
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698