Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 2208693003: Revert of cc: Make LayerTreeTests use a DelegatingRenderer and Display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/surface_layer_unittest.cc ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 #include "cc/layers/texture_layer_impl.h" 27 #include "cc/layers/texture_layer_impl.h"
28 #include "cc/output/context_provider.h" 28 #include "cc/output/context_provider.h"
29 #include "cc/resources/returned_resource.h" 29 #include "cc/resources/returned_resource.h"
30 #include "cc/test/fake_impl_task_runner_provider.h" 30 #include "cc/test/fake_impl_task_runner_provider.h"
31 #include "cc/test/fake_layer_tree_host_client.h" 31 #include "cc/test/fake_layer_tree_host_client.h"
32 #include "cc/test/fake_layer_tree_host_impl.h" 32 #include "cc/test/fake_layer_tree_host_impl.h"
33 #include "cc/test/fake_output_surface.h" 33 #include "cc/test/fake_output_surface.h"
34 #include "cc/test/layer_test_common.h" 34 #include "cc/test/layer_test_common.h"
35 #include "cc/test/layer_tree_test.h" 35 #include "cc/test/layer_tree_test.h"
36 #include "cc/test/stub_layer_tree_host_single_thread_client.h" 36 #include "cc/test/stub_layer_tree_host_single_thread_client.h"
37 #include "cc/test/test_delegating_output_surface.h"
38 #include "cc/test/test_task_graph_runner.h" 37 #include "cc/test/test_task_graph_runner.h"
39 #include "cc/test/test_web_graphics_context_3d.h" 38 #include "cc/test/test_web_graphics_context_3d.h"
40 #include "cc/trees/blocking_task_runner.h" 39 #include "cc/trees/blocking_task_runner.h"
41 #include "cc/trees/layer_tree_host.h" 40 #include "cc/trees/layer_tree_host.h"
42 #include "cc/trees/layer_tree_impl.h" 41 #include "cc/trees/layer_tree_impl.h"
43 #include "cc/trees/single_thread_proxy.h" 42 #include "cc/trees/single_thread_proxy.h"
44 #include "gpu/GLES2/gl2extchromium.h" 43 #include "gpu/GLES2/gl2extchromium.h"
45 #include "testing/gmock/include/gmock/gmock.h" 44 #include "testing/gmock/include/gmock/gmock.h"
46 #include "testing/gtest/include/gtest/gtest.h" 45 #include "testing/gtest/include/gtest/gtest.h"
47 46
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 main_thread_task_runner_.get()); 624 main_thread_task_runner_.get());
626 625
627 stop_capture.Signal(); 626 stop_capture.Signal();
628 Wait(main_thread_); 627 Wait(main_thread_);
629 628
630 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); 629 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_);
631 } 630 }
632 631
633 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { 632 class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
634 public: 633 public:
635 TextureLayerImplWithMailboxThreadedCallback() = default; 634 TextureLayerImplWithMailboxThreadedCallback()
636 635 : callback_count_(0),
637 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( 636 commit_count_(0) {}
638 scoped_refptr<ContextProvider> compositor_context_provider,
639 scoped_refptr<ContextProvider> worker_context_provider) override {
640 bool synchronous_composite =
641 !HasImplThread() &&
642 !layer_tree_host()->settings().single_thread_proxy_scheduler;
643 // Allow relaim resources for this test so that mailboxes in the display
644 // will be returned inside the commit that replaces them.
645 bool force_disable_reclaim_resources = false;
646 return base::MakeUnique<TestDelegatingOutputSurface>(
647 compositor_context_provider, std::move(worker_context_provider),
648 CreateDisplayOutputSurface(compositor_context_provider),
649 shared_bitmap_manager(), gpu_memory_buffer_manager(),
650 layer_tree_host()->settings().renderer_settings, ImplThreadTaskRunner(),
651 synchronous_composite, force_disable_reclaim_resources);
652 }
653 637
654 // Make sure callback is received on main and doesn't block the impl thread. 638 // Make sure callback is received on main and doesn't block the impl thread.
655 void ReleaseCallback(char mailbox_char, 639 void ReleaseCallback(const gpu::SyncToken& sync_token, bool lost_resource) {
656 const gpu::SyncToken& sync_token,
657 bool lost_resource) {
658 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 640 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
659 EXPECT_FALSE(lost_resource); 641 EXPECT_FALSE(lost_resource);
660 ++callback_count_; 642 ++callback_count_;
661 } 643 }
662 644
663 void SetMailbox(char mailbox_char) { 645 void SetMailbox(char mailbox_char) {
664 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 646 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
665 std::unique_ptr<SingleReleaseCallback> callback = 647 std::unique_ptr<SingleReleaseCallback> callback =
666 SingleReleaseCallback::Create(base::Bind( 648 SingleReleaseCallback::Create(base::Bind(
667 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, 649 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback,
668 base::Unretained(this), mailbox_char)); 650 base::Unretained(this)));
669 layer_->SetTextureMailbox( 651 layer_->SetTextureMailbox(
670 TextureMailbox(MailboxFromChar(mailbox_char), 652 TextureMailbox(MailboxFromChar(mailbox_char),
671 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)), 653 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)),
672 GL_TEXTURE_2D), 654 GL_TEXTURE_2D),
673 std::move(callback)); 655 std::move(callback));
674 // Damage the layer so we send a new frame with the new mailbox to the
675 // Display compositor.
676 layer_->SetNeedsDisplay();
677 } 656 }
678 657
679 void BeginTest() override { 658 void BeginTest() override {
680 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); 659 EXPECT_EQ(true, main_thread_.CalledOnValidThread());
681 660
682 gfx::Size bounds(100, 100); 661 gfx::Size bounds(100, 100);
683 root_ = Layer::Create(); 662 root_ = Layer::Create();
684 root_->SetBounds(bounds); 663 root_->SetBounds(bounds);
685 664
686 layer_ = TextureLayer::CreateForMailbox(nullptr); 665 layer_ = TextureLayer::CreateForMailbox(nullptr);
(...skipping 30 matching lines...) Expand all
717 layer_->SetBounds(gfx::Size()); 696 layer_->SetBounds(gfx::Size());
718 SetMailbox('4'); 697 SetMailbox('4');
719 break; 698 break;
720 case 3: 699 case 3:
721 EXPECT_EQ(3, callback_count_); 700 EXPECT_EQ(3, callback_count_);
722 // Case #4: release mailbox that was committed but never drawn. The 701 // Case #4: release mailbox that was committed but never drawn. The
723 // old mailbox should be released during the next commit. 702 // old mailbox should be released during the next commit.
724 layer_->SetTextureMailbox(TextureMailbox(), nullptr); 703 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
725 break; 704 break;
726 case 4: 705 case 4:
706 // With impl painting, the texture mailbox will still be on the impl
707 // thread when the commit finishes, because the layer is not drawble
708 // when it has no texture mailbox, and thus does not block the commit
709 // on activation. So, we wait for activation.
710 // TODO(danakj): fix this. crbug.com/277953
711 layer_tree_host()->SetNeedsCommit();
712 break;
713 case 5:
727 EXPECT_EQ(4, callback_count_); 714 EXPECT_EQ(4, callback_count_);
728 // Restore a mailbox for the next step. 715 // Restore a mailbox for the next step.
729 SetMailbox('5'); 716 SetMailbox('5');
730 break; 717 break;
731 case 5: 718 case 6:
732 // Case #5: remove layer from tree. Callback should *not* be called, the 719 // Case #5: remove layer from tree. Callback should *not* be called, the
733 // mailbox is returned to the main thread. 720 // mailbox is returned to the main thread.
734 EXPECT_EQ(4, callback_count_); 721 EXPECT_EQ(4, callback_count_);
735 layer_->RemoveFromParent(); 722 layer_->RemoveFromParent();
736 break; 723 break;
737 case 6: 724 case 7:
725 // With impl painting, the texture mailbox will still be on the impl
726 // thread when the commit finishes, because the layer is not around to
727 // block the commit on activation anymore. So, we wait for activation.
728 // TODO(danakj): fix this. crbug.com/277953
729 layer_tree_host()->SetNeedsCommit();
730 break;
731 case 8:
738 EXPECT_EQ(4, callback_count_); 732 EXPECT_EQ(4, callback_count_);
739 // Resetting the mailbox will call the callback now. 733 // Resetting the mailbox will call the callback now.
740 layer_->SetTextureMailbox(TextureMailbox(), nullptr); 734 layer_->SetTextureMailbox(TextureMailbox(), nullptr);
741 EXPECT_EQ(5, callback_count_); 735 EXPECT_EQ(5, callback_count_);
742 EndTest(); 736 EndTest();
743 break; 737 break;
744 default: 738 default:
745 NOTREACHED(); 739 NOTREACHED();
746 break; 740 break;
747 } 741 }
748 } 742 }
749 743
750 void AfterTest() override {} 744 void AfterTest() override {}
751 745
752 private: 746 private:
753 base::ThreadChecker main_thread_; 747 base::ThreadChecker main_thread_;
754 int callback_count_ = 0; 748 int callback_count_;
755 int commit_count_ = 0; 749 int commit_count_;
756 scoped_refptr<Layer> root_; 750 scoped_refptr<Layer> root_;
757 scoped_refptr<TextureLayer> layer_; 751 scoped_refptr<TextureLayer> layer_;
758 }; 752 };
759 753
760 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 754 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
761 TextureLayerImplWithMailboxThreadedCallback); 755 TextureLayerImplWithMailboxThreadedCallback);
762 756
763 757
764 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { 758 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
765 protected: 759 protected:
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 int callback_count_; 1449 int callback_count_;
1456 scoped_refptr<Layer> root_; 1450 scoped_refptr<Layer> root_;
1457 scoped_refptr<TextureLayer> layer_; 1451 scoped_refptr<TextureLayer> layer_;
1458 }; 1452 };
1459 1453
1460 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1454 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1461 TextureLayerWithMailboxImplThreadDeleted); 1455 TextureLayerWithMailboxImplThreadDeleted);
1462 1456
1463 } // namespace 1457 } // namespace
1464 } // namespace cc 1458 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/surface_layer_unittest.cc ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698