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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 MOCK_METHOD0(SetNeedsCommit, void()); | 58 MOCK_METHOD0(SetNeedsCommit, void()); |
59 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 59 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
60 MOCK_METHOD0(StartRateLimiter, void()); | 60 MOCK_METHOD0(StartRateLimiter, void()); |
61 MOCK_METHOD0(StopRateLimiter, void()); | 61 MOCK_METHOD0(StopRateLimiter, void()); |
62 }; | 62 }; |
63 | 63 |
64 class FakeTextureLayerClient : public TextureLayerClient { | 64 class FakeTextureLayerClient : public TextureLayerClient { |
65 public: | 65 public: |
66 FakeTextureLayerClient() : mailbox_changed_(true) {} | 66 FakeTextureLayerClient() : mailbox_changed_(true) {} |
67 | 67 |
68 virtual bool PrepareTextureMailbox( | 68 bool PrepareTextureMailbox( |
69 TextureMailbox* mailbox, | 69 TextureMailbox* mailbox, |
70 scoped_ptr<SingleReleaseCallback>* release_callback, | 70 scoped_ptr<SingleReleaseCallback>* release_callback, |
71 bool use_shared_memory) override { | 71 bool use_shared_memory) override { |
72 if (!mailbox_changed_) | 72 if (!mailbox_changed_) |
73 return false; | 73 return false; |
74 | 74 |
75 *mailbox = mailbox_; | 75 *mailbox = mailbox_; |
76 *release_callback = release_callback_.Pass(); | 76 *release_callback = release_callback_.Pass(); |
77 mailbox_changed_ = false; | 77 mailbox_changed_ = false; |
78 return true; | 78 return true; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 286 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
287 layer_tree_host_->SetRootLayer(nullptr); | 287 layer_tree_host_->SetRootLayer(nullptr); |
288 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 288 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
289 } | 289 } |
290 | 290 |
291 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { | 291 class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { |
292 public: | 292 public: |
293 using TextureLayer::TextureMailboxHolder::Create; | 293 using TextureLayer::TextureMailboxHolder::Create; |
294 | 294 |
295 protected: | 295 protected: |
296 virtual ~TestMailboxHolder() {} | 296 ~TestMailboxHolder() override {} |
297 }; | 297 }; |
298 | 298 |
299 class TextureLayerWithMailboxTest : public TextureLayerTest { | 299 class TextureLayerWithMailboxTest : public TextureLayerTest { |
300 protected: | 300 protected: |
301 virtual void TearDown() { | 301 virtual void TearDown() { |
302 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); | 302 Mock::VerifyAndClearExpectations(&test_data_.mock_callback_); |
303 EXPECT_CALL(test_data_.mock_callback_, | 303 EXPECT_CALL(test_data_.mock_callback_, |
304 Release(test_data_.mailbox_name1_, | 304 Release(test_data_.mailbox_name1_, |
305 test_data_.sync_point1_, | 305 test_data_.sync_point1_, |
306 false)).Times(1); | 306 false)).Times(1); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 719 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
720 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 720 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
721 base::Bind( | 721 base::Bind( |
722 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, | 722 &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, |
723 base::Unretained(this))); | 723 base::Unretained(this))); |
724 layer_->SetTextureMailbox( | 724 layer_->SetTextureMailbox( |
725 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 725 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
726 callback.Pass()); | 726 callback.Pass()); |
727 } | 727 } |
728 | 728 |
729 virtual void BeginTest() override { | 729 void BeginTest() override { |
730 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 730 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
731 | 731 |
732 gfx::Size bounds(100, 100); | 732 gfx::Size bounds(100, 100); |
733 root_ = Layer::Create(); | 733 root_ = Layer::Create(); |
734 root_->SetBounds(bounds); | 734 root_->SetBounds(bounds); |
735 | 735 |
736 layer_ = TextureLayer::CreateForMailbox(nullptr); | 736 layer_ = TextureLayer::CreateForMailbox(nullptr); |
737 layer_->SetIsDrawable(true); | 737 layer_->SetIsDrawable(true); |
738 layer_->SetBounds(bounds); | 738 layer_->SetBounds(bounds); |
739 | 739 |
740 root_->AddChild(layer_); | 740 root_->AddChild(layer_); |
741 layer_tree_host()->SetRootLayer(root_); | 741 layer_tree_host()->SetRootLayer(root_); |
742 layer_tree_host()->SetViewportSize(bounds); | 742 layer_tree_host()->SetViewportSize(bounds); |
743 SetMailbox('1'); | 743 SetMailbox('1'); |
744 EXPECT_EQ(0, callback_count_); | 744 EXPECT_EQ(0, callback_count_); |
745 | 745 |
746 // Case #1: change mailbox before the commit. The old mailbox should be | 746 // Case #1: change mailbox before the commit. The old mailbox should be |
747 // released immediately. | 747 // released immediately. |
748 SetMailbox('2'); | 748 SetMailbox('2'); |
749 EXPECT_EQ(1, callback_count_); | 749 EXPECT_EQ(1, callback_count_); |
750 PostSetNeedsCommitToMainThread(); | 750 PostSetNeedsCommitToMainThread(); |
751 } | 751 } |
752 | 752 |
753 virtual void DidCommit() override { | 753 void DidCommit() override { |
754 ++commit_count_; | 754 ++commit_count_; |
755 switch (commit_count_) { | 755 switch (commit_count_) { |
756 case 1: | 756 case 1: |
757 // Case #2: change mailbox after the commit (and draw), where the | 757 // Case #2: change mailbox after the commit (and draw), where the |
758 // layer draws. The old mailbox should be released during the next | 758 // layer draws. The old mailbox should be released during the next |
759 // commit. | 759 // commit. |
760 SetMailbox('3'); | 760 SetMailbox('3'); |
761 EXPECT_EQ(1, callback_count_); | 761 EXPECT_EQ(1, callback_count_); |
762 break; | 762 break; |
763 case 2: | 763 case 2: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 layer_->SetTextureMailbox(TextureMailbox(), nullptr); | 813 layer_->SetTextureMailbox(TextureMailbox(), nullptr); |
814 EXPECT_EQ(5, callback_count_); | 814 EXPECT_EQ(5, callback_count_); |
815 EndTest(); | 815 EndTest(); |
816 break; | 816 break; |
817 default: | 817 default: |
818 NOTREACHED(); | 818 NOTREACHED(); |
819 break; | 819 break; |
820 } | 820 } |
821 } | 821 } |
822 | 822 |
823 virtual void AfterTest() override {} | 823 void AfterTest() override {} |
824 | 824 |
825 private: | 825 private: |
826 base::ThreadChecker main_thread_; | 826 base::ThreadChecker main_thread_; |
827 int callback_count_; | 827 int callback_count_; |
828 int commit_count_; | 828 int commit_count_; |
829 scoped_refptr<Layer> root_; | 829 scoped_refptr<Layer> root_; |
830 scoped_refptr<TextureLayer> layer_; | 830 scoped_refptr<TextureLayer> layer_; |
831 }; | 831 }; |
832 | 832 |
833 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 833 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
834 TextureLayerImplWithMailboxThreadedCallback); | 834 TextureLayerImplWithMailboxThreadedCallback); |
835 | 835 |
836 | 836 |
837 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { | 837 class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { |
838 protected: | 838 protected: |
839 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} | 839 TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} |
840 | 840 |
841 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} | 841 static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} |
842 | 842 |
843 void SetMailbox(char mailbox_char) { | 843 void SetMailbox(char mailbox_char) { |
844 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 844 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
845 base::Bind( | 845 base::Bind( |
846 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); | 846 &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); |
847 layer_->SetTextureMailbox( | 847 layer_->SetTextureMailbox( |
848 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 848 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
849 callback.Pass()); | 849 callback.Pass()); |
850 } | 850 } |
851 | 851 |
852 virtual void BeginTest() override { | 852 void BeginTest() override { |
853 gfx::Size bounds(100, 100); | 853 gfx::Size bounds(100, 100); |
854 root_ = Layer::Create(); | 854 root_ = Layer::Create(); |
855 root_->SetBounds(bounds); | 855 root_->SetBounds(bounds); |
856 | 856 |
857 layer_ = TextureLayer::CreateForMailbox(nullptr); | 857 layer_ = TextureLayer::CreateForMailbox(nullptr); |
858 layer_->SetIsDrawable(true); | 858 layer_->SetIsDrawable(true); |
859 layer_->SetBounds(bounds); | 859 layer_->SetBounds(bounds); |
860 | 860 |
861 root_->AddChild(layer_); | 861 root_->AddChild(layer_); |
862 layer_tree_host()->SetRootLayer(root_); | 862 layer_tree_host()->SetRootLayer(root_); |
863 layer_tree_host()->SetViewportSize(bounds); | 863 layer_tree_host()->SetViewportSize(bounds); |
864 SetMailbox('1'); | 864 SetMailbox('1'); |
865 | 865 |
866 PostSetNeedsCommitToMainThread(); | 866 PostSetNeedsCommitToMainThread(); |
867 } | 867 } |
868 | 868 |
869 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 869 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
870 ++activate_count_; | 870 ++activate_count_; |
871 } | 871 } |
872 | 872 |
873 virtual void DidCommit() override { | 873 void DidCommit() override { |
874 switch (layer_tree_host()->source_frame_number()) { | 874 switch (layer_tree_host()->source_frame_number()) { |
875 case 1: | 875 case 1: |
876 // The first mailbox has been activated. Set a new mailbox, and | 876 // The first mailbox has been activated. Set a new mailbox, and |
877 // expect the next commit to finish *after* it is activated. | 877 // expect the next commit to finish *after* it is activated. |
878 SetMailbox('2'); | 878 SetMailbox('2'); |
879 break; | 879 break; |
880 case 2: | 880 case 2: |
881 // The second mailbox has been activated. Remove the layer from | 881 // The second mailbox has been activated. Remove the layer from |
882 // the tree to cause another commit/activation. The commit should | 882 // the tree to cause another commit/activation. The commit should |
883 // finish *after* the layer is removed from the active tree. | 883 // finish *after* the layer is removed from the active tree. |
884 layer_->RemoveFromParent(); | 884 layer_->RemoveFromParent(); |
885 break; | 885 break; |
886 case 3: | 886 case 3: |
887 EndTest(); | 887 EndTest(); |
888 break; | 888 break; |
889 } | 889 } |
890 } | 890 } |
891 | 891 |
892 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 892 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
893 switch (host_impl->active_tree()->source_frame_number()) { | 893 switch (host_impl->active_tree()->source_frame_number()) { |
894 case 0: { | 894 case 0: { |
895 // The activate for the 1st mailbox should have happened before now. | 895 // The activate for the 1st mailbox should have happened before now. |
896 EXPECT_EQ(1, activate_count_); | 896 EXPECT_EQ(1, activate_count_); |
897 break; | 897 break; |
898 } | 898 } |
899 case 1: { | 899 case 1: { |
900 // The activate for the 2nd mailbox should have happened before now. | 900 // The activate for the 2nd mailbox should have happened before now. |
901 EXPECT_EQ(2, activate_count_); | 901 EXPECT_EQ(2, activate_count_); |
902 break; | 902 break; |
903 } | 903 } |
904 case 2: { | 904 case 2: { |
905 // The activate to remove the layer should have happened before now. | 905 // The activate to remove the layer should have happened before now. |
906 EXPECT_EQ(3, activate_count_); | 906 EXPECT_EQ(3, activate_count_); |
907 break; | 907 break; |
908 } | 908 } |
909 case 3: { | 909 case 3: { |
910 NOTREACHED(); | 910 NOTREACHED(); |
911 break; | 911 break; |
912 } | 912 } |
913 } | 913 } |
914 } | 914 } |
915 | 915 |
916 | 916 void AfterTest() override {} |
917 virtual void AfterTest() override {} | |
918 | 917 |
919 int activate_count_; | 918 int activate_count_; |
920 scoped_refptr<Layer> root_; | 919 scoped_refptr<Layer> root_; |
921 scoped_refptr<TextureLayer> layer_; | 920 scoped_refptr<TextureLayer> layer_; |
922 }; | 921 }; |
923 | 922 |
924 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 923 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
925 TextureLayerMailboxIsActivatedDuringCommit); | 924 TextureLayerMailboxIsActivatedDuringCommit); |
926 | 925 |
927 class TextureLayerImplWithMailboxTest : public TextureLayerTest { | 926 class TextureLayerImplWithMailboxTest : public TextureLayerTest { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 provider->ReceiveReturnsFromParent(returned); | 1121 provider->ReceiveReturnsFromParent(returned); |
1123 } | 1122 } |
1124 | 1123 |
1125 // Checks that TextureLayer::Update does not cause an extra commit when setting | 1124 // Checks that TextureLayer::Update does not cause an extra commit when setting |
1126 // the texture mailbox. | 1125 // the texture mailbox. |
1127 class TextureLayerNoExtraCommitForMailboxTest | 1126 class TextureLayerNoExtraCommitForMailboxTest |
1128 : public LayerTreeTest, | 1127 : public LayerTreeTest, |
1129 public TextureLayerClient { | 1128 public TextureLayerClient { |
1130 public: | 1129 public: |
1131 // TextureLayerClient implementation. | 1130 // TextureLayerClient implementation. |
1132 virtual bool PrepareTextureMailbox( | 1131 bool PrepareTextureMailbox( |
1133 TextureMailbox* texture_mailbox, | 1132 TextureMailbox* texture_mailbox, |
1134 scoped_ptr<SingleReleaseCallback>* release_callback, | 1133 scoped_ptr<SingleReleaseCallback>* release_callback, |
1135 bool use_shared_memory) override { | 1134 bool use_shared_memory) override { |
1136 if (layer_tree_host()->source_frame_number() == 1) { | 1135 if (layer_tree_host()->source_frame_number() == 1) { |
1137 // Once this has been committed, the mailbox will be released. | 1136 // Once this has been committed, the mailbox will be released. |
1138 *texture_mailbox = TextureMailbox(); | 1137 *texture_mailbox = TextureMailbox(); |
1139 return true; | 1138 return true; |
1140 } | 1139 } |
1141 | 1140 |
1142 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); | 1141 *texture_mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); |
1143 *release_callback = SingleReleaseCallback::Create( | 1142 *release_callback = SingleReleaseCallback::Create( |
1144 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, | 1143 base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, |
1145 base::Unretained(this))); | 1144 base::Unretained(this))); |
1146 return true; | 1145 return true; |
1147 } | 1146 } |
1148 | 1147 |
1149 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1148 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1150 // Source frame number during callback is the same as the source frame | 1149 // Source frame number during callback is the same as the source frame |
1151 // on which it was released. | 1150 // on which it was released. |
1152 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); | 1151 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); |
1153 EndTest(); | 1152 EndTest(); |
1154 } | 1153 } |
1155 | 1154 |
1156 virtual void SetupTree() override { | 1155 void SetupTree() override { |
1157 scoped_refptr<Layer> root = Layer::Create(); | 1156 scoped_refptr<Layer> root = Layer::Create(); |
1158 root->SetBounds(gfx::Size(10, 10)); | 1157 root->SetBounds(gfx::Size(10, 10)); |
1159 root->SetIsDrawable(true); | 1158 root->SetIsDrawable(true); |
1160 | 1159 |
1161 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1160 texture_layer_ = TextureLayer::CreateForMailbox(this); |
1162 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1161 texture_layer_->SetBounds(gfx::Size(10, 10)); |
1163 texture_layer_->SetIsDrawable(true); | 1162 texture_layer_->SetIsDrawable(true); |
1164 root->AddChild(texture_layer_); | 1163 root->AddChild(texture_layer_); |
1165 | 1164 |
1166 layer_tree_host()->SetRootLayer(root); | 1165 layer_tree_host()->SetRootLayer(root); |
1167 LayerTreeTest::SetupTree(); | 1166 LayerTreeTest::SetupTree(); |
1168 } | 1167 } |
1169 | 1168 |
1170 virtual void BeginTest() override { | 1169 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1171 PostSetNeedsCommitToMainThread(); | |
1172 } | |
1173 | 1170 |
1174 virtual void DidCommitAndDrawFrame() override { | 1171 void DidCommitAndDrawFrame() override { |
1175 switch (layer_tree_host()->source_frame_number()) { | 1172 switch (layer_tree_host()->source_frame_number()) { |
1176 case 1: | 1173 case 1: |
1177 EXPECT_FALSE(proxy()->MainFrameWillHappenForTesting()); | 1174 EXPECT_FALSE(proxy()->MainFrameWillHappenForTesting()); |
1178 // Invalidate the texture layer to clear the mailbox before | 1175 // Invalidate the texture layer to clear the mailbox before |
1179 // ending the test. | 1176 // ending the test. |
1180 texture_layer_->SetNeedsDisplay(); | 1177 texture_layer_->SetNeedsDisplay(); |
1181 break; | 1178 break; |
1182 case 2: | 1179 case 2: |
1183 break; | 1180 break; |
1184 default: | 1181 default: |
1185 NOTREACHED(); | 1182 NOTREACHED(); |
1186 break; | 1183 break; |
1187 } | 1184 } |
1188 } | 1185 } |
1189 | 1186 |
1190 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 1187 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
1191 bool result) override { | |
1192 ASSERT_TRUE(result); | 1188 ASSERT_TRUE(result); |
1193 DelegatedFrameData* delegated_frame_data = | 1189 DelegatedFrameData* delegated_frame_data = |
1194 output_surface()->last_sent_frame().delegated_frame_data.get(); | 1190 output_surface()->last_sent_frame().delegated_frame_data.get(); |
1195 if (!delegated_frame_data) | 1191 if (!delegated_frame_data) |
1196 return; | 1192 return; |
1197 | 1193 |
1198 // Return all resources immediately. | 1194 // Return all resources immediately. |
1199 TransferableResourceArray resources_to_return = | 1195 TransferableResourceArray resources_to_return = |
1200 output_surface()->resources_held_by_parent(); | 1196 output_surface()->resources_held_by_parent(); |
1201 | 1197 |
1202 CompositorFrameAck ack; | 1198 CompositorFrameAck ack; |
1203 for (size_t i = 0; i < resources_to_return.size(); ++i) | 1199 for (size_t i = 0; i < resources_to_return.size(); ++i) |
1204 output_surface()->ReturnResource(resources_to_return[i].id, &ack); | 1200 output_surface()->ReturnResource(resources_to_return[i].id, &ack); |
1205 host_impl->ReclaimResources(&ack); | 1201 host_impl->ReclaimResources(&ack); |
1206 } | 1202 } |
1207 | 1203 |
1208 virtual void AfterTest() override {} | 1204 void AfterTest() override {} |
1209 | 1205 |
1210 private: | 1206 private: |
1211 scoped_refptr<TextureLayer> texture_layer_; | 1207 scoped_refptr<TextureLayer> texture_layer_; |
1212 }; | 1208 }; |
1213 | 1209 |
1214 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest); | 1210 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerNoExtraCommitForMailboxTest); |
1215 | 1211 |
1216 // Checks that changing a mailbox in the client for a TextureLayer that's | 1212 // Checks that changing a mailbox in the client for a TextureLayer that's |
1217 // invisible correctly works and uses the new mailbox as soon as the layer | 1213 // invisible correctly works and uses the new mailbox as soon as the layer |
1218 // becomes visible (and returns the old one). | 1214 // becomes visible (and returns the old one). |
1219 class TextureLayerChangeInvisibleMailboxTest | 1215 class TextureLayerChangeInvisibleMailboxTest |
1220 : public LayerTreeTest, | 1216 : public LayerTreeTest, |
1221 public TextureLayerClient { | 1217 public TextureLayerClient { |
1222 public: | 1218 public: |
1223 TextureLayerChangeInvisibleMailboxTest() | 1219 TextureLayerChangeInvisibleMailboxTest() |
1224 : mailbox_changed_(true), | 1220 : mailbox_changed_(true), |
1225 mailbox_returned_(0), | 1221 mailbox_returned_(0), |
1226 prepare_called_(0), | 1222 prepare_called_(0), |
1227 commit_count_(0) { | 1223 commit_count_(0) { |
1228 mailbox_ = MakeMailbox('1'); | 1224 mailbox_ = MakeMailbox('1'); |
1229 } | 1225 } |
1230 | 1226 |
1231 // TextureLayerClient implementation. | 1227 // TextureLayerClient implementation. |
1232 virtual bool PrepareTextureMailbox( | 1228 bool PrepareTextureMailbox( |
1233 TextureMailbox* mailbox, | 1229 TextureMailbox* mailbox, |
1234 scoped_ptr<SingleReleaseCallback>* release_callback, | 1230 scoped_ptr<SingleReleaseCallback>* release_callback, |
1235 bool use_shared_memory) override { | 1231 bool use_shared_memory) override { |
1236 ++prepare_called_; | 1232 ++prepare_called_; |
1237 if (!mailbox_changed_) | 1233 if (!mailbox_changed_) |
1238 return false; | 1234 return false; |
1239 *mailbox = mailbox_; | 1235 *mailbox = mailbox_; |
1240 *release_callback = SingleReleaseCallback::Create( | 1236 *release_callback = SingleReleaseCallback::Create( |
1241 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, | 1237 base::Bind(&TextureLayerChangeInvisibleMailboxTest::MailboxReleased, |
1242 base::Unretained(this))); | 1238 base::Unretained(this))); |
1243 return true; | 1239 return true; |
1244 } | 1240 } |
1245 | 1241 |
1246 TextureMailbox MakeMailbox(char name) { | 1242 TextureMailbox MakeMailbox(char name) { |
1247 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); | 1243 return TextureMailbox(MailboxFromChar(name), GL_TEXTURE_2D, 0); |
1248 } | 1244 } |
1249 | 1245 |
1250 void MailboxReleased(uint32 sync_point, bool lost_resource) { | 1246 void MailboxReleased(uint32 sync_point, bool lost_resource) { |
1251 ++mailbox_returned_; | 1247 ++mailbox_returned_; |
1252 } | 1248 } |
1253 | 1249 |
1254 virtual void SetupTree() override { | 1250 void SetupTree() override { |
1255 scoped_refptr<Layer> root = Layer::Create(); | 1251 scoped_refptr<Layer> root = Layer::Create(); |
1256 root->SetBounds(gfx::Size(10, 10)); | 1252 root->SetBounds(gfx::Size(10, 10)); |
1257 root->SetIsDrawable(true); | 1253 root->SetIsDrawable(true); |
1258 | 1254 |
1259 solid_layer_ = SolidColorLayer::Create(); | 1255 solid_layer_ = SolidColorLayer::Create(); |
1260 solid_layer_->SetBounds(gfx::Size(10, 10)); | 1256 solid_layer_->SetBounds(gfx::Size(10, 10)); |
1261 solid_layer_->SetIsDrawable(true); | 1257 solid_layer_->SetIsDrawable(true); |
1262 solid_layer_->SetBackgroundColor(SK_ColorWHITE); | 1258 solid_layer_->SetBackgroundColor(SK_ColorWHITE); |
1263 root->AddChild(solid_layer_); | 1259 root->AddChild(solid_layer_); |
1264 | 1260 |
1265 parent_layer_ = Layer::Create(); | 1261 parent_layer_ = Layer::Create(); |
1266 parent_layer_->SetBounds(gfx::Size(10, 10)); | 1262 parent_layer_->SetBounds(gfx::Size(10, 10)); |
1267 parent_layer_->SetIsDrawable(true); | 1263 parent_layer_->SetIsDrawable(true); |
1268 root->AddChild(parent_layer_); | 1264 root->AddChild(parent_layer_); |
1269 | 1265 |
1270 texture_layer_ = TextureLayer::CreateForMailbox(this); | 1266 texture_layer_ = TextureLayer::CreateForMailbox(this); |
1271 texture_layer_->SetBounds(gfx::Size(10, 10)); | 1267 texture_layer_->SetBounds(gfx::Size(10, 10)); |
1272 texture_layer_->SetIsDrawable(true); | 1268 texture_layer_->SetIsDrawable(true); |
1273 parent_layer_->AddChild(texture_layer_); | 1269 parent_layer_->AddChild(texture_layer_); |
1274 | 1270 |
1275 layer_tree_host()->SetRootLayer(root); | 1271 layer_tree_host()->SetRootLayer(root); |
1276 LayerTreeTest::SetupTree(); | 1272 LayerTreeTest::SetupTree(); |
1277 } | 1273 } |
1278 | 1274 |
1279 virtual void BeginTest() override { | 1275 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1280 PostSetNeedsCommitToMainThread(); | |
1281 } | |
1282 | 1276 |
1283 virtual void DidCommitAndDrawFrame() override { | 1277 void DidCommitAndDrawFrame() override { |
1284 ++commit_count_; | 1278 ++commit_count_; |
1285 switch (commit_count_) { | 1279 switch (commit_count_) { |
1286 case 1: | 1280 case 1: |
1287 // We should have updated the layer, committing the texture. | 1281 // We should have updated the layer, committing the texture. |
1288 EXPECT_EQ(1, prepare_called_); | 1282 EXPECT_EQ(1, prepare_called_); |
1289 // Make layer invisible. | 1283 // Make layer invisible. |
1290 parent_layer_->SetOpacity(0.f); | 1284 parent_layer_->SetOpacity(0.f); |
1291 break; | 1285 break; |
1292 case 2: | 1286 case 2: |
1293 // Layer shouldn't have been updated. | 1287 // Layer shouldn't have been updated. |
(...skipping 23 matching lines...) Expand all Loading... |
1317 case 5: | 1311 case 5: |
1318 EXPECT_EQ(2, mailbox_returned_); | 1312 EXPECT_EQ(2, mailbox_returned_); |
1319 EndTest(); | 1313 EndTest(); |
1320 break; | 1314 break; |
1321 default: | 1315 default: |
1322 NOTREACHED(); | 1316 NOTREACHED(); |
1323 break; | 1317 break; |
1324 } | 1318 } |
1325 } | 1319 } |
1326 | 1320 |
1327 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 1321 void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) override { |
1328 bool result) override { | |
1329 ASSERT_TRUE(result); | 1322 ASSERT_TRUE(result); |
1330 DelegatedFrameData* delegated_frame_data = | 1323 DelegatedFrameData* delegated_frame_data = |
1331 output_surface()->last_sent_frame().delegated_frame_data.get(); | 1324 output_surface()->last_sent_frame().delegated_frame_data.get(); |
1332 if (!delegated_frame_data) | 1325 if (!delegated_frame_data) |
1333 return; | 1326 return; |
1334 | 1327 |
1335 // Return all resources immediately. | 1328 // Return all resources immediately. |
1336 TransferableResourceArray resources_to_return = | 1329 TransferableResourceArray resources_to_return = |
1337 output_surface()->resources_held_by_parent(); | 1330 output_surface()->resources_held_by_parent(); |
1338 | 1331 |
1339 CompositorFrameAck ack; | 1332 CompositorFrameAck ack; |
1340 for (size_t i = 0; i < resources_to_return.size(); ++i) | 1333 for (size_t i = 0; i < resources_to_return.size(); ++i) |
1341 output_surface()->ReturnResource(resources_to_return[i].id, &ack); | 1334 output_surface()->ReturnResource(resources_to_return[i].id, &ack); |
1342 host_impl->ReclaimResources(&ack); | 1335 host_impl->ReclaimResources(&ack); |
1343 } | 1336 } |
1344 | 1337 |
1345 virtual void AfterTest() override {} | 1338 void AfterTest() override {} |
1346 | 1339 |
1347 private: | 1340 private: |
1348 scoped_refptr<SolidColorLayer> solid_layer_; | 1341 scoped_refptr<SolidColorLayer> solid_layer_; |
1349 scoped_refptr<Layer> parent_layer_; | 1342 scoped_refptr<Layer> parent_layer_; |
1350 scoped_refptr<TextureLayer> texture_layer_; | 1343 scoped_refptr<TextureLayer> texture_layer_; |
1351 | 1344 |
1352 // Used on the main thread. | 1345 // Used on the main thread. |
1353 bool mailbox_changed_; | 1346 bool mailbox_changed_; |
1354 TextureMailbox mailbox_; | 1347 TextureMailbox mailbox_; |
1355 int mailbox_returned_; | 1348 int mailbox_returned_; |
1356 int prepare_called_; | 1349 int prepare_called_; |
1357 int commit_count_; | 1350 int commit_count_; |
1358 }; | 1351 }; |
1359 | 1352 |
1360 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest); | 1353 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerChangeInvisibleMailboxTest); |
1361 | 1354 |
1362 // Test that TextureLayerImpl::ReleaseResources can be called which releases | 1355 // Test that TextureLayerImpl::ReleaseResources can be called which releases |
1363 // the mailbox back to TextureLayerClient. | 1356 // the mailbox back to TextureLayerClient. |
1364 class TextureLayerReleaseResourcesBase | 1357 class TextureLayerReleaseResourcesBase |
1365 : public LayerTreeTest, | 1358 : public LayerTreeTest, |
1366 public TextureLayerClient { | 1359 public TextureLayerClient { |
1367 public: | 1360 public: |
1368 // TextureLayerClient implementation. | 1361 // TextureLayerClient implementation. |
1369 virtual bool PrepareTextureMailbox( | 1362 bool PrepareTextureMailbox( |
1370 TextureMailbox* mailbox, | 1363 TextureMailbox* mailbox, |
1371 scoped_ptr<SingleReleaseCallback>* release_callback, | 1364 scoped_ptr<SingleReleaseCallback>* release_callback, |
1372 bool use_shared_memory) override { | 1365 bool use_shared_memory) override { |
1373 *mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); | 1366 *mailbox = TextureMailbox(MailboxFromChar('1'), GL_TEXTURE_2D, 0); |
1374 *release_callback = SingleReleaseCallback::Create( | 1367 *release_callback = SingleReleaseCallback::Create( |
1375 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, | 1368 base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, |
1376 base::Unretained(this))); | 1369 base::Unretained(this))); |
1377 return true; | 1370 return true; |
1378 } | 1371 } |
1379 | 1372 |
1380 void MailboxReleased(unsigned sync_point, bool lost_resource) { | 1373 void MailboxReleased(unsigned sync_point, bool lost_resource) { |
1381 mailbox_released_ = true; | 1374 mailbox_released_ = true; |
1382 } | 1375 } |
1383 | 1376 |
1384 virtual void SetupTree() override { | 1377 void SetupTree() override { |
1385 LayerTreeTest::SetupTree(); | 1378 LayerTreeTest::SetupTree(); |
1386 | 1379 |
1387 scoped_refptr<TextureLayer> texture_layer = | 1380 scoped_refptr<TextureLayer> texture_layer = |
1388 TextureLayer::CreateForMailbox(this); | 1381 TextureLayer::CreateForMailbox(this); |
1389 texture_layer->SetBounds(gfx::Size(10, 10)); | 1382 texture_layer->SetBounds(gfx::Size(10, 10)); |
1390 texture_layer->SetIsDrawable(true); | 1383 texture_layer->SetIsDrawable(true); |
1391 | 1384 |
1392 layer_tree_host()->root_layer()->AddChild(texture_layer); | 1385 layer_tree_host()->root_layer()->AddChild(texture_layer); |
1393 } | 1386 } |
1394 | 1387 |
1395 virtual void BeginTest() override { | 1388 void BeginTest() override { |
1396 mailbox_released_ = false; | 1389 mailbox_released_ = false; |
1397 PostSetNeedsCommitToMainThread(); | 1390 PostSetNeedsCommitToMainThread(); |
1398 } | 1391 } |
1399 | 1392 |
1400 virtual void DidCommitAndDrawFrame() override { | 1393 void DidCommitAndDrawFrame() override { EndTest(); } |
1401 EndTest(); | |
1402 } | |
1403 | 1394 |
1404 virtual void AfterTest() override { | 1395 void AfterTest() override { EXPECT_TRUE(mailbox_released_); } |
1405 EXPECT_TRUE(mailbox_released_); | |
1406 } | |
1407 | 1396 |
1408 private: | 1397 private: |
1409 bool mailbox_released_; | 1398 bool mailbox_released_; |
1410 }; | 1399 }; |
1411 | 1400 |
1412 class TextureLayerReleaseResourcesAfterCommit | 1401 class TextureLayerReleaseResourcesAfterCommit |
1413 : public TextureLayerReleaseResourcesBase { | 1402 : public TextureLayerReleaseResourcesBase { |
1414 public: | 1403 public: |
1415 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1404 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
1416 LayerTreeImpl* tree = nullptr; | 1405 LayerTreeImpl* tree = nullptr; |
1417 if (host_impl->settings().impl_side_painting) | 1406 if (host_impl->settings().impl_side_painting) |
1418 tree = host_impl->pending_tree(); | 1407 tree = host_impl->pending_tree(); |
1419 else | 1408 else |
1420 tree = host_impl->active_tree(); | 1409 tree = host_impl->active_tree(); |
1421 tree->root_layer()->children()[0]->ReleaseResources(); | 1410 tree->root_layer()->children()[0]->ReleaseResources(); |
1422 } | 1411 } |
1423 }; | 1412 }; |
1424 | 1413 |
1425 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterCommit); | 1414 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterCommit); |
1426 | 1415 |
1427 class TextureLayerReleaseResourcesAfterActivate | 1416 class TextureLayerReleaseResourcesAfterActivate |
1428 : public TextureLayerReleaseResourcesBase { | 1417 : public TextureLayerReleaseResourcesBase { |
1429 public: | 1418 public: |
1430 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 1419 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
1431 host_impl->active_tree()->root_layer()->children()[0]->ReleaseResources(); | 1420 host_impl->active_tree()->root_layer()->children()[0]->ReleaseResources(); |
1432 } | 1421 } |
1433 }; | 1422 }; |
1434 | 1423 |
1435 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate); | 1424 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerReleaseResourcesAfterActivate); |
1436 | 1425 |
1437 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { | 1426 class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { |
1438 public: | 1427 public: |
1439 void ReleaseCallback(uint32 sync_point, bool lost_resource) { | 1428 void ReleaseCallback(uint32 sync_point, bool lost_resource) { |
1440 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1429 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1441 EXPECT_FALSE(lost_resource); | 1430 EXPECT_FALSE(lost_resource); |
1442 ++callback_count_; | 1431 ++callback_count_; |
1443 EndTest(); | 1432 EndTest(); |
1444 } | 1433 } |
1445 | 1434 |
1446 void SetMailbox(char mailbox_char) { | 1435 void SetMailbox(char mailbox_char) { |
1447 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1436 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1448 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 1437 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
1449 base::Bind( | 1438 base::Bind( |
1450 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, | 1439 &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, |
1451 base::Unretained(this))); | 1440 base::Unretained(this))); |
1452 layer_->SetTextureMailbox( | 1441 layer_->SetTextureMailbox( |
1453 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1442 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1454 callback.Pass()); | 1443 callback.Pass()); |
1455 } | 1444 } |
1456 | 1445 |
1457 virtual void SetupTree() override { | 1446 void SetupTree() override { |
1458 gfx::Size bounds(100, 100); | 1447 gfx::Size bounds(100, 100); |
1459 root_ = Layer::Create(); | 1448 root_ = Layer::Create(); |
1460 root_->SetBounds(bounds); | 1449 root_->SetBounds(bounds); |
1461 | 1450 |
1462 layer_ = TextureLayer::CreateForMailbox(nullptr); | 1451 layer_ = TextureLayer::CreateForMailbox(nullptr); |
1463 layer_->SetIsDrawable(true); | 1452 layer_->SetIsDrawable(true); |
1464 layer_->SetBounds(bounds); | 1453 layer_->SetBounds(bounds); |
1465 | 1454 |
1466 root_->AddChild(layer_); | 1455 root_->AddChild(layer_); |
1467 layer_tree_host()->SetRootLayer(root_); | 1456 layer_tree_host()->SetRootLayer(root_); |
1468 layer_tree_host()->SetViewportSize(bounds); | 1457 layer_tree_host()->SetViewportSize(bounds); |
1469 } | 1458 } |
1470 | 1459 |
1471 virtual void BeginTest() override { | 1460 void BeginTest() override { |
1472 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1461 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1473 | 1462 |
1474 callback_count_ = 0; | 1463 callback_count_ = 0; |
1475 | 1464 |
1476 // Set the mailbox on the main thread. | 1465 // Set the mailbox on the main thread. |
1477 SetMailbox('1'); | 1466 SetMailbox('1'); |
1478 EXPECT_EQ(0, callback_count_); | 1467 EXPECT_EQ(0, callback_count_); |
1479 | 1468 |
1480 PostSetNeedsCommitToMainThread(); | 1469 PostSetNeedsCommitToMainThread(); |
1481 } | 1470 } |
1482 | 1471 |
1483 virtual void DidCommitAndDrawFrame() override { | 1472 void DidCommitAndDrawFrame() override { |
1484 switch (layer_tree_host()->source_frame_number()) { | 1473 switch (layer_tree_host()->source_frame_number()) { |
1485 case 1: | 1474 case 1: |
1486 // Delete the TextureLayer on the main thread while the mailbox is in | 1475 // Delete the TextureLayer on the main thread while the mailbox is in |
1487 // the impl tree. | 1476 // the impl tree. |
1488 layer_->RemoveFromParent(); | 1477 layer_->RemoveFromParent(); |
1489 layer_ = nullptr; | 1478 layer_ = nullptr; |
1490 break; | 1479 break; |
1491 } | 1480 } |
1492 } | 1481 } |
1493 | 1482 |
1494 virtual void AfterTest() override { | 1483 void AfterTest() override { EXPECT_EQ(1, callback_count_); } |
1495 EXPECT_EQ(1, callback_count_); | |
1496 } | |
1497 | 1484 |
1498 private: | 1485 private: |
1499 base::ThreadChecker main_thread_; | 1486 base::ThreadChecker main_thread_; |
1500 int callback_count_; | 1487 int callback_count_; |
1501 scoped_refptr<Layer> root_; | 1488 scoped_refptr<Layer> root_; |
1502 scoped_refptr<TextureLayer> layer_; | 1489 scoped_refptr<TextureLayer> layer_; |
1503 }; | 1490 }; |
1504 | 1491 |
1505 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1492 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1506 TextureLayerWithMailboxMainThreadDeleted); | 1493 TextureLayerWithMailboxMainThreadDeleted); |
(...skipping 11 matching lines...) Expand all Loading... |
1518 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1505 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1519 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( | 1506 scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( |
1520 base::Bind( | 1507 base::Bind( |
1521 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, | 1508 &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, |
1522 base::Unretained(this))); | 1509 base::Unretained(this))); |
1523 layer_->SetTextureMailbox( | 1510 layer_->SetTextureMailbox( |
1524 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), | 1511 TextureMailbox(MailboxFromChar(mailbox_char), GL_TEXTURE_2D, 0), |
1525 callback.Pass()); | 1512 callback.Pass()); |
1526 } | 1513 } |
1527 | 1514 |
1528 virtual void SetupTree() override { | 1515 void SetupTree() override { |
1529 gfx::Size bounds(100, 100); | 1516 gfx::Size bounds(100, 100); |
1530 root_ = Layer::Create(); | 1517 root_ = Layer::Create(); |
1531 root_->SetBounds(bounds); | 1518 root_->SetBounds(bounds); |
1532 | 1519 |
1533 layer_ = TextureLayer::CreateForMailbox(nullptr); | 1520 layer_ = TextureLayer::CreateForMailbox(nullptr); |
1534 layer_->SetIsDrawable(true); | 1521 layer_->SetIsDrawable(true); |
1535 layer_->SetBounds(bounds); | 1522 layer_->SetBounds(bounds); |
1536 | 1523 |
1537 root_->AddChild(layer_); | 1524 root_->AddChild(layer_); |
1538 layer_tree_host()->SetRootLayer(root_); | 1525 layer_tree_host()->SetRootLayer(root_); |
1539 layer_tree_host()->SetViewportSize(bounds); | 1526 layer_tree_host()->SetViewportSize(bounds); |
1540 } | 1527 } |
1541 | 1528 |
1542 virtual void BeginTest() override { | 1529 void BeginTest() override { |
1543 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); | 1530 EXPECT_EQ(true, main_thread_.CalledOnValidThread()); |
1544 | 1531 |
1545 callback_count_ = 0; | 1532 callback_count_ = 0; |
1546 | 1533 |
1547 // Set the mailbox on the main thread. | 1534 // Set the mailbox on the main thread. |
1548 SetMailbox('1'); | 1535 SetMailbox('1'); |
1549 EXPECT_EQ(0, callback_count_); | 1536 EXPECT_EQ(0, callback_count_); |
1550 | 1537 |
1551 PostSetNeedsCommitToMainThread(); | 1538 PostSetNeedsCommitToMainThread(); |
1552 } | 1539 } |
1553 | 1540 |
1554 virtual void DidCommitAndDrawFrame() override { | 1541 void DidCommitAndDrawFrame() override { |
1555 switch (layer_tree_host()->source_frame_number()) { | 1542 switch (layer_tree_host()->source_frame_number()) { |
1556 case 1: | 1543 case 1: |
1557 // Remove the TextureLayer on the main thread while the mailbox is in | 1544 // Remove the TextureLayer on the main thread while the mailbox is in |
1558 // the impl tree, but don't delete the TextureLayer until after the impl | 1545 // the impl tree, but don't delete the TextureLayer until after the impl |
1559 // tree side is deleted. | 1546 // tree side is deleted. |
1560 layer_->RemoveFromParent(); | 1547 layer_->RemoveFromParent(); |
1561 break; | 1548 break; |
1562 case 2: | 1549 case 2: |
1563 layer_ = nullptr; | 1550 layer_ = nullptr; |
1564 break; | 1551 break; |
1565 } | 1552 } |
1566 } | 1553 } |
1567 | 1554 |
1568 virtual void AfterTest() override { | 1555 void AfterTest() override { EXPECT_EQ(1, callback_count_); } |
1569 EXPECT_EQ(1, callback_count_); | |
1570 } | |
1571 | 1556 |
1572 private: | 1557 private: |
1573 base::ThreadChecker main_thread_; | 1558 base::ThreadChecker main_thread_; |
1574 int callback_count_; | 1559 int callback_count_; |
1575 scoped_refptr<Layer> root_; | 1560 scoped_refptr<Layer> root_; |
1576 scoped_refptr<TextureLayer> layer_; | 1561 scoped_refptr<TextureLayer> layer_; |
1577 }; | 1562 }; |
1578 | 1563 |
1579 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 1564 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
1580 TextureLayerWithMailboxImplThreadDeleted); | 1565 TextureLayerWithMailboxImplThreadDeleted); |
1581 | 1566 |
1582 } // namespace | 1567 } // namespace |
1583 } // namespace cc | 1568 } // namespace cc |
OLD | NEW |