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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return FakeOutputSurface::Create3d(context3d.Pass()); | 96 return FakeOutputSurface::Create3d(context3d.Pass()); |
97 } | 97 } |
98 | 98 |
99 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 99 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
100 LayerTreeHostImpl::FrameData* frame, | 100 LayerTreeHostImpl::FrameData* frame, |
101 DrawResult draw_result) override { | 101 DrawResult draw_result) override { |
102 if (draw_result == DRAW_ABORTED_MISSING_HIGH_RES_CONTENT) { | 102 if (draw_result == DRAW_ABORTED_MISSING_HIGH_RES_CONTENT) { |
103 // Only valid for single-threaded impl-side painting, which activates | 103 // Only valid for single-threaded impl-side painting, which activates |
104 // immediately and will try to draw again when content has finished. | 104 // immediately and will try to draw again when content has finished. |
105 DCHECK(!host_impl->proxy()->HasImplThread()); | 105 DCHECK(!host_impl->proxy()->HasImplThread()); |
106 DCHECK(layer_tree_host()->settings().impl_side_painting); | 106 DCHECK(host_impl->settings().impl_side_painting); |
107 return draw_result; | 107 return draw_result; |
108 } | 108 } |
109 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 109 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
110 if (!times_to_lose_during_draw_) | 110 if (!times_to_lose_during_draw_) |
111 return draw_result; | 111 return draw_result; |
112 | 112 |
113 --times_to_lose_during_draw_; | 113 --times_to_lose_during_draw_; |
114 LoseContext(); | 114 LoseContext(); |
115 | 115 |
116 times_to_fail_create_ = times_to_fail_recreate_; | 116 times_to_fail_create_ = times_to_fail_recreate_; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 869 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
870 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); | 870 LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
871 | 871 |
872 FakePictureLayerImpl* root_picture = NULL; | 872 FakePictureLayerImpl* root_picture = NULL; |
873 FakePictureLayerImpl* child_picture = NULL; | 873 FakePictureLayerImpl* child_picture = NULL; |
874 FakePictureLayerImpl* grandchild_picture = NULL; | 874 FakePictureLayerImpl* grandchild_picture = NULL; |
875 FakeContentLayerImpl* root_content = NULL; | 875 FakeContentLayerImpl* root_content = NULL; |
876 FakeContentLayerImpl* child_content = NULL; | 876 FakeContentLayerImpl* child_content = NULL; |
877 FakeContentLayerImpl* grandchild_content = NULL; | 877 FakeContentLayerImpl* grandchild_content = NULL; |
878 | 878 |
879 if (layer_tree_host()->settings().impl_side_painting) { | 879 if (host_impl->settings().impl_side_painting) { |
880 root_picture = static_cast<FakePictureLayerImpl*>( | 880 root_picture = static_cast<FakePictureLayerImpl*>( |
881 host_impl->active_tree()->root_layer()); | 881 host_impl->active_tree()->root_layer()); |
882 child_picture = | 882 child_picture = |
883 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); | 883 static_cast<FakePictureLayerImpl*>(root_picture->children()[0]); |
884 grandchild_picture = | 884 grandchild_picture = |
885 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); | 885 static_cast<FakePictureLayerImpl*>(child_picture->children()[0]); |
886 | 886 |
887 } else { | 887 } else { |
888 root_content = static_cast<FakeContentLayerImpl*>( | 888 root_content = static_cast<FakeContentLayerImpl*>( |
889 host_impl->active_tree()->root_layer()); | 889 host_impl->active_tree()->root_layer()); |
890 child_content = | 890 child_content = |
891 static_cast<FakeContentLayerImpl*>(root_content->children()[0]); | 891 static_cast<FakeContentLayerImpl*>(root_content->children()[0]); |
892 grandchild_content = | 892 grandchild_content = |
893 static_cast<FakeContentLayerImpl*>(child_content->children()[0]); | 893 static_cast<FakeContentLayerImpl*>(child_content->children()[0]); |
894 } | 894 } |
895 | 895 |
896 ++num_commits_; | 896 ++num_commits_; |
897 switch (num_commits_) { | 897 switch (num_commits_) { |
898 case 1: | 898 case 1: |
899 if (layer_tree_host()->settings().impl_side_painting) { | 899 if (host_impl->settings().impl_side_painting) { |
900 EXPECT_EQ(0u, root_picture->release_resources_count()); | 900 EXPECT_EQ(0u, root_picture->release_resources_count()); |
901 EXPECT_EQ(0u, child_picture->release_resources_count()); | 901 EXPECT_EQ(0u, child_picture->release_resources_count()); |
902 EXPECT_EQ(0u, grandchild_picture->release_resources_count()); | 902 EXPECT_EQ(0u, grandchild_picture->release_resources_count()); |
903 } else { | 903 } else { |
904 EXPECT_EQ(0u, root_content->lost_output_surface_count()); | 904 EXPECT_EQ(0u, root_content->lost_output_surface_count()); |
905 EXPECT_EQ(0u, child_content->lost_output_surface_count()); | 905 EXPECT_EQ(0u, child_content->lost_output_surface_count()); |
906 EXPECT_EQ(0u, grandchild_content->lost_output_surface_count()); | 906 EXPECT_EQ(0u, grandchild_content->lost_output_surface_count()); |
907 } | 907 } |
908 | 908 |
909 // Lose the context and struggle to recreate it. | 909 // Lose the context and struggle to recreate it. |
910 LoseContext(); | 910 LoseContext(); |
911 times_to_fail_create_ = 1; | 911 times_to_fail_create_ = 1; |
912 break; | 912 break; |
913 case 2: | 913 case 2: |
914 if (layer_tree_host()->settings().impl_side_painting) { | 914 if (host_impl->settings().impl_side_painting) { |
915 EXPECT_TRUE(root_picture->release_resources_count()); | 915 EXPECT_TRUE(root_picture->release_resources_count()); |
916 EXPECT_TRUE(child_picture->release_resources_count()); | 916 EXPECT_TRUE(child_picture->release_resources_count()); |
917 EXPECT_TRUE(grandchild_picture->release_resources_count()); | 917 EXPECT_TRUE(grandchild_picture->release_resources_count()); |
918 } else { | 918 } else { |
919 EXPECT_TRUE(root_content->lost_output_surface_count()); | 919 EXPECT_TRUE(root_content->lost_output_surface_count()); |
920 EXPECT_TRUE(child_content->lost_output_surface_count()); | 920 EXPECT_TRUE(child_content->lost_output_surface_count()); |
921 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); | 921 EXPECT_TRUE(grandchild_content->lost_output_surface_count()); |
922 } | 922 } |
923 | 923 |
924 EndTest(); | 924 EndTest(); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 } | 1262 } |
1263 }; | 1263 }; |
1264 | 1264 |
1265 class UIResourceLostTestSimple : public UIResourceLostTest { | 1265 class UIResourceLostTestSimple : public UIResourceLostTest { |
1266 public: | 1266 public: |
1267 // This is called when the commit is complete and the new layer tree has been | 1267 // This is called when the commit is complete and the new layer tree has been |
1268 // activated. | 1268 // activated. |
1269 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; | 1269 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; |
1270 | 1270 |
1271 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1271 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
1272 if (!layer_tree_host()->settings().impl_side_painting) { | 1272 if (!impl->settings().impl_side_painting) { |
1273 StepCompleteOnImplThread(impl); | 1273 StepCompleteOnImplThread(impl); |
1274 PostStepCompleteToMainThread(); | 1274 PostStepCompleteToMainThread(); |
1275 ++time_step_; | 1275 ++time_step_; |
1276 } | 1276 } |
1277 } | 1277 } |
1278 | 1278 |
1279 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 1279 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
1280 if (layer_tree_host()->settings().impl_side_painting) { | 1280 if (impl->settings().impl_side_painting) { |
1281 StepCompleteOnImplThread(impl); | 1281 StepCompleteOnImplThread(impl); |
1282 PostStepCompleteToMainThread(); | 1282 PostStepCompleteToMainThread(); |
1283 ++time_step_; | 1283 ++time_step_; |
1284 } | 1284 } |
1285 } | 1285 } |
1286 }; | 1286 }; |
1287 | 1287 |
1288 // Losing context after an UI resource has been created. | 1288 // Losing context after an UI resource has been created. |
1289 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { | 1289 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
1290 public: | 1290 public: |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 void AfterTest() override {} | 1734 void AfterTest() override {} |
1735 | 1735 |
1736 bool deferred_; | 1736 bool deferred_; |
1737 }; | 1737 }; |
1738 | 1738 |
1739 SINGLE_AND_MULTI_THREAD_TEST_F( | 1739 SINGLE_AND_MULTI_THREAD_TEST_F( |
1740 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1740 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
1741 | 1741 |
1742 } // namespace | 1742 } // namespace |
1743 } // namespace cc | 1743 } // namespace cc |
OLD | NEW |