| 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, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, |
| 328 GL_RGBA, GL_FLOAT, _)) |
| 329 .Times(1) |
| 330 .RetiresOnSaturation(); |
| 331 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, gl_ids[1])) |
| 332 .Times(1) |
| 333 .RetiresOnSaturation(); |
| 334 EXPECT_CALL(*gl, FramebufferTexture2DEXT(GL_FRAMEBUFFER, |
| 335 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl_ids[1], 0)) |
| 336 .Times(1) |
| 337 .RetiresOnSaturation(); |
| 338 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 339 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
| 340 .RetiresOnSaturation(); |
| 341 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, |
| 342 GL_RGB, GL_FLOAT, _)) |
| 343 .Times(1) |
| 344 .RetiresOnSaturation(); |
| 345 if (is_es3) { |
| 346 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 347 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) |
| 348 .RetiresOnSaturation(); |
| 349 } else { |
| 350 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 351 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
| 352 .RetiresOnSaturation(); |
| 353 } |
| 354 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _)) |
| 355 .Times(1) |
| 356 .RetiresOnSaturation(); |
| 357 EXPECT_CALL(*gl, DeleteTextures(1, _)) |
| 358 .Times(1) |
| 359 .RetiresOnSaturation(); |
| 360 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, gl_ids[0])) |
| 361 .Times(1) |
| 362 .RetiresOnSaturation(); |
| 363 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, gl_ids[0])) |
| 364 .Times(1) |
| 365 .RetiresOnSaturation(); |
| 366 if (DCHECK_IS_ON()) { |
| 367 EXPECT_CALL(*gl, GetError()) |
| 368 .WillOnce(Return(GL_NO_ERROR)) |
| 369 .RetiresOnSaturation(); |
| 370 } |
| 371 } |
| 300 } | 372 } |
| 301 | 373 |
| 302 void TestHelper::SetupExpectationsForClearingUniforms( | 374 void TestHelper::SetupExpectationsForClearingUniforms( |
| 303 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms) { | 375 ::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms) { |
| 304 for (size_t ii = 0; ii < num_uniforms; ++ii) { | 376 for (size_t ii = 0; ii < num_uniforms; ++ii) { |
| 305 const UniformInfo& info = uniforms[ii]; | 377 const UniformInfo& info = uniforms[ii]; |
| 306 switch (info.type) { | 378 switch (info.type) { |
| 307 case GL_FLOAT: | 379 case GL_FLOAT: |
| 308 EXPECT_CALL(*gl, Uniform1fv(info.real_location, info.size, _)) | 380 EXPECT_CALL(*gl, Uniform1fv(info.real_location, info.size, _)) |
| 309 .Times(1) | 381 .Times(1) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 gfx::SetGLImplementation(implementation); | 625 gfx::SetGLImplementation(implementation); |
| 554 } | 626 } |
| 555 | 627 |
| 556 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { | 628 ScopedGLImplementationSetter::~ScopedGLImplementationSetter() { |
| 557 gfx::SetGLImplementation(old_implementation_); | 629 gfx::SetGLImplementation(old_implementation_); |
| 558 } | 630 } |
| 559 | 631 |
| 560 } // namespace gles2 | 632 } // namespace gles2 |
| 561 } // namespace gpu | 633 } // namespace gpu |
| 562 | 634 |
| OLD | NEW |