| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 using ::testing::_; | 28 using ::testing::_; |
| 29 using ::testing::DoAll; | 29 using ::testing::DoAll; |
| 30 using ::testing::InSequence; | 30 using ::testing::InSequence; |
| 31 using ::testing::MatcherCast; | 31 using ::testing::MatcherCast; |
| 32 using ::testing::Pointee; | 32 using ::testing::Pointee; |
| 33 using ::testing::NotNull; | 33 using ::testing::NotNull; |
| 34 using ::testing::Return; | 34 using ::testing::Return; |
| 35 using ::testing::SetArrayArgument; | 35 using ::testing::SetArrayArgument; |
| 36 using ::testing::SetArgumentPointee; | 36 using ::testing::SetArgumentPointee; |
| 37 using ::testing::SetArgPointee; |
| 37 using ::testing::StrEq; | 38 using ::testing::StrEq; |
| 38 using ::testing::StrictMock; | 39 using ::testing::StrictMock; |
| 39 | 40 |
| 40 namespace gpu { | 41 namespace gpu { |
| 41 namespace gles2 { | 42 namespace gles2 { |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 template<typename T> | 46 template<typename T> |
| 46 T ConstructShaderVariable( | 47 T ConstructShaderVariable( |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 EXPECT_CALL(*gl, DeleteTextures(TextureManager::kNumDefaultTextures, _)) | 325 EXPECT_CALL(*gl, DeleteTextures(TextureManager::kNumDefaultTextures, _)) |
| 325 .Times(1) | 326 .Times(1) |
| 326 .RetiresOnSaturation(); | 327 .RetiresOnSaturation(); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void TestHelper::SetupContextGroupInitExpectations( | 330 void TestHelper::SetupContextGroupInitExpectations( |
| 330 ::gl::MockGLInterface* gl, | 331 ::gl::MockGLInterface* gl, |
| 331 const DisallowedFeatures& disallowed_features, | 332 const DisallowedFeatures& disallowed_features, |
| 332 const char* extensions, | 333 const char* extensions, |
| 333 const char* gl_version, | 334 const char* gl_version, |
| 335 ContextType context_type, |
| 334 bool bind_generates_resource) { | 336 bool bind_generates_resource) { |
| 335 InSequence sequence; | 337 InSequence sequence; |
| 336 | 338 |
| 337 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version); | 339 gl::GLVersionInfo gl_info(gl_version, "", extensions); |
| 338 | 340 |
| 339 gl::GLVersionInfo gl_info(gl_version, "", extensions); | 341 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version, |
| 342 context_type, |
| 343 context_type == CONTEXT_TYPE_WEBGL2 || |
| 344 context_type == CONTEXT_TYPE_OPENGLES3); |
| 340 | 345 |
| 341 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) | 346 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) |
| 342 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) | 347 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) |
| 343 .RetiresOnSaturation(); | 348 .RetiresOnSaturation(); |
| 344 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || | 349 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || |
| 345 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || | 350 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || |
| 346 gl_info.is_es3 || gl_info.is_desktop_core_profile) { | 351 gl_info.is_es3 || gl_info.is_desktop_core_profile) { |
| 347 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) | 352 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) |
| 348 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) | 353 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) |
| 349 .RetiresOnSaturation(); | 354 .RetiresOnSaturation(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 .RetiresOnSaturation(); | 466 .RetiresOnSaturation(); |
| 462 | 467 |
| 463 bool use_default_textures = bind_generates_resource; | 468 bool use_default_textures = bind_generates_resource; |
| 464 SetupTextureManagerInitExpectations( | 469 SetupTextureManagerInitExpectations( |
| 465 gl, false, gl_info.is_desktop_core_profile, extensions, | 470 gl, false, gl_info.is_desktop_core_profile, extensions, |
| 466 use_default_textures); | 471 use_default_textures); |
| 467 } | 472 } |
| 468 | 473 |
| 469 void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl, | 474 void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl, |
| 470 const char* extensions) { | 475 const char* extensions) { |
| 471 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", ""); | 476 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", "", |
| 477 CONTEXT_TYPE_OPENGLES2); |
| 472 } | 478 } |
| 473 | 479 |
| 474 void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 480 void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
| 475 ::gl::MockGLInterface* gl, | 481 ::gl::MockGLInterface* gl, |
| 476 const char* extensions, | 482 const char* extensions, |
| 477 const char* gl_renderer, | 483 const char* gl_renderer, |
| 478 const char* gl_version, | 484 const char* gl_version, |
| 485 ContextType context_type, |
| 479 bool enable_es3) { | 486 bool enable_es3) { |
| 480 InSequence sequence; | 487 InSequence sequence; |
| 481 | 488 |
| 482 EXPECT_CALL(*gl, GetString(GL_VERSION)) | 489 EXPECT_CALL(*gl, GetString(GL_VERSION)) |
| 483 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) | 490 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) |
| 484 .RetiresOnSaturation(); | 491 .RetiresOnSaturation(); |
| 485 | 492 |
| 486 // Persistent storage is needed for the split extension string. | 493 // Persistent storage is needed for the split extension string. |
| 487 split_extensions_.clear(); | 494 split_extensions_.clear(); |
| 488 if (extensions) { | 495 if (extensions) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 507 .RetiresOnSaturation(); | 514 .RetiresOnSaturation(); |
| 508 } | 515 } |
| 509 | 516 |
| 510 EXPECT_CALL(*gl, GetString(GL_VERSION)) | 517 EXPECT_CALL(*gl, GetString(GL_VERSION)) |
| 511 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) | 518 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) |
| 512 .RetiresOnSaturation(); | 519 .RetiresOnSaturation(); |
| 513 EXPECT_CALL(*gl, GetString(GL_RENDERER)) | 520 EXPECT_CALL(*gl, GetString(GL_RENDERER)) |
| 514 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer))) | 521 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer))) |
| 515 .RetiresOnSaturation(); | 522 .RetiresOnSaturation(); |
| 516 | 523 |
| 524 if (!(context_type == CONTEXT_TYPE_WEBGL1 || |
| 525 context_type == CONTEXT_TYPE_OPENGLES2) && |
| 526 gl_info.is_es3_capable && enable_es3) { |
| 527 EXPECT_CALL(*gl, GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, _)) |
| 528 .WillOnce(SetArgPointee<1>(0)) |
| 529 .RetiresOnSaturation(); |
| 530 } |
| 531 |
| 517 if ((strstr(extensions, "GL_ARB_texture_float") || | 532 if ((strstr(extensions, "GL_ARB_texture_float") || |
| 518 gl_info.is_desktop_core_profile) || | 533 gl_info.is_desktop_core_profile) || |
| 519 (gl_info.is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) { | 534 (gl_info.is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) { |
| 520 static const GLuint tx_ids[] = {101, 102}; | 535 static const GLuint tx_ids[] = {101, 102}; |
| 521 static const GLuint fb_ids[] = {103, 104}; | 536 static const GLuint fb_ids[] = {103, 104}; |
| 522 const GLsizei width = 16; | 537 const GLsizei width = 16; |
| 523 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _)) | 538 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _)) |
| 524 .WillOnce(SetArgumentPointee<1>(fb_ids[0])) | 539 .WillOnce(SetArgumentPointee<1>(fb_ids[0])) |
| 525 .RetiresOnSaturation(); | 540 .RetiresOnSaturation(); |
| 526 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _)) | 541 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _)) |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 GLenum precision, | 1195 GLenum precision, |
| 1181 bool static_use, | 1196 bool static_use, |
| 1182 const std::string& name) { | 1197 const std::string& name) { |
| 1183 return ConstructShaderVariable<sh::OutputVariable>( | 1198 return ConstructShaderVariable<sh::OutputVariable>( |
| 1184 type, array_size, precision, static_use, name); | 1199 type, array_size, precision, static_use, name); |
| 1185 } | 1200 } |
| 1186 | 1201 |
| 1187 } // namespace gles2 | 1202 } // namespace gles2 |
| 1188 } // namespace gpu | 1203 } // namespace gpu |
| 1189 | 1204 |
| OLD | NEW |