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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 220 } |
221 | 221 |
222 EXPECT_CALL(*gl, DeleteTextures(4, _)) | 222 EXPECT_CALL(*gl, DeleteTextures(4, _)) |
223 .Times(1) | 223 .Times(1) |
224 .RetiresOnSaturation(); | 224 .RetiresOnSaturation(); |
225 } | 225 } |
226 | 226 |
227 void TestHelper::SetupContextGroupInitExpectations( | 227 void TestHelper::SetupContextGroupInitExpectations( |
228 ::gfx::MockGLInterface* gl, | 228 ::gfx::MockGLInterface* gl, |
229 const DisallowedFeatures& disallowed_features, | 229 const DisallowedFeatures& disallowed_features, |
230 const char* extensions) { | 230 const char* extensions, |
| 231 const char* gl_version) { |
231 InSequence sequence; | 232 InSequence sequence; |
232 | 233 |
233 SetupFeatureInfoInitExpectations(gl, extensions); | 234 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version); |
| 235 |
| 236 std::string l_version(StringToLowerASCII(std::string(gl_version))); |
| 237 bool is_es3 = (l_version.substr(0, 12) == "opengl es 3."); |
234 | 238 |
235 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) | 239 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) |
236 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) | 240 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) |
237 .RetiresOnSaturation(); | 241 .RetiresOnSaturation(); |
238 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || | 242 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || |
239 strstr(extensions, "GL_EXT_multisampled_render_to_texture")) { | 243 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || is_es3) { |
240 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) | 244 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) |
241 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) | 245 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) |
242 .RetiresOnSaturation(); | 246 .RetiresOnSaturation(); |
243 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { | 247 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { |
244 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES_IMG, _)) | 248 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES_IMG, _)) |
245 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) | 249 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) |
246 .RetiresOnSaturation(); | 250 .RetiresOnSaturation(); |
247 } | 251 } |
248 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) | 252 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) |
249 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) | 253 .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 294 |
291 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS)) | 295 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS)) |
292 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions))) | 296 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions))) |
293 .RetiresOnSaturation(); | 297 .RetiresOnSaturation(); |
294 EXPECT_CALL(*gl, GetString(GL_RENDERER)) | 298 EXPECT_CALL(*gl, GetString(GL_RENDERER)) |
295 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_renderer))) | 299 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_renderer))) |
296 .RetiresOnSaturation(); | 300 .RetiresOnSaturation(); |
297 EXPECT_CALL(*gl, GetString(GL_VERSION)) | 301 EXPECT_CALL(*gl, GetString(GL_VERSION)) |
298 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_version))) | 302 .WillOnce(Return(reinterpret_cast<const uint8*>(gl_version))) |
299 .RetiresOnSaturation(); | 303 .RetiresOnSaturation(); |
| 304 |
| 305 std::string l_version(StringToLowerASCII(std::string(gl_version))); |
| 306 bool is_es3 = (l_version.substr(0, 12) == "opengl es 3."); |
| 307 |
| 308 if (strstr(extensions, "GL_ARB_texture_float") || |
| 309 (is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) { |
| 310 static const GLuint gl_ids[] = {101, 102}; |
| 311 const GLsizei width = 16; |
| 312 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _)) |
| 313 .WillOnce(SetArgumentPointee<1>(gl_ids[0])) |
| 314 .RetiresOnSaturation(); |
| 315 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _)) |
| 316 .WillOnce(SetArgumentPointee<1>(gl_ids[0])) |
| 317 .RetiresOnSaturation(); |
| 318 EXPECT_CALL(*gl, GenTextures(1, _)) |
| 319 .WillOnce(SetArrayArgument<1>(gl_ids + 1, gl_ids + 2)) |
| 320 .RetiresOnSaturation(); |
| 321 EXPECT_CALL(*gl, GenFramebuffersEXT(1, _)) |
| 322 .WillOnce(SetArrayArgument<1>(gl_ids + 1, gl_ids + 2)) |
| 323 .RetiresOnSaturation(); |
| 324 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, gl_ids[1])) |
| 325 .Times(1) |
| 326 .RetiresOnSaturation(); |
| 327 EXPECT_CALL(*gl, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 328 GL_NEAREST)) |
| 329 .Times(1) |
| 330 .RetiresOnSaturation(); |
| 331 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, |
| 332 GL_RGBA, GL_FLOAT, _)) |
| 333 .Times(1) |
| 334 .RetiresOnSaturation(); |
| 335 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, gl_ids[1])) |
| 336 .Times(1) |
| 337 .RetiresOnSaturation(); |
| 338 EXPECT_CALL(*gl, FramebufferTexture2DEXT(GL_FRAMEBUFFER, |
| 339 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl_ids[1], 0)) |
| 340 .Times(1) |
| 341 .RetiresOnSaturation(); |
| 342 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 343 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
| 344 .RetiresOnSaturation(); |
| 345 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, |
| 346 GL_RGB, GL_FLOAT, _)) |
| 347 .Times(1) |
| 348 .RetiresOnSaturation(); |
| 349 if (is_es3) { |
| 350 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 351 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) |
| 352 .RetiresOnSaturation(); |
| 353 } else { |
| 354 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 355 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
| 356 .RetiresOnSaturation(); |
| 357 } |
| 358 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _)) |
| 359 .Times(1) |
| 360 .RetiresOnSaturation(); |
| 361 EXPECT_CALL(*gl, DeleteTextures(1, _)) |
| 362 .Times(1) |
| 363 .RetiresOnSaturation(); |
| 364 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, gl_ids[0])) |
| 365 .Times(1) |
| 366 .RetiresOnSaturation(); |
| 367 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, gl_ids[0])) |
| 368 .Times(1) |
| 369 .RetiresOnSaturation(); |
| 370 if (DCHECK_IS_ON()) { |
| 371 EXPECT_CALL(*gl, GetError()) |
| 372 .WillOnce(Return(GL_NO_ERROR)) |
| 373 .RetiresOnSaturation(); |
| 374 } |
| 375 } |
300 } | 376 } |
301 | 377 |
302 void TestHelper::SetupExpectationsForClearingUniforms( | 378 void TestHelper::SetupExpectationsForClearingUniforms( |
303 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms) { | 379 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms) { |
304 for (size_t ii = 0; ii < num_uniforms; ++ii) { | 380 for (size_t ii = 0; ii < num_uniforms; ++ii) { |
305 const UniformInfo& info = uniforms[ii]; | 381 const UniformInfo& info = uniforms[ii]; |
306 switch (info.type) { | 382 switch (info.type) { |
307 case GL_FLOAT: | 383 case GL_FLOAT: |
308 EXPECT_CALL(*gl, Uniform1fv(info.real_location, info.size, _)) | 384 EXPECT_CALL(*gl, Uniform1fv(info.real_location, info.size, _)) |
309 .Times(1) | 385 .Times(1) |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 gfx::SetGLImplementation(implementation); | 629 gfx::SetGLImplementation(implementation); |
554 } | 630 } |
555 | 631 |
556 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { | 632 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { |
557 gfx::SetGLImplementation(old_implementation_); | 633 gfx::SetGLImplementation(old_implementation_); |
558 } | 634 } |
559 | 635 |
560 } // namespace gles2 | 636 } // namespace gles2 |
561 } // namespace gpu | 637 } // namespace gpu |
562 | 638 |
OLD | NEW |