| 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 5e6a0d4e009869efd7c0aef5bb82394af2247b7c..676181389823d8f6df27fa591baa465767bcca4a 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
|
| @@ -1931,6 +1931,106 @@ TEST_P(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) {
|
| EXPECT_EQ(kServiceTextureId, texture->service_id());
|
| }
|
|
|
| +TEST_P(GLES2DecoderTest, ProduceAndConsumeDirectTextureCHROMIUM) {
|
| + Mailbox mailbox = Mailbox::Generate();
|
| +
|
| + DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
|
| + DoTexImage2D(
|
| + GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
|
| + DoTexImage2D(
|
| + GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
|
| + TextureRef* texture_ref =
|
| + group().texture_manager()->GetTexture(client_texture_id_);
|
| + ASSERT_TRUE(texture_ref != NULL);
|
| + Texture* texture = texture_ref->texture();
|
| + EXPECT_EQ(kServiceTextureId, texture->service_id());
|
| +
|
| + 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());
|
| +
|
| + // Texture didn't change.
|
| + GLsizei width;
|
| + GLsizei height;
|
| + GLenum type;
|
| + GLenum internal_format;
|
| +
|
| + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
|
| + EXPECT_EQ(3, width);
|
| + EXPECT_EQ(1, height);
|
| + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
|
| + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
|
| + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
|
| +
|
| + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
|
| + EXPECT_EQ(2, width);
|
| + EXPECT_EQ(4, height);
|
| + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
|
| + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
|
| + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
|
| +
|
| + // Service ID has not changed.
|
| + EXPECT_EQ(kServiceTextureId, texture->service_id());
|
| +
|
| + // Consume the texture into a new client ID.
|
| + GLuint new_texture_id = kNewClientId;
|
| + 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)));
|
| + EXPECT_EQ(GL_NO_ERROR, GetGLError());
|
| +
|
| + // Make sure the new client ID is associated with the produced service ID.
|
| + texture_ref = group().texture_manager()->GetTexture(new_texture_id);
|
| + ASSERT_TRUE(texture_ref != NULL);
|
| + texture = texture_ref->texture();
|
| + EXPECT_EQ(kServiceTextureId, texture->service_id());
|
| +
|
| + DoBindTexture(GL_TEXTURE_2D, kNewClientId, kServiceTextureId);
|
| +
|
| + // Texture is redefined.
|
| + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
|
| + EXPECT_EQ(3, width);
|
| + EXPECT_EQ(1, height);
|
| + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
|
| + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
|
| + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
|
| +
|
| + EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
|
| + EXPECT_EQ(2, width);
|
| + EXPECT_EQ(4, height);
|
| + EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
|
| + EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
|
| + EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
|
| +}
|
| +
|
| +TEST_P(GLES2DecoderTest, ProduceTextureCHROMIUMInvalidTarget) {
|
| + Mailbox mailbox = Mailbox::Generate();
|
| +
|
| + DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId);
|
| + DoTexImage2D(
|
| + GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 1, 0, GL_RGBA,
|
| + GL_UNSIGNED_BYTE, 0, 0);
|
| + TextureRef* texture_ref =
|
| + group().texture_manager()->GetTexture(client_texture_id_);
|
| + ASSERT_TRUE(texture_ref != NULL);
|
| + Texture* texture = texture_ref->texture();
|
| + EXPECT_EQ(kServiceTextureId, texture->service_id());
|
| +
|
| + 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)));
|
| +
|
| + // ProduceTexture should fail it the texture and produce targets don't match.
|
| + EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
|
| +}
|
| +
|
| TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) {
|
| InitState init;
|
| init.extensions = "GL_ANGLE_depth_texture";
|
|
|