OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/shader_manager.h" | 5 #include "gpu/command_buffer/service/shader_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "gpu/command_buffer/common/gl_mock.h" | 8 #include "gpu/command_buffer/common/gl_mock.h" |
9 #include "gpu/command_buffer/service/mocks.h" | 9 #include "gpu/command_buffer/service/mocks.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 const char* kAttrib2Name = "attr2"; | 135 const char* kAttrib2Name = "attr2"; |
136 const GLenum kUniform1Type = GL_FLOAT_MAT2; | 136 const GLenum kUniform1Type = GL_FLOAT_MAT2; |
137 const GLsizei kUniform1Size = 3; | 137 const GLsizei kUniform1Size = 3; |
138 const char* kUniform1Name = "uni1"; | 138 const char* kUniform1Name = "uni1"; |
139 const GLenum kUniform2Type = GL_FLOAT_MAT3; | 139 const GLenum kUniform2Type = GL_FLOAT_MAT3; |
140 const GLsizei kUniform2Size = 5; | 140 const GLsizei kUniform2Size = 5; |
141 const char* kUniform2Name = "uni2"; | 141 const char* kUniform2Name = "uni2"; |
142 MockShaderTranslator shader_translator; | 142 MockShaderTranslator shader_translator; |
143 ShaderTranslator::VariableMap attrib_map; | 143 ShaderTranslator::VariableMap attrib_map; |
144 attrib_map[kAttrib1Name] = ShaderTranslatorInterface::VariableInfo( | 144 attrib_map[kAttrib1Name] = ShaderTranslatorInterface::VariableInfo( |
145 kAttrib1Type, kAttrib1Size); | 145 kAttrib1Type, kAttrib1Size, kAttrib1Name); |
146 attrib_map[kAttrib2Name] = ShaderTranslatorInterface::VariableInfo( | 146 attrib_map[kAttrib2Name] = ShaderTranslatorInterface::VariableInfo( |
147 kAttrib2Type, kAttrib2Size); | 147 kAttrib2Type, kAttrib2Size, kAttrib2Name); |
148 ShaderTranslator::VariableMap uniform_map; | 148 ShaderTranslator::VariableMap uniform_map; |
149 uniform_map[kUniform1Name] = ShaderTranslatorInterface::VariableInfo( | 149 uniform_map[kUniform1Name] = ShaderTranslatorInterface::VariableInfo( |
150 kUniform1Type, kUniform1Size); | 150 kUniform1Type, kUniform1Size, kUniform1Name); |
151 uniform_map[kUniform2Name] = ShaderTranslatorInterface::VariableInfo( | 151 uniform_map[kUniform2Name] = ShaderTranslatorInterface::VariableInfo( |
152 kUniform2Type, kUniform2Size); | 152 kUniform2Type, kUniform2Size, kUniform2Name); |
153 EXPECT_CALL(shader_translator, attrib_map()) | 153 EXPECT_CALL(shader_translator, attrib_map()) |
154 .WillRepeatedly(ReturnRef(attrib_map)); | 154 .WillRepeatedly(ReturnRef(attrib_map)); |
155 EXPECT_CALL(shader_translator, uniform_map()) | 155 EXPECT_CALL(shader_translator, uniform_map()) |
156 .WillRepeatedly(ReturnRef(uniform_map)); | 156 .WillRepeatedly(ReturnRef(uniform_map)); |
157 // Check we can create shader. | 157 // Check we can create shader. |
158 ShaderManager::ShaderInfo* info1 = manager_.CreateShaderInfo( | 158 ShaderManager::ShaderInfo* info1 = manager_.CreateShaderInfo( |
159 kClient1Id, kService1Id, kShader1Type); | 159 kClient1Id, kService1Id, kShader1Type); |
160 // Check shader got created. | 160 // Check shader got created. |
161 ASSERT_TRUE(info1 != NULL); | 161 ASSERT_TRUE(info1 != NULL); |
162 // Set Status | 162 // Set Status |
163 info1->SetStatus(true, "", &shader_translator); | 163 info1->SetStatus(true, "", &shader_translator); |
164 // Check attrib and uniform infos got copied. | 164 // Check attrib and uniform infos got copied. |
165 for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin(); | 165 for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin(); |
166 it != attrib_map.end(); ++it) { | 166 it != attrib_map.end(); ++it) { |
167 const ShaderManager::ShaderInfo::VariableInfo* variable_info = | 167 const ShaderManager::ShaderInfo::VariableInfo* variable_info = |
168 info1->GetAttribInfo(it->first); | 168 info1->GetAttribInfo(it->first); |
169 ASSERT_TRUE(variable_info != NULL); | 169 ASSERT_TRUE(variable_info != NULL); |
170 EXPECT_EQ(it->second.type, variable_info->type); | 170 EXPECT_EQ(it->second.type, variable_info->type); |
171 EXPECT_EQ(it->second.size, variable_info->size); | 171 EXPECT_EQ(it->second.size, variable_info->size); |
| 172 EXPECT_EQ(it->second.name, variable_info->name); |
172 } | 173 } |
173 for (ShaderTranslator::VariableMap::const_iterator it = uniform_map.begin(); | 174 for (ShaderTranslator::VariableMap::const_iterator it = uniform_map.begin(); |
174 it != uniform_map.end(); ++it) { | 175 it != uniform_map.end(); ++it) { |
175 const ShaderManager::ShaderInfo::VariableInfo* variable_info = | 176 const ShaderManager::ShaderInfo::VariableInfo* variable_info = |
176 info1->GetUniformInfo(it->first); | 177 info1->GetUniformInfo(it->first); |
177 ASSERT_TRUE(variable_info != NULL); | 178 ASSERT_TRUE(variable_info != NULL); |
178 EXPECT_EQ(it->second.type, variable_info->type); | 179 EXPECT_EQ(it->second.type, variable_info->type); |
179 EXPECT_EQ(it->second.size, variable_info->size); | 180 EXPECT_EQ(it->second.size, variable_info->size); |
| 181 EXPECT_EQ(it->second.name, variable_info->name); |
180 } | 182 } |
181 // Check attrib and uniform get cleared. | 183 // Check attrib and uniform get cleared. |
182 info1->SetStatus(true, NULL, NULL); | 184 info1->SetStatus(true, NULL, NULL); |
183 EXPECT_TRUE(info1->log_info() == NULL); | 185 EXPECT_TRUE(info1->log_info() == NULL); |
184 for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin(); | 186 for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin(); |
185 it != attrib_map.end(); ++it) { | 187 it != attrib_map.end(); ++it) { |
186 const ShaderManager::ShaderInfo::VariableInfo* variable_info = | 188 const ShaderManager::ShaderInfo::VariableInfo* variable_info = |
187 info1->GetAttribInfo(it->first); | 189 info1->GetAttribInfo(it->first); |
188 EXPECT_TRUE(variable_info == NULL); | 190 EXPECT_TRUE(variable_info == NULL); |
189 } | 191 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 EXPECT_EQ(info1, info2); | 237 EXPECT_EQ(info1, info2); |
236 manager_.MarkAsDeleted(info1); // this should delete the shader. | 238 manager_.MarkAsDeleted(info1); // this should delete the shader. |
237 info2 = manager_.GetShaderInfo(kClient1Id); | 239 info2 = manager_.GetShaderInfo(kClient1Id); |
238 EXPECT_TRUE(info2 == NULL); | 240 EXPECT_TRUE(info2 == NULL); |
239 } | 241 } |
240 | 242 |
241 } // namespace gles2 | 243 } // namespace gles2 |
242 } // namespace gpu | 244 } // namespace gpu |
243 | 245 |
244 | 246 |
OLD | NEW |