OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/service/gpu_service_test.h" | 8 #include "gpu/command_buffer/service/gpu_service_test.h" |
9 #include "gpu/command_buffer/service/mocks.h" | 9 #include "gpu/command_buffer/service/mocks.h" |
10 #include "gpu/command_buffer/service/test_helper.h" | 10 #include "gpu/command_buffer/service/test_helper.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 EXPECT_EQ(0u, shader1->uniform_map().size()); | 133 EXPECT_EQ(0u, shader1->uniform_map().size()); |
134 EXPECT_EQ(0u, shader1->varying_map().size()); | 134 EXPECT_EQ(0u, shader1->varying_map().size()); |
135 EXPECT_EQ(Shader::kShaderStateWaiting, shader1->shader_state()); | 135 EXPECT_EQ(Shader::kShaderStateWaiting, shader1->shader_state()); |
136 | 136 |
137 // Check we can set its source. | 137 // Check we can set its source. |
138 shader1->set_source(kClient1Source); | 138 shader1->set_source(kClient1Source); |
139 EXPECT_STREQ(kClient1Source, shader1->source().c_str()); | 139 EXPECT_STREQ(kClient1Source, shader1->source().c_str()); |
140 EXPECT_TRUE(shader1->last_compiled_source().empty()); | 140 EXPECT_TRUE(shader1->last_compiled_source().empty()); |
141 | 141 |
142 // Check that DoCompile() will not work if RequestCompile() was not called. | 142 // Check that DoCompile() will not work if RequestCompile() was not called. |
143 MockShaderTranslator translator; | 143 shader1->DoCompile(); |
144 shader1->DoCompile(&translator, Shader::kANGLE); | |
145 EXPECT_EQ(Shader::kShaderStateWaiting, shader1->shader_state()); | 144 EXPECT_EQ(Shader::kShaderStateWaiting, shader1->shader_state()); |
146 EXPECT_FALSE(shader1->valid()); | 145 EXPECT_FALSE(shader1->valid()); |
147 | 146 |
148 // Check RequestCompile() will update the state and last compiled source, but | 147 // Check RequestCompile() will update the state and last compiled source, but |
149 // still keep the actual compile state invalid. | 148 // still keep the actual compile state invalid. |
150 shader1->RequestCompile(); | 149 scoped_refptr<ShaderTranslatorInterface> translator(new MockShaderTranslator); |
| 150 shader1->RequestCompile(translator, Shader::kANGLE); |
151 EXPECT_EQ(Shader::kShaderStateCompileRequested, shader1->shader_state()); | 151 EXPECT_EQ(Shader::kShaderStateCompileRequested, shader1->shader_state()); |
152 EXPECT_STREQ(kClient1Source, shader1->last_compiled_source().c_str()); | 152 EXPECT_STREQ(kClient1Source, shader1->last_compiled_source().c_str()); |
153 EXPECT_FALSE(shader1->valid()); | 153 EXPECT_FALSE(shader1->valid()); |
154 | 154 |
155 // Check DoCompile() will set compilation states, log, translated source, | 155 // Check DoCompile() will set compilation states, log, translated source, |
156 // shader variables, and name mapping. | 156 // shader variables, and name mapping. |
157 const std::string kLog = "foo"; | 157 const std::string kLog = "foo"; |
158 const std::string kTranslatedSource = "poo"; | 158 const std::string kTranslatedSource = "poo"; |
159 | 159 |
160 AttributeMap attrib_map; | 160 AttributeMap attrib_map; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 EXPECT_FALSE(shader1->InUse()); | 272 EXPECT_FALSE(shader1->InUse()); |
273 shader2 = manager_.GetShader(kClient1Id); | 273 shader2 = manager_.GetShader(kClient1Id); |
274 EXPECT_EQ(shader1, shader2); | 274 EXPECT_EQ(shader1, shader2); |
275 manager_.MarkAsDeleted(shader1); // this should delete the shader. | 275 manager_.MarkAsDeleted(shader1); // this should delete the shader. |
276 shader2 = manager_.GetShader(kClient1Id); | 276 shader2 = manager_.GetShader(kClient1Id); |
277 EXPECT_TRUE(shader2 == NULL); | 277 EXPECT_TRUE(shader2 == NULL); |
278 } | 278 } |
279 | 279 |
280 } // namespace gles2 | 280 } // namespace gles2 |
281 } // namespace gpu | 281 } // namespace gpu |
OLD | NEW |