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/test_helper.h" | 5 #include "gpu/command_buffer/service/test_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 ::gl::MockGLInterface* gl, | 1116 ::gl::MockGLInterface* gl, |
1117 Shader* shader, | 1117 Shader* shader, |
1118 bool expected_valid, | 1118 bool expected_valid, |
1119 const std::string* const expected_log_info, | 1119 const std::string* const expected_log_info, |
1120 const std::string* const expected_translated_source, | 1120 const std::string* const expected_translated_source, |
1121 const int* const expected_shader_version, | 1121 const int* const expected_shader_version, |
1122 const AttributeMap* const expected_attrib_map, | 1122 const AttributeMap* const expected_attrib_map, |
1123 const UniformMap* const expected_uniform_map, | 1123 const UniformMap* const expected_uniform_map, |
1124 const VaryingMap* const expected_varying_map, | 1124 const VaryingMap* const expected_varying_map, |
1125 const InterfaceBlockMap* const expected_interface_block_map, | 1125 const InterfaceBlockMap* const expected_interface_block_map, |
1126 const OutputVariableList* const expected_output_variable_list, | 1126 const OutputVariableList* const expected_output_variable_list) { |
1127 const NameMap* const expected_name_map) { | |
1128 const std::string empty_log_info; | 1127 const std::string empty_log_info; |
1129 const std::string* log_info = (expected_log_info && !expected_valid) ? | 1128 const std::string* log_info = (expected_log_info && !expected_valid) ? |
1130 expected_log_info : &empty_log_info; | 1129 expected_log_info : &empty_log_info; |
1131 const std::string empty_translated_source; | 1130 const std::string empty_translated_source; |
1132 const std::string* translated_source = | 1131 const std::string* translated_source = |
1133 (expected_translated_source && expected_valid) ? | 1132 (expected_translated_source && expected_valid) ? |
1134 expected_translated_source : &empty_translated_source; | 1133 expected_translated_source : &empty_translated_source; |
1135 int default_shader_version = 100; | 1134 int default_shader_version = 100; |
1136 const int* shader_version = (expected_shader_version && expected_valid) ? | 1135 const int* shader_version = (expected_shader_version && expected_valid) ? |
1137 expected_shader_version : &default_shader_version; | 1136 expected_shader_version : &default_shader_version; |
1138 const AttributeMap empty_attrib_map; | 1137 const AttributeMap empty_attrib_map; |
1139 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ? | 1138 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ? |
1140 expected_attrib_map : &empty_attrib_map; | 1139 expected_attrib_map : &empty_attrib_map; |
1141 const UniformMap empty_uniform_map; | 1140 const UniformMap empty_uniform_map; |
1142 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ? | 1141 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ? |
1143 expected_uniform_map : &empty_uniform_map; | 1142 expected_uniform_map : &empty_uniform_map; |
1144 const VaryingMap empty_varying_map; | 1143 const VaryingMap empty_varying_map; |
1145 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ? | 1144 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ? |
1146 expected_varying_map : &empty_varying_map; | 1145 expected_varying_map : &empty_varying_map; |
1147 const InterfaceBlockMap empty_interface_block_map; | 1146 const InterfaceBlockMap empty_interface_block_map; |
1148 const InterfaceBlockMap* interface_block_map = | 1147 const InterfaceBlockMap* interface_block_map = |
1149 (expected_interface_block_map && expected_valid) ? | 1148 (expected_interface_block_map && expected_valid) ? |
1150 expected_interface_block_map : &empty_interface_block_map; | 1149 expected_interface_block_map : &empty_interface_block_map; |
1151 const OutputVariableList empty_output_variable_list; | 1150 const OutputVariableList empty_output_variable_list; |
1152 const OutputVariableList* output_variable_list = | 1151 const OutputVariableList* output_variable_list = |
1153 (expected_output_variable_list && expected_valid) | 1152 (expected_output_variable_list && expected_valid) |
1154 ? expected_output_variable_list | 1153 ? expected_output_variable_list |
1155 : &empty_output_variable_list; | 1154 : &empty_output_variable_list; |
1156 const NameMap empty_name_map; | |
1157 const NameMap* name_map = (expected_name_map && expected_valid) ? | |
1158 expected_name_map : &empty_name_map; | |
1159 | 1155 |
1160 MockShaderTranslator* mock_translator = new MockShaderTranslator; | 1156 MockShaderTranslator* mock_translator = new MockShaderTranslator; |
1161 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator); | 1157 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator); |
1162 EXPECT_CALL(*mock_translator, Translate(_, | 1158 EXPECT_CALL(*mock_translator, Translate(_, |
1163 NotNull(), // log_info | 1159 NotNull(), // log_info |
1164 NotNull(), // translated_source | 1160 NotNull(), // translated_source |
1165 NotNull(), // shader_version | 1161 NotNull(), // shader_version |
1166 NotNull(), // attrib_map | 1162 NotNull(), // attrib_map |
1167 NotNull(), // uniform_map | 1163 NotNull(), // uniform_map |
1168 NotNull(), // varying_map | 1164 NotNull(), // varying_map |
1169 NotNull(), // interface_block_map | 1165 NotNull(), // interface_block_map |
1170 NotNull(), // output_variable_list | 1166 NotNull())) // output_variable_list |
1171 NotNull())) // name_map | |
1172 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info), | 1167 .WillOnce(DoAll(SetArgumentPointee<1>(*log_info), |
1173 SetArgumentPointee<2>(*translated_source), | 1168 SetArgumentPointee<2>(*translated_source), |
1174 SetArgumentPointee<3>(*shader_version), | 1169 SetArgumentPointee<3>(*shader_version), |
1175 SetArgumentPointee<4>(*attrib_map), | 1170 SetArgumentPointee<4>(*attrib_map), |
1176 SetArgumentPointee<5>(*uniform_map), | 1171 SetArgumentPointee<5>(*uniform_map), |
1177 SetArgumentPointee<6>(*varying_map), | 1172 SetArgumentPointee<6>(*varying_map), |
1178 SetArgumentPointee<7>(*interface_block_map), | 1173 SetArgumentPointee<7>(*interface_block_map), |
1179 SetArgumentPointee<8>(*output_variable_list), | 1174 SetArgumentPointee<8>(*output_variable_list), |
1180 SetArgumentPointee<9>(*name_map), Return(expected_valid))) | 1175 Return(expected_valid))) |
1181 .RetiresOnSaturation(); | 1176 .RetiresOnSaturation(); |
1182 if (expected_valid) { | 1177 if (expected_valid) { |
1183 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL)) | 1178 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, NULL)) |
1184 .Times(1) | 1179 .Times(1) |
1185 .RetiresOnSaturation(); | 1180 .RetiresOnSaturation(); |
1186 EXPECT_CALL(*gl, CompileShader(shader->service_id())) | 1181 EXPECT_CALL(*gl, CompileShader(shader->service_id())) |
1187 .Times(1) | 1182 .Times(1) |
1188 .RetiresOnSaturation(); | 1183 .RetiresOnSaturation(); |
1189 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(), | 1184 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(), |
1190 GL_COMPILE_STATUS, | 1185 GL_COMPILE_STATUS, |
1191 NotNull())) // status | 1186 NotNull())) // status |
1192 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) | 1187 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) |
1193 .RetiresOnSaturation(); | 1188 .RetiresOnSaturation(); |
1194 } | 1189 } |
1195 shader->RequestCompile(translator, Shader::kGL); | 1190 shader->RequestCompile(translator, Shader::kGL); |
1196 shader->DoCompile(); | 1191 shader->DoCompile(); |
1197 } | 1192 } |
1198 | 1193 |
1199 // static | 1194 // static |
1200 void TestHelper::SetShaderStates(::gl::MockGLInterface* gl, | 1195 void TestHelper::SetShaderStates(::gl::MockGLInterface* gl, |
1201 Shader* shader, | 1196 Shader* shader, |
1202 bool valid) { | 1197 bool valid) { |
1203 SetShaderStates(gl, shader, valid, nullptr, nullptr, nullptr, nullptr, | 1198 SetShaderStates(gl, shader, valid, nullptr, nullptr, nullptr, nullptr, |
1204 nullptr, nullptr, nullptr, nullptr, nullptr); | 1199 nullptr, nullptr, nullptr, nullptr); |
1205 } | 1200 } |
1206 | 1201 |
1207 // static | 1202 // static |
1208 sh::Attribute TestHelper::ConstructAttribute( | 1203 sh::Attribute TestHelper::ConstructAttribute( |
1209 GLenum type, GLint array_size, GLenum precision, | 1204 GLenum type, GLint array_size, GLenum precision, |
1210 bool static_use, const std::string& name) { | 1205 bool static_use, const std::string& name) { |
1211 return ConstructShaderVariable<sh::Attribute>( | 1206 return ConstructShaderVariable<sh::Attribute>( |
1212 type, array_size, precision, static_use, name); | 1207 type, array_size, precision, static_use, name); |
1213 } | 1208 } |
1214 | 1209 |
(...skipping 19 matching lines...) Expand all Loading... |
1234 GLenum precision, | 1229 GLenum precision, |
1235 bool static_use, | 1230 bool static_use, |
1236 const std::string& name) { | 1231 const std::string& name) { |
1237 return ConstructShaderVariable<sh::OutputVariable>( | 1232 return ConstructShaderVariable<sh::OutputVariable>( |
1238 type, array_size, precision, static_use, name); | 1233 type, array_size, precision, static_use, name); |
1239 } | 1234 } |
1240 | 1235 |
1241 } // namespace gles2 | 1236 } // namespace gles2 |
1242 } // namespace gpu | 1237 } // namespace gpu |
1243 | 1238 |
OLD | NEW |