| 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 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 static const GLuint kQueriesStartId = 1; | 386 static const GLuint kQueriesStartId = 1; |
| 387 static const GLuint kVertexArraysStartId = 1; | 387 static const GLuint kVertexArraysStartId = 1; |
| 388 | 388 |
| 389 typedef MockTransferBuffer::ExpectedMemoryInfo ExpectedMemoryInfo; | 389 typedef MockTransferBuffer::ExpectedMemoryInfo ExpectedMemoryInfo; |
| 390 | 390 |
| 391 class TestContext { | 391 class TestContext { |
| 392 public: | 392 public: |
| 393 TestContext() : commands_(NULL), token_(0) {} | 393 TestContext() : commands_(NULL), token_(0) {} |
| 394 | 394 |
| 395 bool Initialize(ShareGroup* share_group, | 395 bool Initialize(ShareGroup* share_group, |
| 396 bool bind_generates_resource, | 396 bool bind_generates_resource_client, |
| 397 bool bind_generates_resource_service, |
| 397 bool lose_context_when_out_of_memory) { | 398 bool lose_context_when_out_of_memory) { |
| 398 command_buffer_.reset(new StrictMock<MockClientCommandBuffer>()); | 399 command_buffer_.reset(new StrictMock<MockClientCommandBuffer>()); |
| 399 if (!command_buffer_->Initialize()) | 400 if (!command_buffer_->Initialize()) |
| 400 return false; | 401 return false; |
| 401 | 402 |
| 402 transfer_buffer_.reset( | 403 transfer_buffer_.reset( |
| 403 new MockTransferBuffer(command_buffer_.get(), | 404 new MockTransferBuffer(command_buffer_.get(), |
| 404 kTransferBufferSize, | 405 kTransferBufferSize, |
| 405 GLES2Implementation::kStartingOffset, | 406 GLES2Implementation::kStartingOffset, |
| 406 GLES2Implementation::kAlignment)); | 407 GLES2Implementation::kAlignment)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 421 int_state.max_renderbuffer_size = kMaxRenderbufferSize; | 422 int_state.max_renderbuffer_size = kMaxRenderbufferSize; |
| 422 int_state.max_texture_image_units = kMaxTextureImageUnits; | 423 int_state.max_texture_image_units = kMaxTextureImageUnits; |
| 423 int_state.max_texture_size = kMaxTextureSize; | 424 int_state.max_texture_size = kMaxTextureSize; |
| 424 int_state.max_varying_vectors = kMaxVaryingVectors; | 425 int_state.max_varying_vectors = kMaxVaryingVectors; |
| 425 int_state.max_vertex_attribs = kMaxVertexAttribs; | 426 int_state.max_vertex_attribs = kMaxVertexAttribs; |
| 426 int_state.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; | 427 int_state.max_vertex_texture_image_units = kMaxVertexTextureImageUnits; |
| 427 int_state.max_vertex_uniform_vectors = kMaxVertexUniformVectors; | 428 int_state.max_vertex_uniform_vectors = kMaxVertexUniformVectors; |
| 428 int_state.num_compressed_texture_formats = kNumCompressedTextureFormats; | 429 int_state.num_compressed_texture_formats = kNumCompressedTextureFormats; |
| 429 int_state.num_shader_binary_formats = kNumShaderBinaryFormats; | 430 int_state.num_shader_binary_formats = kNumShaderBinaryFormats; |
| 430 int_state.bind_generates_resource_chromium = | 431 int_state.bind_generates_resource_chromium = |
| 431 bind_generates_resource ? 1 : 0; | 432 bind_generates_resource_service ? 1 : 0; |
| 432 | 433 |
| 433 // This just happens to work for now because IntState has 1 GLint per | 434 // This just happens to work for now because IntState has 1 GLint per |
| 434 // state. | 435 // state. |
| 435 // If IntState gets more complicated this code will need to get more | 436 // If IntState gets more complicated this code will need to get more |
| 436 // complicated. | 437 // complicated. |
| 437 ExpectedMemoryInfo mem1 = transfer_buffer_->GetExpectedMemory( | 438 ExpectedMemoryInfo mem1 = transfer_buffer_->GetExpectedMemory( |
| 438 sizeof(GLES2Implementation::GLStaticState::IntState) * 2 + | 439 sizeof(GLES2Implementation::GLStaticState::IntState) * 2 + |
| 439 sizeof(cmds::GetShaderPrecisionFormat::Result) * 12); | 440 sizeof(cmds::GetShaderPrecisionFormat::Result) * 12); |
| 440 | 441 |
| 441 { | 442 { |
| 442 InSequence sequence; | 443 InSequence sequence; |
| 443 | 444 |
| 444 EXPECT_CALL(*command_buffer_, OnFlush()) | 445 EXPECT_CALL(*command_buffer_, OnFlush()) |
| 445 .WillOnce(SetMemory(mem1.ptr + sizeof(int_state), int_state)) | 446 .WillOnce(SetMemory(mem1.ptr + sizeof(int_state), int_state)) |
| 446 .RetiresOnSaturation(); | 447 .RetiresOnSaturation(); |
| 447 GetNextToken(); // eat the token that starting up will use. | 448 GetNextToken(); // eat the token that starting up will use. |
| 448 | 449 |
| 449 gl_.reset(new GLES2Implementation(helper_.get(), | 450 gl_.reset(new GLES2Implementation(helper_.get(), |
| 450 share_group, | 451 share_group, |
| 451 transfer_buffer_.get(), | 452 transfer_buffer_.get(), |
| 452 bind_generates_resource, | 453 bind_generates_resource_client, |
| 453 lose_context_when_out_of_memory, | 454 lose_context_when_out_of_memory, |
| 454 gpu_control_.get())); | 455 gpu_control_.get())); |
| 455 | 456 |
| 456 if (!gl_->Initialize(kTransferBufferSize, | 457 if (!gl_->Initialize(kTransferBufferSize, |
| 457 kTransferBufferSize, | 458 kTransferBufferSize, |
| 458 kTransferBufferSize, | 459 kTransferBufferSize, |
| 459 GLES2Implementation::kNoLimit)) | 460 GLES2Implementation::kNoLimit)) |
| 460 return false; | 461 return false; |
| 461 } | 462 } |
| 462 | 463 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 bind_generates_resource_service(true), | 531 bind_generates_resource_service(true), |
| 531 lose_context_when_out_of_memory(false) {} | 532 lose_context_when_out_of_memory(false) {} |
| 532 | 533 |
| 533 bool bind_generates_resource_client; | 534 bool bind_generates_resource_client; |
| 534 bool bind_generates_resource_service; | 535 bool bind_generates_resource_service; |
| 535 bool lose_context_when_out_of_memory; | 536 bool lose_context_when_out_of_memory; |
| 536 }; | 537 }; |
| 537 | 538 |
| 538 bool Initialize(const ContextInitOptions& init_options) { | 539 bool Initialize(const ContextInitOptions& init_options) { |
| 539 bool success = true; | 540 bool success = true; |
| 540 share_group_ = new ShareGroup(init_options.bind_generates_resource_service); | 541 share_group_ = new ShareGroup(init_options.bind_generates_resource_client); |
| 541 | 542 |
| 542 for (int i = 0; i < kNumTestContexts; i++) { | 543 for (int i = 0; i < kNumTestContexts; i++) { |
| 543 if (!test_contexts_[i].Initialize( | 544 if (!test_contexts_[i].Initialize( |
| 544 share_group_.get(), | 545 share_group_.get(), |
| 545 init_options.bind_generates_resource_client, | 546 init_options.bind_generates_resource_client, |
| 547 init_options.bind_generates_resource_service, |
| 546 init_options.lose_context_when_out_of_memory)) | 548 init_options.lose_context_when_out_of_memory)) |
| 547 success = false; | 549 success = false; |
| 548 } | 550 } |
| 549 | 551 |
| 550 // Default to test context 0. | 552 // Default to test context 0. |
| 551 gpu_control_ = test_contexts_[0].gpu_control_.get(); | 553 gpu_control_ = test_contexts_[0].gpu_control_.get(); |
| 552 helper_ = test_contexts_[0].helper_.get(); | 554 helper_ = test_contexts_[0].helper_.get(); |
| 553 transfer_buffer_ = test_contexts_[0].transfer_buffer_.get(); | 555 transfer_buffer_ = test_contexts_[0].transfer_buffer_.get(); |
| 554 gl_ = test_contexts_[0].gl_.get(); | 556 gl_ = test_contexts_[0].gl_.get(); |
| 555 commands_ = test_contexts_[0].commands_; | 557 commands_ = test_contexts_[0].commands_; |
| (...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3403 ContextInitOptions init_options; | 3405 ContextInitOptions init_options; |
| 3404 init_options.bind_generates_resource_client = true; | 3406 init_options.bind_generates_resource_client = true; |
| 3405 init_options.bind_generates_resource_service = false; | 3407 init_options.bind_generates_resource_service = false; |
| 3406 EXPECT_FALSE(Initialize(init_options)); | 3408 EXPECT_FALSE(Initialize(init_options)); |
| 3407 } | 3409 } |
| 3408 | 3410 |
| 3409 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3411 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 3410 | 3412 |
| 3411 } // namespace gles2 | 3413 } // namespace gles2 |
| 3412 } // namespace gpu | 3414 } // namespace gpu |
| OLD | NEW |