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

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

Issue 2729183002: Fixing flakiness of TextureLayerMailboxIsActivatedDuringCommit (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 scoped_refptr<Layer> root_; 782 scoped_refptr<Layer> root_;
783 scoped_refptr<TextureLayer> layer_; 783 scoped_refptr<TextureLayer> layer_;
784 }; 784 };
785 785
786 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback); 786 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback);
787 787
788 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { 788 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest {
789 protected: 789 protected:
790 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} 790 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {}
791 791
792 static void ReleaseCallback(const gpu::SyncToken& original_sync_token, 792 void ReleaseCallback(const gpu::SyncToken& original_sync_token,
793 const gpu::SyncToken& release_sync_token, 793 const gpu::SyncToken& release_sync_token,
794 bool lost_resource) {} 794 bool lost_resource) {
795 released_count_++;
796 switch (released_count_) {
797 case 1:
798 break;
799 case 2:
800 EXPECT_EQ(3, layer_tree_host()->SourceFrameNumber());
801 EndTest();
802 break;
803 default:
804 NOTREACHED();
805 }
806 }
795 807
796 void SetMailbox(char mailbox_char) { 808 void SetMailbox(char mailbox_char) {
797 const gpu::SyncToken sync_token = 809 const gpu::SyncToken sync_token =
798 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char)); 810 SyncTokenFromUInt(static_cast<uint32_t>(mailbox_char));
799 std::unique_ptr<SingleReleaseCallback> callback = 811 std::unique_ptr<SingleReleaseCallback> callback =
800 SingleReleaseCallback::Create(base::Bind( 812 SingleReleaseCallback::Create(base::Bind(
801 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback, 813 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback,
802 sync_token)); 814 base::Unretained(this), sync_token));
803 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char), 815 layer_->SetTextureMailbox(TextureMailbox(MailboxFromChar(mailbox_char),
804 sync_token, GL_TEXTURE_2D), 816 sync_token, GL_TEXTURE_2D),
805 std::move(callback)); 817 std::move(callback));
806 } 818 }
807 819
808 void BeginTest() override { 820 void BeginTest() override {
809 gfx::Size bounds(100, 100); 821 gfx::Size bounds(100, 100);
810 root_ = Layer::Create(); 822 root_ = Layer::Create();
811 root_->SetBounds(bounds); 823 root_->SetBounds(bounds);
812 824
(...skipping 29 matching lines...) Expand all
842 // expect the next commit to finish *after* it is activated. 854 // expect the next commit to finish *after* it is activated.
843 SetMailbox('2'); 855 SetMailbox('2');
844 break; 856 break;
845 case 2: 857 case 2:
846 // The second mailbox has been activated. Remove the layer from 858 // The second mailbox has been activated. Remove the layer from
847 // the tree to cause another commit/activation. The commit should 859 // the tree to cause another commit/activation. The commit should
848 // finish *after* the layer is removed from the active tree. 860 // finish *after* the layer is removed from the active tree.
849 layer_->RemoveFromParent(); 861 layer_->RemoveFromParent();
850 break; 862 break;
851 case 3: 863 case 3:
852 EndTest(); 864 // This ensures all texture mailboxes are released before the end of the
865 // test.
866 layer_->ClearClient();
853 break; 867 break;
868 default:
869 NOTREACHED();
854 } 870 }
855 } 871 }
856 872
857 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 873 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
858 // The activate didn't happen before commit is done on the impl side (but it 874 // The activate didn't happen before commit is done on the impl side (but it
859 // should happen before the main thread is done). 875 // should happen before the main thread is done).
860 EXPECT_EQ(activate_count_, host_impl->sync_tree()->source_frame_number()); 876 EXPECT_EQ(activate_count_, host_impl->sync_tree()->source_frame_number());
861 } 877 }
862 878
863 void AfterTest() override {} 879 void AfterTest() override {}
864 880
865 base::Lock activate_count_lock_; 881 base::Lock activate_count_lock_;
866 int activate_count_; 882 int activate_count_;
danakj 2017/03/03 16:33:26 nit: can u init this here too now since you're doi
Saman Sami 2017/03/03 16:43:52 Done.
867 scoped_refptr<Layer> root_; 883 scoped_refptr<Layer> root_;
868 scoped_refptr<TextureLayer> layer_; 884 scoped_refptr<TextureLayer> layer_;
885 int released_count_ = 0;
869 }; 886 };
870 887
871 // Flaky on windows and linux. https://crbug.com/641613
danakj 2017/03/03 16:33:26 Oooh dang, we let this sit here D:
872 #if !defined(OS_WIN) && !defined(OS_LINUX)
873 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerMailboxIsActivatedDuringCommit); 888 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerMailboxIsActivatedDuringCommit);
874 #endif
875 889
876 class TextureLayerImplWithMailboxTest : public TextureLayerTest { 890 class TextureLayerImplWithMailboxTest : public TextureLayerTest {
877 protected: 891 protected:
878 void SetUp() override { 892 void SetUp() override {
879 TextureLayerTest::SetUp(); 893 TextureLayerTest::SetUp();
880 layer_tree_host_ = MockLayerTreeHost::Create( 894 layer_tree_host_ = MockLayerTreeHost::Create(
881 &fake_client_, &task_graph_runner_, animation_host_.get()); 895 &fake_client_, &task_graph_runner_, animation_host_.get());
882 host_impl_.SetVisible(true); 896 host_impl_.SetVisible(true);
883 EXPECT_TRUE(host_impl_.InitializeRenderer(compositor_frame_sink_.get())); 897 EXPECT_TRUE(host_impl_.InitializeRenderer(compositor_frame_sink_.get()));
884 } 898 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 base::ThreadChecker main_thread_; 1490 base::ThreadChecker main_thread_;
1477 int callback_count_; 1491 int callback_count_;
1478 scoped_refptr<Layer> root_; 1492 scoped_refptr<Layer> root_;
1479 scoped_refptr<TextureLayer> layer_; 1493 scoped_refptr<TextureLayer> layer_;
1480 }; 1494 };
1481 1495
1482 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerWithMailboxImplThreadDeleted); 1496 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerWithMailboxImplThreadDeleted);
1483 1497
1484 } // namespace 1498 } // namespace
1485 } // namespace cc 1499 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698