OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/layers/texture_layer.h" | 5 #include "cc/layers/texture_layer.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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { | 636 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { |
637 public: | 637 public: |
638 TextureLayerImplWithMailboxThreadedCallback() = default; | 638 TextureLayerImplWithMailboxThreadedCallback() = default; |
639 | 639 |
640 std::unique_ptr<TestCompositorFrameSink> CreateCompositorFrameSink( | 640 std::unique_ptr<TestCompositorFrameSink> CreateCompositorFrameSink( |
641 scoped_refptr<ContextProvider> compositor_context_provider, | 641 scoped_refptr<ContextProvider> compositor_context_provider, |
642 scoped_refptr<ContextProvider> worker_context_provider) override { | 642 scoped_refptr<ContextProvider> worker_context_provider) override { |
643 bool synchronous_composite = | 643 bool synchronous_composite = |
644 !HasImplThread() && | 644 !HasImplThread() && |
645 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; | 645 !layer_tree_host()->GetSettings().single_thread_proxy_scheduler; |
| 646 // Allow relaim resources for this test so that mailboxes in the display |
| 647 // will be returned inside the commit that replaces them. |
| 648 bool force_disable_reclaim_resources = false; |
646 return base::MakeUnique<TestCompositorFrameSink>( | 649 return base::MakeUnique<TestCompositorFrameSink>( |
647 compositor_context_provider, std::move(worker_context_provider), | 650 compositor_context_provider, std::move(worker_context_provider), |
648 shared_bitmap_manager(), gpu_memory_buffer_manager(), | 651 shared_bitmap_manager(), gpu_memory_buffer_manager(), |
649 layer_tree_host()->GetSettings().renderer_settings, | 652 layer_tree_host()->GetSettings().renderer_settings, |
650 ImplThreadTaskRunner(), synchronous_composite); | 653 ImplThreadTaskRunner(), synchronous_composite, |
| 654 force_disable_reclaim_resources); |
651 } | 655 } |
652 | 656 |
653 // Make sure callback is received on main and doesn't block the impl thread. | 657 // Make sure callback is received on main and doesn't block the impl thread. |
654 void ReleaseCallback(char mailbox_char, | 658 void ReleaseCallback(char mailbox_char, |
655 const gpu::SyncToken& sync_token, | 659 const gpu::SyncToken& sync_token, |
656 bool lost_resource) { | 660 bool lost_resource) { |
657 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 661 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
658 EXPECT_FALSE(lost_resource); | 662 EXPECT_FALSE(lost_resource); |
659 ++callback_count_; | 663 ++callback_count_; |
660 } | 664 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 EXPECT_EQ(0, callback_count_); | 697 EXPECT_EQ(0, callback_count_); |
694 | 698 |
695 // Case #1: change mailbox before the commit. The old mailbox should be | 699 // Case #1: change mailbox before the commit. The old mailbox should be |
696 // released immediately. | 700 // released immediately. |
697 SetMailbox('2'); | 701 SetMailbox('2'); |
698 EXPECT_EQ(1, callback_count_); | 702 EXPECT_EQ(1, callback_count_); |
699 PostSetNeedsCommitToMainThread(); | 703 PostSetNeedsCommitToMainThread(); |
700 } | 704 } |
701 | 705 |
702 void DidCommit() override { | 706 void DidCommit() override { |
703 ++total_commit_count_; | 707 ++commit_count_; |
704 if (total_commit_count_ % 2) { | 708 switch (commit_count_) { |
705 // Perform an extra commit after each meaningful commit to reclaim | |
706 // resources. | |
707 PostSetNeedsCommitToMainThread(); | |
708 return; | |
709 } | |
710 | |
711 ++meaningful_commit_count_; | |
712 switch (meaningful_commit_count_) { | |
713 case 1: | 709 case 1: |
714 // Case #2: change mailbox after the commit (and draw), where the | 710 // Case #2: change mailbox after the commit (and draw), where the |
715 // layer draws. The old mailbox should be released during the next | 711 // layer draws. The old mailbox should be released during the next |
716 // commit. | 712 // commit. |
717 SetMailbox('3'); | 713 SetMailbox('3'); |
718 EXPECT_EQ(1, callback_count_); | 714 EXPECT_EQ(1, callback_count_); |
719 break; | 715 break; |
720 case 2: | 716 case 2: |
721 EXPECT_EQ(2, callback_count_); | 717 EXPECT_EQ(2, callback_count_); |
722 // Case #3: change mailbox when the layer doesn't draw. The old | 718 // Case #3: change mailbox when the layer doesn't draw. The old |
(...skipping 29 matching lines...) Expand all Loading... |
752 NOTREACHED(); | 748 NOTREACHED(); |
753 break; | 749 break; |
754 } | 750 } |
755 } | 751 } |
756 | 752 |
757 void AfterTest() override {} | 753 void AfterTest() override {} |
758 | 754 |
759 private: | 755 private: |
760 base::ThreadChecker main_thread_; | 756 base::ThreadChecker main_thread_; |
761 int callback_count_ = 0; | 757 int callback_count_ = 0; |
762 int total_commit_count_ = 0; | 758 int commit_count_ = 0; |
763 int meaningful_commit_count_ = 0; | |
764 scoped_refptr<Layer> root_; | 759 scoped_refptr<Layer> root_; |
765 scoped_refptr<TextureLayer> layer_; | 760 scoped_refptr<TextureLayer> layer_; |
766 }; | 761 }; |
767 | 762 |
768 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback); | 763 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback); |
769 | 764 |
770 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { | 765 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { |
771 protected: | 766 protected: |
772 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} | 767 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} |
773 | 768 |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 base::ThreadChecker main_thread_; | 1454 base::ThreadChecker main_thread_; |
1460 int callback_count_; | 1455 int callback_count_; |
1461 scoped_refptr<Layer> root_; | 1456 scoped_refptr<Layer> root_; |
1462 scoped_refptr<TextureLayer> layer_; | 1457 scoped_refptr<TextureLayer> layer_; |
1463 }; | 1458 }; |
1464 | 1459 |
1465 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerWithMailboxImplThreadDeleted); | 1460 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerWithMailboxImplThreadDeleted); |
1466 | 1461 |
1467 } // namespace | 1462 } // namespace |
1468 } // namespace cc | 1463 } // namespace cc |
OLD | NEW |