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