| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
| 6 #include "gpu/command_buffer/service/gpu_service_test.h" | 6 #include "gpu/command_buffer/service/gpu_service_test.h" |
| 7 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 7 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
| 8 #include "gpu/command_buffer/service/mailbox_manager_sync.h" | 8 #include "gpu/command_buffer/service/mailbox_manager_sync.h" |
| 9 #include "gpu/command_buffer/service/texture_manager.h" | 9 #include "gpu/command_buffer/service/texture_manager.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // Cleared state should be synced. | 588 // Cleared state should be synced. |
| 589 EXPECT_FALSE(new_texture->SafeToRenderFrom()); | 589 EXPECT_FALSE(new_texture->SafeToRenderFrom()); |
| 590 | 590 |
| 591 DestroyTexture(texture); | 591 DestroyTexture(texture); |
| 592 DestroyTexture(new_texture); | 592 DestroyTexture(new_texture); |
| 593 | 593 |
| 594 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); | 594 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); |
| 595 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); | 595 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); |
| 596 } | 596 } |
| 597 | 597 |
| 598 TEST_F(MailboxManagerSyncTest, SyncIncompleteTexture) { |
| 599 const GLuint kNewTextureId = 1234; |
| 600 |
| 601 // Create but not define texture. |
| 602 Texture* texture = CreateTexture(); |
| 603 SetTarget(texture, GL_TEXTURE_2D, 1); |
| 604 EXPECT_FALSE(texture->IsDefined()); |
| 605 |
| 606 Mailbox name = Mailbox::Generate(); |
| 607 manager_->ProduceTexture(name, texture); |
| 608 EXPECT_EQ(texture, manager_->ConsumeTexture(name)); |
| 609 |
| 610 // Synchronize |
| 611 manager_->PushTextureUpdates(0); |
| 612 manager2_->PullTextureUpdates(0); |
| 613 |
| 614 // Should sync to new texture which is not defined. |
| 615 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 616 .WillOnce(SetArgPointee<1>(kNewTextureId)); |
| 617 SetupUpdateTexParamExpectations(kNewTextureId, texture->min_filter(), |
| 618 texture->mag_filter(), texture->wrap_s(), |
| 619 texture->wrap_t()); |
| 620 Texture* new_texture = manager2_->ConsumeTexture(name); |
| 621 ASSERT_TRUE(new_texture); |
| 622 EXPECT_NE(texture, new_texture); |
| 623 EXPECT_EQ(kNewTextureId, new_texture->service_id()); |
| 624 EXPECT_FALSE(new_texture->IsDefined()); |
| 625 |
| 626 // Change cleared to false. |
| 627 SetLevelInfo(texture, |
| 628 GL_TEXTURE_2D, |
| 629 0, |
| 630 GL_RGBA, |
| 631 1, |
| 632 1, |
| 633 1, |
| 634 0, |
| 635 GL_RGBA, |
| 636 GL_UNSIGNED_BYTE, |
| 637 true); |
| 638 SetParameter(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 639 SetParameter(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 640 EXPECT_TRUE(texture->IsDefined()); |
| 641 |
| 642 // Synchronize |
| 643 manager_->PushTextureUpdates(0); |
| 644 SetupUpdateTexParamExpectations( |
| 645 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); |
| 646 manager2_->PullTextureUpdates(0); |
| 647 |
| 648 // Cleared state should be synced. |
| 649 EXPECT_TRUE(new_texture->IsDefined()); |
| 650 |
| 651 DestroyTexture(texture); |
| 652 DestroyTexture(new_texture); |
| 653 |
| 654 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); |
| 655 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); |
| 656 } |
| 657 |
| 598 // Putting the same texture into multiple mailboxes should result in sharing | 658 // Putting the same texture into multiple mailboxes should result in sharing |
| 599 // only a single texture also within a synchronized manager instance. | 659 // only a single texture also within a synchronized manager instance. |
| 600 TEST_F(MailboxManagerSyncTest, SharedThroughMultipleMailboxes) { | 660 TEST_F(MailboxManagerSyncTest, SharedThroughMultipleMailboxes) { |
| 601 const GLuint kNewTextureId = 1234; | 661 const GLuint kNewTextureId = 1234; |
| 602 InSequence sequence; | 662 InSequence sequence; |
| 603 | 663 |
| 604 Texture* texture = DefineTexture(); | 664 Texture* texture = DefineTexture(); |
| 605 Mailbox name1 = Mailbox::Generate(); | 665 Mailbox name1 = Mailbox::Generate(); |
| 606 Mailbox name2 = Mailbox::Generate(); | 666 Mailbox name2 = Mailbox::Generate(); |
| 607 | 667 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 manager2_->PullTextureUpdates(0); | 724 manager2_->PullTextureUpdates(0); |
| 665 | 725 |
| 666 // name should return the original texture, and not texture2 or a new one. | 726 // name should return the original texture, and not texture2 or a new one. |
| 667 EXPECT_EQ(new_texture, manager2_->ConsumeTexture(name)); | 727 EXPECT_EQ(new_texture, manager2_->ConsumeTexture(name)); |
| 668 | 728 |
| 669 DestroyTexture(texture1); | 729 DestroyTexture(texture1); |
| 670 DestroyTexture(texture2); | 730 DestroyTexture(texture2); |
| 671 DestroyTexture(new_texture); | 731 DestroyTexture(new_texture); |
| 672 } | 732 } |
| 673 | 733 |
| 674 // TODO: Produce incomplete texture | |
| 675 | |
| 676 // TODO: Texture::level_infos_[][].size() | 734 // TODO: Texture::level_infos_[][].size() |
| 677 | 735 |
| 678 // TODO: unsupported targets and formats | 736 // TODO: unsupported targets and formats |
| 679 | 737 |
| 680 } // namespace gles2 | 738 } // namespace gles2 |
| 681 } // namespace gpu | 739 } // namespace gpu |
| OLD | NEW |