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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return FakeOutputSurface::Create3d(context3d.Pass()); | 103 return FakeOutputSurface::Create3d(context3d.Pass()); |
104 } | 104 } |
105 | 105 |
106 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 106 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
107 LayerTreeHostImpl::FrameData* frame, | 107 LayerTreeHostImpl::FrameData* frame, |
108 DrawResult draw_result) override { | 108 DrawResult draw_result) override { |
109 if (draw_result == DRAW_ABORTED_MISSING_HIGH_RES_CONTENT) { | 109 if (draw_result == DRAW_ABORTED_MISSING_HIGH_RES_CONTENT) { |
110 // Only valid for single-threaded impl-side painting, which activates | 110 // Only valid for single-threaded impl-side painting, which activates |
111 // immediately and will try to draw again when content has finished. | 111 // immediately and will try to draw again when content has finished. |
112 DCHECK(!host_impl->proxy()->HasImplThread()); | 112 DCHECK(!host_impl->proxy()->HasImplThread()); |
113 DCHECK(layer_tree_host()->settings().impl_side_painting); | 113 DCHECK(host_impl->settings().impl_side_painting); |
114 return draw_result; | 114 return draw_result; |
115 } | 115 } |
116 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 116 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
117 if (!times_to_lose_during_draw_) | 117 if (!times_to_lose_during_draw_) |
118 return draw_result; | 118 return draw_result; |
119 | 119 |
120 --times_to_lose_during_draw_; | 120 --times_to_lose_during_draw_; |
121 LoseContext(); | 121 LoseContext(); |
122 | 122 |
123 times_to_fail_create_ = times_to_fail_recreate_; | 123 times_to_fail_create_ = times_to_fail_recreate_; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 876 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
877 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); | 877 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
878 | 878 |
879 FakePictureLayerImpl* root_picture = NULL; | 879 FakePictureLayerImpl* root_picture = NULL; |
880 FakePictureLayerImpl* child_picture = NULL; | 880 FakePictureLayerImpl* child_picture = NULL; |
881 FakePictureLayerImpl* grandchild_picture = NULL; | 881 FakePictureLayerImpl* grandchild_picture = NULL; |
882 FakeContentLayerImpl* root_content = NULL; | 882 FakeContentLayerImpl* root_content = NULL; |
883 FakeContentLayerImpl* child_content = NULL; | 883 FakeContentLayerImpl* child_content = NULL; |
884 FakeContentLayerImpl* grandchild_content = NULL; | 884 FakeContentLayerImpl* grandchild_content = NULL; |
885 | 885 |
886 if (layer_tree_host()->settings().impl_side_painting) { | 886 if (host_impl->settings().impl_side_painting) { |
887 root_picture = static_cast<FakePictureLayerImpl*>( | 887 root_picture = static_cast<FakePictureLayerImpl*>( |
888 host_impl->active_tree()->root_layer()); | 888 host_impl->active_tree()->root_layer()); |
889 child_picture = | 889 child_picture = |
890 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); | 890 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); |
891 grandchild_picture = | 891 grandchild_picture = |
892 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); | 892 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); |
893 | 893 |
894 } else { | 894 } else { |
895 root_content = static_cast<FakeContentLayerImpl*>( | 895 root_content = static_cast<FakeContentLayerImpl*>( |
896 host_impl->active_tree()->root_layer()); | 896 host_impl->active_tree()->root_layer()); |
897 child_content = | 897 child_content = |
898 static_cast<FakeContentLayerImpl*>(root_content->children()[0]); | 898 static_cast<FakeContentLayerImpl*>(root_content->children()[0]); |
899 grandchild_content = | 899 grandchild_content = |
900 static_cast<FakeContentLayerImpl*>(child_content->children()[0]); | 900 static_cast<FakeContentLayerImpl*>(child_content->children()[0]); |
901 } | 901 } |
902 | 902 |
903 ++num_commits_; | 903 ++num_commits_; |
904 switch (num_commits_) { | 904 switch (num_commits_) { |
905 case 1: | 905 case 1: |
906 if (layer_tree_host()->settings().impl_side_painting) { | 906 if (host_impl->settings().impl_side_painting) { |
907 EXPECT_EQ(0u, root_picture->release_resources_count()); | 907 EXPECT_EQ(0u, root_picture->release_resources_count()); |
908 EXPECT_EQ(0u, child_picture->release_resources_count()); | 908 EXPECT_EQ(0u, child_picture->release_resources_count()); |
909 EXPECT_EQ(0u, grandchild_picture->release_resources_count()); | 909 EXPECT_EQ(0u, grandchild_picture->release_resources_count()); |
910 } else { | 910 } else { |
911 EXPECT_EQ(0u, root_content->lost_output_surface_count()); | 911 EXPECT_EQ(0u, root_content->lost_output_surface_count()); |
912 EXPECT_EQ(0u, child_content->lost_output_surface_count()); | 912 EXPECT_EQ(0u, child_content->lost_output_surface_count()); |
913 EXPECT_EQ(0u, grandchild_content->lost_output_surface_count()); | 913 EXPECT_EQ(0u, grandchild_content->lost_output_surface_count()); |
914 } | 914 } |
915 | 915 |
916 // Lose the context and struggle to recreate it. | 916 // Lose the context and struggle to recreate it. |
917 LoseContext(); | 917 LoseContext(); |
918 times_to_fail_create_ = 1; | 918 times_to_fail_create_ = 1; |
919 break; | 919 break; |
920 case 2: | 920 case 2: |
921 if (layer_tree_host()->settings().impl_side_painting) { | 921 if (host_impl->settings().impl_side_painting) { |
922 EXPECT_TRUE(root_picture->release_resources_count()); | 922 EXPECT_TRUE(root_picture->release_resources_count()); |
923 EXPECT_TRUE(child_picture->release_resources_count()); | 923 EXPECT_TRUE(child_picture->release_resources_count()); |
924 EXPECT_TRUE(grandchild_picture->release_resources_count()); | 924 EXPECT_TRUE(grandchild_picture->release_resources_count()); |
925 } else { | 925 } else { |
926 EXPECT_TRUE(root_content->lost_output_surface_count()); | 926 EXPECT_TRUE(root_content->lost_output_surface_count()); |
927 EXPECT_TRUE(child_content->lost_output_surface_count()); | 927 EXPECT_TRUE(child_content->lost_output_surface_count()); |
928 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); | 928 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); |
929 } | 929 } |
930 | 930 |
931 EndTest(); | 931 EndTest(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 } | 1320 } |
1321 }; | 1321 }; |
1322 | 1322 |
1323 class UIResourceLostTestSimple : public UIResourceLostTest { | 1323 class UIResourceLostTestSimple : public UIResourceLostTest { |
1324 public: | 1324 public: |
1325 // This is called when the commit is complete and the new layer tree has been | 1325 // This is called when the commit is complete and the new layer tree has been |
1326 // activated. | 1326 // activated. |
1327 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; | 1327 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; |
1328 | 1328 |
1329 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1329 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
1330 if (!layer_tree_host()->settings().impl_side_painting) { | 1330 if (!impl->settings().impl_side_painting) { |
1331 StepCompleteOnImplThread(impl); | 1331 StepCompleteOnImplThread(impl); |
1332 PostStepCompleteToMainThread(); | 1332 PostStepCompleteToMainThread(); |
1333 ++time_step_; | 1333 ++time_step_; |
1334 } | 1334 } |
1335 } | 1335 } |
1336 | 1336 |
1337 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 1337 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
1338 if (layer_tree_host()->settings().impl_side_painting) { | 1338 if (impl->settings().impl_side_painting) { |
1339 StepCompleteOnImplThread(impl); | 1339 StepCompleteOnImplThread(impl); |
1340 PostStepCompleteToMainThread(); | 1340 PostStepCompleteToMainThread(); |
1341 ++time_step_; | 1341 ++time_step_; |
1342 } | 1342 } |
1343 } | 1343 } |
1344 }; | 1344 }; |
1345 | 1345 |
1346 // Losing context after an UI resource has been created. | 1346 // Losing context after an UI resource has been created. |
1347 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { | 1347 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
1348 public: | 1348 public: |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 void AfterTest() override {} | 1792 void AfterTest() override {} |
1793 | 1793 |
1794 bool deferred_; | 1794 bool deferred_; |
1795 }; | 1795 }; |
1796 | 1796 |
1797 SINGLE_AND_MULTI_THREAD_TEST_F( | 1797 SINGLE_AND_MULTI_THREAD_TEST_F( |
1798 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1798 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
1799 | 1799 |
1800 } // namespace | 1800 } // namespace |
1801 } // namespace cc | 1801 } // namespace cc |
OLD | NEW |