summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/shader_manager_unittest.cc
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-08 05:21:42 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-08 05:21:42 +0000
commitdf37b9935c8103e0912cd2eac8094969c42b6539 (patch)
treeff6fa40619151ef5dfab83110a94aec6bb84ee93 /gpu/command_buffer/service/shader_manager_unittest.cc
parent3b55e8b64c79390278ade0a9bdb92a5a21de38bc (diff)
downloadchromium_src-df37b9935c8103e0912cd2eac8094969c42b6539.zip
chromium_src-df37b9935c8103e0912cd2eac8094969c42b6539.tar.gz
chromium_src-df37b9935c8103e0912cd2eac8094969c42b6539.tar.bz2
Refactor GPU code: Shader* info -> Shader* shader
Program* info -> Program* program BUG=none Review URL: https://chromiumcodereview.appspot.com/12665002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/shader_manager_unittest.cc')
-rw-r--r--gpu/command_buffer/service/shader_manager_unittest.cc184
1 files changed, 92 insertions, 92 deletions
diff --git a/gpu/command_buffer/service/shader_manager_unittest.cc b/gpu/command_buffer/service/shader_manager_unittest.cc
index 58e3566..2de9a58 100644
--- a/gpu/command_buffer/service/shader_manager_unittest.cc
+++ b/gpu/command_buffer/service/shader_manager_unittest.cc
@@ -50,12 +50,12 @@ TEST_F(ShaderManagerTest, Basic) {
kClient1Id, kService1Id, kShader1Type);
// Check shader got created.
ASSERT_TRUE(info0 != NULL);
- Shader* info1 = manager_.GetShader(kClient1Id);
- ASSERT_EQ(info0, info1);
+ Shader* shader1 = manager_.GetShader(kClient1Id);
+ ASSERT_EQ(info0, shader1);
// Check we get nothing for a non-existent shader.
EXPECT_TRUE(manager_.GetShader(kClient2Id) == NULL);
// Check we can't get the shader after we remove it.
- manager_.MarkAsDeleted(info1);
+ manager_.MarkAsDeleted(shader1);
EXPECT_TRUE(manager_.GetShader(kClient1Id) == NULL);
}
@@ -64,17 +64,17 @@ TEST_F(ShaderManagerTest, Destroy) {
const GLuint kService1Id = 11;
const GLenum kShader1Type = GL_VERTEX_SHADER;
// Check we can create shader.
- Shader* info1 = manager_.CreateShader(
+ Shader* shader1 = manager_.CreateShader(
kClient1Id, kService1Id, kShader1Type);
// Check shader got created.
- ASSERT_TRUE(info1 != NULL);
+ ASSERT_TRUE(shader1 != NULL);
EXPECT_CALL(*gl_, DeleteShader(kService1Id))
.Times(1)
.RetiresOnSaturation();
manager_.Destroy(true);
// Check that resources got freed.
- info1 = manager_.GetShader(kClient1Id);
- ASSERT_TRUE(info1 == NULL);
+ shader1 = manager_.GetShader(kClient1Id);
+ ASSERT_TRUE(shader1 == NULL);
}
TEST_F(ShaderManagerTest, DeleteBug) {
@@ -84,17 +84,17 @@ TEST_F(ShaderManagerTest, DeleteBug) {
const GLuint kService2Id = 12;
const GLenum kShaderType = GL_VERTEX_SHADER;
// Check we can create shader.
- scoped_refptr<Shader> info1(
+ scoped_refptr<Shader> shader1(
manager_.CreateShader(kClient1Id, kService1Id, kShaderType));
- scoped_refptr<Shader> info2(
+ scoped_refptr<Shader> shader2(
manager_.CreateShader(kClient2Id, kService2Id, kShaderType));
- ASSERT_TRUE(info1);
- ASSERT_TRUE(info2);
- manager_.UseShader(info1);
- manager_.MarkAsDeleted(info1);
- manager_.MarkAsDeleted(info2);
- EXPECT_TRUE(manager_.IsOwned(info1));
- EXPECT_FALSE(manager_.IsOwned(info2));
+ ASSERT_TRUE(shader1);
+ ASSERT_TRUE(shader2);
+ manager_.UseShader(shader1);
+ manager_.MarkAsDeleted(shader1);
+ manager_.MarkAsDeleted(shader2);
+ EXPECT_TRUE(manager_.IsOwned(shader1));
+ EXPECT_FALSE(manager_.IsOwned(shader2));
}
TEST_F(ShaderManagerTest, Shader) {
@@ -103,29 +103,29 @@ TEST_F(ShaderManagerTest, Shader) {
const GLenum kShader1Type = GL_VERTEX_SHADER;
const char* kClient1Source = "hello world";
// Check we can create shader.
- Shader* info1 = manager_.CreateShader(
+ Shader* shader1 = manager_.CreateShader(
kClient1Id, kService1Id, kShader1Type);
// Check shader got created.
- ASSERT_TRUE(info1 != NULL);
- EXPECT_EQ(kService1Id, info1->service_id());
+ ASSERT_TRUE(shader1 != NULL);
+ EXPECT_EQ(kService1Id, shader1->service_id());
// Check if the shader has correct type.
- EXPECT_EQ(kShader1Type, info1->shader_type());
- EXPECT_FALSE(info1->IsValid());
- EXPECT_FALSE(info1->InUse());
- EXPECT_TRUE(info1->source() == NULL);
- EXPECT_TRUE(info1->log_info() == NULL);
+ EXPECT_EQ(kShader1Type, shader1->shader_type());
+ EXPECT_FALSE(shader1->IsValid());
+ EXPECT_FALSE(shader1->InUse());
+ EXPECT_TRUE(shader1->source() == NULL);
+ EXPECT_TRUE(shader1->log_info() == NULL);
const char* kLog = "foo";
- info1->SetStatus(true, kLog, NULL);
- EXPECT_TRUE(info1->IsValid());
- EXPECT_STREQ(kLog, info1->log_info()->c_str());
+ shader1->SetStatus(true, kLog, NULL);
+ EXPECT_TRUE(shader1->IsValid());
+ EXPECT_STREQ(kLog, shader1->log_info()->c_str());
// Check we can set its source.
- info1->UpdateSource(kClient1Source);
- EXPECT_STREQ(kClient1Source, info1->source()->c_str());
- EXPECT_EQ(NULL, info1->translated_source());
+ shader1->UpdateSource(kClient1Source);
+ EXPECT_STREQ(kClient1Source, shader1->source()->c_str());
+ EXPECT_EQ(NULL, shader1->translated_source());
// Check we can set its translated source.
- info1->UpdateTranslatedSource(kClient1Source);
+ shader1->UpdateTranslatedSource(kClient1Source);
EXPECT_STREQ(kClient1Source,
- info1->translated_source()->c_str());
+ shader1->translated_source()->c_str());
}
TEST_F(ShaderManagerTest, GetInfo) {
@@ -163,17 +163,17 @@ TEST_F(ShaderManagerTest, GetInfo) {
EXPECT_CALL(shader_translator, name_map())
.WillRepeatedly(ReturnRef(name_map));
// Check we can create shader.
- Shader* info1 = manager_.CreateShader(
+ Shader* shader1 = manager_.CreateShader(
kClient1Id, kService1Id, kShader1Type);
// Check shader got created.
- ASSERT_TRUE(info1 != NULL);
+ ASSERT_TRUE(shader1 != NULL);
// Set Status
- info1->SetStatus(true, "", &shader_translator);
+ shader1->SetStatus(true, "", &shader_translator);
// Check attrib and uniform infos got copied.
for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin();
it != attrib_map.end(); ++it) {
const Shader::VariableInfo* variable_info =
- info1->GetAttribInfo(it->first);
+ shader1->GetAttribInfo(it->first);
ASSERT_TRUE(variable_info != NULL);
EXPECT_EQ(it->second.type, variable_info->type);
EXPECT_EQ(it->second.size, variable_info->size);
@@ -182,25 +182,25 @@ TEST_F(ShaderManagerTest, GetInfo) {
for (ShaderTranslator::VariableMap::const_iterator it = uniform_map.begin();
it != uniform_map.end(); ++it) {
const Shader::VariableInfo* variable_info =
- info1->GetUniformInfo(it->first);
+ shader1->GetUniformInfo(it->first);
ASSERT_TRUE(variable_info != NULL);
EXPECT_EQ(it->second.type, variable_info->type);
EXPECT_EQ(it->second.size, variable_info->size);
EXPECT_EQ(it->second.name, variable_info->name);
}
// Check attrib and uniform get cleared.
- info1->SetStatus(true, NULL, NULL);
- EXPECT_TRUE(info1->log_info() == NULL);
+ shader1->SetStatus(true, NULL, NULL);
+ EXPECT_TRUE(shader1->log_info() == NULL);
for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin();
it != attrib_map.end(); ++it) {
const Shader::VariableInfo* variable_info =
- info1->GetAttribInfo(it->first);
+ shader1->GetAttribInfo(it->first);
EXPECT_TRUE(variable_info == NULL);
}
for (ShaderTranslator::VariableMap::const_iterator it = uniform_map.begin();
it != uniform_map.end(); ++it) {
const Shader::VariableInfo* variable_info =
- info1->GetUniformInfo(it->first);
+ shader1->GetUniformInfo(it->first);
ASSERT_TRUE(variable_info == NULL);
}
}
@@ -210,82 +210,82 @@ TEST_F(ShaderManagerTest, ShaderInfoUseCount) {
const GLuint kService1Id = 11;
const GLenum kShader1Type = GL_VERTEX_SHADER;
// Check we can create shader.
- Shader* info1 = manager_.CreateShader(
+ Shader* shader1 = manager_.CreateShader(
kClient1Id, kService1Id, kShader1Type);
// Check shader got created.
- ASSERT_TRUE(info1 != NULL);
- EXPECT_FALSE(info1->InUse());
- EXPECT_FALSE(info1->IsDeleted());
- manager_.UseShader(info1);
- EXPECT_TRUE(info1->InUse());
- manager_.UseShader(info1);
- EXPECT_TRUE(info1->InUse());
- manager_.MarkAsDeleted(info1);
- EXPECT_TRUE(info1->IsDeleted());
- Shader* info2 = manager_.GetShader(kClient1Id);
- EXPECT_EQ(info1, info2);
- manager_.UnuseShader(info1);
- EXPECT_TRUE(info1->InUse());
- manager_.UnuseShader(info1); // this should delete the info.
- info2 = manager_.GetShader(kClient1Id);
- EXPECT_TRUE(info2 == NULL);
+ ASSERT_TRUE(shader1 != NULL);
+ EXPECT_FALSE(shader1->InUse());
+ EXPECT_FALSE(shader1->IsDeleted());
+ manager_.UseShader(shader1);
+ EXPECT_TRUE(shader1->InUse());
+ manager_.UseShader(shader1);
+ EXPECT_TRUE(shader1->InUse());
+ manager_.MarkAsDeleted(shader1);
+ EXPECT_TRUE(shader1->IsDeleted());
+ Shader* shader2 = manager_.GetShader(kClient1Id);
+ EXPECT_EQ(shader1, shader2);
+ manager_.UnuseShader(shader1);
+ EXPECT_TRUE(shader1->InUse());
+ manager_.UnuseShader(shader1); // this should delete the info.
+ shader2 = manager_.GetShader(kClient1Id);
+ EXPECT_TRUE(shader2 == NULL);
- info1 = manager_.CreateShader(kClient1Id, kService1Id, kShader1Type);
- ASSERT_TRUE(info1 != NULL);
- EXPECT_FALSE(info1->InUse());
- manager_.UseShader(info1);
- EXPECT_TRUE(info1->InUse());
- manager_.UseShader(info1);
- EXPECT_TRUE(info1->InUse());
- manager_.UnuseShader(info1);
- EXPECT_TRUE(info1->InUse());
- manager_.UnuseShader(info1);
- EXPECT_FALSE(info1->InUse());
- info2 = manager_.GetShader(kClient1Id);
- EXPECT_EQ(info1, info2);
- manager_.MarkAsDeleted(info1); // this should delete the shader.
- info2 = manager_.GetShader(kClient1Id);
- EXPECT_TRUE(info2 == NULL);
+ shader1 = manager_.CreateShader(kClient1Id, kService1Id, kShader1Type);
+ ASSERT_TRUE(shader1 != NULL);
+ EXPECT_FALSE(shader1->InUse());
+ manager_.UseShader(shader1);
+ EXPECT_TRUE(shader1->InUse());
+ manager_.UseShader(shader1);
+ EXPECT_TRUE(shader1->InUse());
+ manager_.UnuseShader(shader1);
+ EXPECT_TRUE(shader1->InUse());
+ manager_.UnuseShader(shader1);
+ EXPECT_FALSE(shader1->InUse());
+ shader2 = manager_.GetShader(kClient1Id);
+ EXPECT_EQ(shader1, shader2);
+ manager_.MarkAsDeleted(shader1); // this should delete the shader.
+ shader2 = manager_.GetShader(kClient1Id);
+ EXPECT_TRUE(shader2 == NULL);
}
TEST_F(ShaderManagerTest, ShaderInfoStoreCompilationStatus) {
const GLuint kClientId = 1;
const GLuint kServiceId = 11;
const GLenum kShaderType = GL_VERTEX_SHADER;
- Shader* info = manager_.CreateShader(
+ Shader* shader = manager_.CreateShader(
kClientId, kServiceId, kShaderType);
- ASSERT_TRUE(info != NULL);
+ ASSERT_TRUE(shader != NULL);
EXPECT_EQ(Shader::NOT_COMPILED,
- info->compilation_status());
- info->UpdateSource("original source");
+ shader->compilation_status());
+ shader->UpdateSource("original source");
EXPECT_EQ(Shader::NOT_COMPILED,
- info->compilation_status());
- info->FlagSourceAsCompiled(false);
+ shader->compilation_status());
+ shader->FlagSourceAsCompiled(false);
EXPECT_EQ(Shader::PENDING_DEFERRED_COMPILE,
- info->compilation_status());
- info->FlagSourceAsCompiled(true);
+ shader->compilation_status());
+ shader->FlagSourceAsCompiled(true);
EXPECT_EQ(Shader::COMPILED,
- info->compilation_status());
+ shader->compilation_status());
}
TEST_F(ShaderManagerTest, ShaderInfoStoreDeferredSource) {
const GLuint kClientId = 1;
const GLuint kServiceId = 11;
const GLenum kShaderType = GL_VERTEX_SHADER;
- Shader* info = manager_.CreateShader(
+ Shader* shader = manager_.CreateShader(
kClientId, kServiceId, kShaderType);
- ASSERT_TRUE(info != NULL);
+ ASSERT_TRUE(shader != NULL);
- info->UpdateSource("original source");
- info->FlagSourceAsCompiled(false);
+ shader->UpdateSource("original source");
+ shader->FlagSourceAsCompiled(false);
- EXPECT_EQ("original source", *info->deferred_compilation_source());
- info->UpdateSource("different!");
- EXPECT_EQ("original source", *info->deferred_compilation_source());
+ EXPECT_EQ("original source", *shader->deferred_compilation_source());
+ shader->UpdateSource("different!");
+ EXPECT_EQ("original source", *shader->deferred_compilation_source());
- info->FlagSourceAsCompiled(true);
- EXPECT_EQ("different!", *info->deferred_compilation_source());
+ shader->FlagSourceAsCompiled(true);
+ EXPECT_EQ("different!", *shader->deferred_compilation_source());
}
} // namespace gles2