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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 internal_format, | 65 internal_format, |
66 width, | 66 width, |
67 height, | 67 height, |
68 depth, | 68 depth, |
69 border, | 69 border, |
70 format, | 70 format, |
71 type, | 71 type, |
72 cleared); | 72 cleared); |
73 } | 73 } |
74 | 74 |
| 75 void SetLevelCleared(Texture* texture, |
| 76 GLenum target, |
| 77 GLint level, |
| 78 bool cleared) { |
| 79 texture->SetLevelCleared(target, level, cleared); |
| 80 } |
| 81 |
75 GLenum SetParameter(Texture* texture, GLenum pname, GLint param) { | 82 GLenum SetParameter(Texture* texture, GLenum pname, GLint param) { |
76 return texture->SetParameteri(feature_info_.get(), pname, param); | 83 return texture->SetParameteri(feature_info_.get(), pname, param); |
77 } | 84 } |
78 | 85 |
79 void DestroyTexture(Texture* texture) { | 86 void DestroyTexture(Texture* texture) { |
80 delete texture; | 87 delete texture; |
81 } | 88 } |
82 | 89 |
83 scoped_refptr<MailboxManager> manager_; | 90 scoped_refptr<MailboxManager> manager_; |
84 | 91 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 DestroyTexture(tmp_texture); | 543 DestroyTexture(tmp_texture); |
537 | 544 |
538 DestroyTexture(old_texture); | 545 DestroyTexture(old_texture); |
539 DestroyTexture(texture); | 546 DestroyTexture(texture); |
540 DestroyTexture(new_texture); | 547 DestroyTexture(new_texture); |
541 | 548 |
542 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); | 549 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); |
543 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); | 550 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); |
544 } | 551 } |
545 | 552 |
| 553 TEST_F(MailboxManagerSyncTest, ClearedStateSynced) { |
| 554 const GLuint kNewTextureId = 1234; |
| 555 |
| 556 Texture* texture = DefineTexture(); |
| 557 EXPECT_TRUE(texture->SafeToRenderFrom()); |
| 558 |
| 559 Mailbox name = Mailbox::Generate(); |
| 560 |
| 561 manager_->ProduceTexture(name, texture); |
| 562 EXPECT_EQ(texture, manager_->ConsumeTexture(name)); |
| 563 |
| 564 // Synchronize |
| 565 manager_->PushTextureUpdates(0); |
| 566 manager2_->PullTextureUpdates(0); |
| 567 |
| 568 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 569 .WillOnce(SetArgPointee<1>(kNewTextureId)); |
| 570 SetupUpdateTexParamExpectations( |
| 571 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); |
| 572 Texture* new_texture = manager2_->ConsumeTexture(name); |
| 573 EXPECT_FALSE(new_texture == NULL); |
| 574 EXPECT_NE(texture, new_texture); |
| 575 EXPECT_EQ(kNewTextureId, new_texture->service_id()); |
| 576 EXPECT_TRUE(texture->SafeToRenderFrom()); |
| 577 |
| 578 // Change cleared to false. |
| 579 SetLevelCleared(texture, texture->target(), 0, false); |
| 580 EXPECT_FALSE(texture->SafeToRenderFrom()); |
| 581 |
| 582 // Synchronize |
| 583 manager_->PushTextureUpdates(0); |
| 584 SetupUpdateTexParamExpectations( |
| 585 kNewTextureId, GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT); |
| 586 manager2_->PullTextureUpdates(0); |
| 587 |
| 588 // Cleared state should be synced. |
| 589 EXPECT_FALSE(new_texture->SafeToRenderFrom()); |
| 590 |
| 591 DestroyTexture(texture); |
| 592 DestroyTexture(new_texture); |
| 593 |
| 594 EXPECT_EQ(NULL, manager_->ConsumeTexture(name)); |
| 595 EXPECT_EQ(NULL, manager2_->ConsumeTexture(name)); |
| 596 } |
| 597 |
546 // Putting the same texture into multiple mailboxes should result in sharing | 598 // Putting the same texture into multiple mailboxes should result in sharing |
547 // only a single texture also within a synchronized manager instance. | 599 // only a single texture also within a synchronized manager instance. |
548 TEST_F(MailboxManagerSyncTest, SharedThroughMultipleMailboxes) { | 600 TEST_F(MailboxManagerSyncTest, SharedThroughMultipleMailboxes) { |
549 const GLuint kNewTextureId = 1234; | 601 const GLuint kNewTextureId = 1234; |
550 InSequence sequence; | 602 InSequence sequence; |
551 | 603 |
552 Texture* texture = DefineTexture(); | 604 Texture* texture = DefineTexture(); |
553 Mailbox name1 = Mailbox::Generate(); | 605 Mailbox name1 = Mailbox::Generate(); |
554 Mailbox name2 = Mailbox::Generate(); | 606 Mailbox name2 = Mailbox::Generate(); |
555 | 607 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 672 } |
621 | 673 |
622 // TODO: Produce incomplete texture | 674 // TODO: Produce incomplete texture |
623 | 675 |
624 // TODO: Texture::level_infos_[][].size() | 676 // TODO: Texture::level_infos_[][].size() |
625 | 677 |
626 // TODO: unsupported targets and formats | 678 // TODO: unsupported targets and formats |
627 | 679 |
628 } // namespace gles2 | 680 } // namespace gles2 |
629 } // namespace gpu | 681 } // namespace gpu |
OLD | NEW |