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 <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 transfer_buffer_.reset( | 397 transfer_buffer_.reset( |
398 new MockTransferBuffer(command_buffer_.get(), | 398 new MockTransferBuffer(command_buffer_.get(), |
399 kTransferBufferSize, | 399 kTransferBufferSize, |
400 GLES2Implementation::kStartingOffset, | 400 GLES2Implementation::kStartingOffset, |
401 GLES2Implementation::kAlignment)); | 401 GLES2Implementation::kAlignment)); |
402 | 402 |
403 helper_.reset(new GLES2CmdHelper(command_buffer())); | 403 helper_.reset(new GLES2CmdHelper(command_buffer())); |
404 helper_->Initialize(kCommandBufferSizeBytes); | 404 helper_->Initialize(kCommandBufferSizeBytes); |
405 | 405 |
406 gpu_control_.reset(new StrictMock<MockClientGpuControl>()); | 406 gpu_control_.reset(new StrictMock<MockClientGpuControl>()); |
407 EXPECT_CALL(*gpu_control_, GetCapabilities()) | |
408 .WillOnce(testing::Return(Capabilities())); | |
409 | 407 |
410 GLES2Implementation::GLStaticState state; | 408 GLES2Implementation::GLStaticState state; |
411 GLES2Implementation::GLStaticState::IntState& int_state = state.int_state; | 409 GLES2Implementation::GLStaticState::IntState& int_state = state.int_state; |
412 int_state.max_combined_texture_image_units = | 410 int_state.max_combined_texture_image_units = |
413 kMaxCombinedTextureImageUnits; | 411 kMaxCombinedTextureImageUnits; |
414 int_state.max_cube_map_texture_size = kMaxCubeMapTextureSize; | 412 int_state.max_cube_map_texture_size = kMaxCubeMapTextureSize; |
415 int_state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; | 413 int_state.max_fragment_uniform_vectors = kMaxFragmentUniformVectors; |
416 int_state.max_renderbuffer_size = kMaxRenderbufferSize; | 414 int_state.max_renderbuffer_size = kMaxRenderbufferSize; |
417 int_state.max_texture_image_units = kMaxTextureImageUnits; | 415 int_state.max_texture_image_units = kMaxTextureImageUnits; |
418 int_state.max_texture_size = kMaxTextureSize; | 416 int_state.max_texture_size = kMaxTextureSize; |
(...skipping 18 matching lines...) Expand all Loading... |
437 EXPECT_CALL(*command_buffer_, OnFlush()) | 435 EXPECT_CALL(*command_buffer_, OnFlush()) |
438 .WillOnce(SetMemory(mem1.ptr + sizeof(int_state), int_state)) | 436 .WillOnce(SetMemory(mem1.ptr + sizeof(int_state), int_state)) |
439 .RetiresOnSaturation(); | 437 .RetiresOnSaturation(); |
440 GetNextToken(); // eat the token that starting up will use. | 438 GetNextToken(); // eat the token that starting up will use. |
441 | 439 |
442 gl_.reset( | 440 gl_.reset( |
443 new GLES2Implementation(helper_.get(), | 441 new GLES2Implementation(helper_.get(), |
444 share_group, | 442 share_group, |
445 transfer_buffer_.get(), | 443 transfer_buffer_.get(), |
446 bind_generates_resource, | 444 bind_generates_resource, |
447 gpu_control_.get())); | 445 gpu_control_.get(), |
| 446 Capabilities())); |
448 ASSERT_TRUE(gl_->Initialize(kTransferBufferSize, | 447 ASSERT_TRUE(gl_->Initialize(kTransferBufferSize, |
449 kTransferBufferSize, | 448 kTransferBufferSize, |
450 kTransferBufferSize, | 449 kTransferBufferSize, |
451 GLES2Implementation::kNoLimit)); | 450 GLES2Implementation::kNoLimit)); |
452 } | 451 } |
453 | 452 |
454 EXPECT_CALL(*command_buffer_, OnFlush()).Times(1).RetiresOnSaturation(); | 453 EXPECT_CALL(*command_buffer_, OnFlush()).Times(1).RetiresOnSaturation(); |
455 helper_->CommandBufferHelper::Finish(); | 454 helper_->CommandBufferHelper::Finish(); |
456 ::testing::Mock::VerifyAndClearExpectations(gl_.get()); | 455 ::testing::Mock::VerifyAndClearExpectations(gl_.get()); |
457 | 456 |
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 } | 2673 } |
2675 | 2674 |
2676 TEST_F(GLES2ImplementationTest, GetString) { | 2675 TEST_F(GLES2ImplementationTest, GetString) { |
2677 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2676 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
2678 const Str7 kString = {"foobar"}; | 2677 const Str7 kString = {"foobar"}; |
2679 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into | 2678 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into |
2680 // GLES2Implementation. | 2679 // GLES2Implementation. |
2681 const char* expected_str = | 2680 const char* expected_str = |
2682 "foobar " | 2681 "foobar " |
2683 "GL_CHROMIUM_flipy " | 2682 "GL_CHROMIUM_flipy " |
| 2683 "GL_CHROMIUM_map_image " |
2684 "GL_EXT_unpack_subimage"; | 2684 "GL_EXT_unpack_subimage"; |
2685 const char kBad = 0x12; | 2685 const char kBad = 0x12; |
2686 struct Cmds { | 2686 struct Cmds { |
2687 cmd::SetBucketSize set_bucket_size1; | 2687 cmd::SetBucketSize set_bucket_size1; |
2688 cmds::GetString get_string; | 2688 cmds::GetString get_string; |
2689 cmd::GetBucketStart get_bucket_start; | 2689 cmd::GetBucketStart get_bucket_start; |
2690 cmd::SetToken set_token1; | 2690 cmd::SetToken set_token1; |
2691 cmd::SetBucketSize set_bucket_size2; | 2691 cmd::SetBucketSize set_bucket_size2; |
2692 }; | 2692 }; |
2693 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 2693 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3097 Cmds expected; | 3097 Cmds expected; |
3098 expected.cmd.Init(GL_TEXTURE_2D, mailbox.name); | 3098 expected.cmd.Init(GL_TEXTURE_2D, mailbox.name); |
3099 gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 3099 gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
3100 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 3100 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
3101 } | 3101 } |
3102 | 3102 |
3103 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 3103 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
3104 | 3104 |
3105 } // namespace gles2 | 3105 } // namespace gles2 |
3106 } // namespace gpu | 3106 } // namespace gpu |
OLD | NEW |