OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 scoped_ptr<DelegatedFrameData> CreateFrameData( | 78 scoped_ptr<DelegatedFrameData> CreateFrameData( |
79 const gfx::Rect& root_output_rect, | 79 const gfx::Rect& root_output_rect, |
80 const gfx::Rect& root_damage_rect) { | 80 const gfx::Rect& root_damage_rect) { |
81 scoped_ptr<DelegatedFrameData> frame(new DelegatedFrameData); | 81 scoped_ptr<DelegatedFrameData> frame(new DelegatedFrameData); |
82 | 82 |
83 scoped_ptr<RenderPass> root_pass(RenderPass::Create()); | 83 scoped_ptr<RenderPass> root_pass(RenderPass::Create()); |
84 root_pass->SetNew(RenderPassId(1, 1), | 84 root_pass->SetNew(RenderPassId(1, 1), |
85 root_output_rect, | 85 root_output_rect, |
86 root_damage_rect, | 86 root_damage_rect, |
87 gfx::Transform()); | 87 gfx::Transform()); |
88 frame->render_pass_list.push_back(root_pass.Pass()); | 88 frame->render_pass_list.push_back(std::move(root_pass)); |
89 return frame.Pass(); | 89 return frame; |
90 } | 90 } |
91 | 91 |
92 scoped_ptr<DelegatedFrameData> CreateInvalidFrameData( | 92 scoped_ptr<DelegatedFrameData> CreateInvalidFrameData( |
93 const gfx::Rect& root_output_rect, | 93 const gfx::Rect& root_output_rect, |
94 const gfx::Rect& root_damage_rect) { | 94 const gfx::Rect& root_damage_rect) { |
95 scoped_ptr<DelegatedFrameData> frame(new DelegatedFrameData); | 95 scoped_ptr<DelegatedFrameData> frame(new DelegatedFrameData); |
96 | 96 |
97 scoped_ptr<RenderPass> root_pass(RenderPass::Create()); | 97 scoped_ptr<RenderPass> root_pass(RenderPass::Create()); |
98 root_pass->SetNew(RenderPassId(1, 1), | 98 root_pass->SetNew(RenderPassId(1, 1), |
99 root_output_rect, | 99 root_output_rect, |
(...skipping 24 matching lines...) Expand all Loading... |
124 visible_rect, | 124 visible_rect, |
125 resource_id, | 125 resource_id, |
126 premultiplied_alpha, | 126 premultiplied_alpha, |
127 uv_top_left, | 127 uv_top_left, |
128 uv_bottom_right, | 128 uv_bottom_right, |
129 background_color, | 129 background_color, |
130 vertex_opacity, | 130 vertex_opacity, |
131 flipped, | 131 flipped, |
132 nearest_neighbor); | 132 nearest_neighbor); |
133 | 133 |
134 frame->render_pass_list.push_back(root_pass.Pass()); | 134 frame->render_pass_list.push_back(std::move(root_pass)); |
135 return frame.Pass(); | 135 return frame; |
136 } | 136 } |
137 | 137 |
138 void AddTransferableResource(DelegatedFrameData* frame, | 138 void AddTransferableResource(DelegatedFrameData* frame, |
139 ResourceId resource_id) { | 139 ResourceId resource_id) { |
140 TransferableResource resource; | 140 TransferableResource resource; |
141 resource.id = resource_id; | 141 resource.id = resource_id; |
142 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 142 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
143 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = { | 143 GLbyte arbitrary_mailbox[GL_MAILBOX_SIZE_CHROMIUM] = { |
144 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, | 144 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, |
145 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, | 145 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 void BeginTest() override { | 250 void BeginTest() override { |
251 resource_collection_->SetClient(this); | 251 resource_collection_->SetClient(this); |
252 PostSetNeedsCommitToMainThread(); | 252 PostSetNeedsCommitToMainThread(); |
253 } | 253 } |
254 | 254 |
255 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data) { | 255 void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data) { |
256 RenderPass* root_pass = frame_data->render_pass_list.back().get(); | 256 RenderPass* root_pass = frame_data->render_pass_list.back().get(); |
257 gfx::Size frame_size = root_pass->output_rect.size(); | 257 gfx::Size frame_size = root_pass->output_rect.size(); |
258 | 258 |
259 if (frame_provider_.get() && frame_size == frame_provider_->frame_size()) { | 259 if (frame_provider_.get() && frame_size == frame_provider_->frame_size()) { |
260 frame_provider_->SetFrameData(frame_data.Pass()); | 260 frame_provider_->SetFrameData(std::move(frame_data)); |
261 return; | 261 return; |
262 } | 262 } |
263 | 263 |
264 if (delegated_.get()) { | 264 if (delegated_.get()) { |
265 delegated_->RemoveFromParent(); | 265 delegated_->RemoveFromParent(); |
266 delegated_ = NULL; | 266 delegated_ = NULL; |
267 frame_provider_ = NULL; | 267 frame_provider_ = NULL; |
268 } | 268 } |
269 | 269 |
270 frame_provider_ = new DelegatedFrameProvider(resource_collection_.get(), | 270 frame_provider_ = new DelegatedFrameProvider(resource_collection_.get(), |
271 frame_data.Pass()); | 271 std::move(frame_data)); |
272 | 272 |
273 delegated_ = CreateDelegatedLayer(frame_provider_.get()); | 273 delegated_ = CreateDelegatedLayer(frame_provider_.get()); |
274 } | 274 } |
275 | 275 |
276 scoped_refptr<DelegatedRendererLayer> CreateDelegatedLayer( | 276 scoped_refptr<DelegatedRendererLayer> CreateDelegatedLayer( |
277 DelegatedFrameProvider* frame_provider) { | 277 DelegatedFrameProvider* frame_provider) { |
278 scoped_refptr<DelegatedRendererLayer> delegated = | 278 scoped_refptr<DelegatedRendererLayer> delegated = |
279 FakeDelegatedRendererLayer::Create(layer_settings(), frame_provider); | 279 FakeDelegatedRendererLayer::Create(layer_settings(), frame_provider); |
280 delegated->SetBounds(gfx::Size(10, 10)); | 280 delegated->SetBounds(gfx::Size(10, 10)); |
281 delegated->SetIsDrawable(true); | 281 delegated->SetIsDrawable(true); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost() | 414 LayerTreeHostDelegatedTestInvalidFrameAfterContextLost() |
415 : num_activates_(0), num_output_surfaces_initialized_(0) {} | 415 : num_activates_(0), num_output_surfaces_initialized_(0) {} |
416 | 416 |
417 void DidCommit() override { | 417 void DidCommit() override { |
418 if (TestEnded()) | 418 if (TestEnded()) |
419 return; | 419 return; |
420 scoped_ptr<DelegatedFrameData> frame1 = | 420 scoped_ptr<DelegatedFrameData> frame1 = |
421 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 421 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
422 AddTextureQuad(frame1.get(), 999); | 422 AddTextureQuad(frame1.get(), 999); |
423 AddTransferableResource(frame1.get(), 999); | 423 AddTransferableResource(frame1.get(), 999); |
424 SetFrameData(frame1.Pass()); | 424 SetFrameData(std::move(frame1)); |
425 } | 425 } |
426 | 426 |
427 void DidInitializeOutputSurface() override { | 427 void DidInitializeOutputSurface() override { |
428 if (!num_output_surfaces_initialized_++) | 428 if (!num_output_surfaces_initialized_++) |
429 return; | 429 return; |
430 | 430 |
431 scoped_refptr<DelegatedRendererLayer> old_delegated = delegated_; | 431 scoped_refptr<DelegatedRendererLayer> old_delegated = delegated_; |
432 SetFrameData( | 432 SetFrameData( |
433 CreateInvalidFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); | 433 CreateInvalidFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1))); |
434 // Make sure we end up using the same layer, or we won't test the right | 434 // Make sure we end up using the same layer, or we won't test the right |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 689 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
690 public: | 690 public: |
691 void BeginTest() override { | 691 void BeginTest() override { |
692 // Push two frames to the delegated renderer layer with no commit between. | 692 // Push two frames to the delegated renderer layer with no commit between. |
693 | 693 |
694 // The first frame has resource 999. | 694 // The first frame has resource 999. |
695 scoped_ptr<DelegatedFrameData> frame1 = | 695 scoped_ptr<DelegatedFrameData> frame1 = |
696 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 696 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
697 AddTextureQuad(frame1.get(), 999); | 697 AddTextureQuad(frame1.get(), 999); |
698 AddTransferableResource(frame1.get(), 999); | 698 AddTransferableResource(frame1.get(), 999); |
699 SetFrameData(frame1.Pass()); | 699 SetFrameData(std::move(frame1)); |
700 | 700 |
701 // The second frame uses resource 999 still, but also adds 555. | 701 // The second frame uses resource 999 still, but also adds 555. |
702 scoped_ptr<DelegatedFrameData> frame2 = | 702 scoped_ptr<DelegatedFrameData> frame2 = |
703 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 703 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
704 AddTextureQuad(frame2.get(), 999); | 704 AddTextureQuad(frame2.get(), 999); |
705 AddTransferableResource(frame2.get(), 999); | 705 AddTransferableResource(frame2.get(), 999); |
706 AddTextureQuad(frame2.get(), 555); | 706 AddTextureQuad(frame2.get(), 555); |
707 AddTransferableResource(frame2.get(), 555); | 707 AddTransferableResource(frame2.get(), 555); |
708 SetFrameData(frame2.Pass()); | 708 SetFrameData(std::move(frame2)); |
709 | 709 |
710 // The resource 999 from frame1 is returned since it is still on the main | 710 // The resource 999 from frame1 is returned since it is still on the main |
711 // thread. | 711 // thread. |
712 ReturnedResourceArray returned_resources; | 712 ReturnedResourceArray returned_resources; |
713 resource_collection_->TakeUnusedResourcesForChildCompositor( | 713 resource_collection_->TakeUnusedResourcesForChildCompositor( |
714 &returned_resources); | 714 &returned_resources); |
715 { | 715 { |
716 unsigned expected[] = {999}; | 716 unsigned expected[] = {999}; |
717 EXPECT_RESOURCES(expected, returned_resources); | 717 EXPECT_RESOURCES(expected, returned_resources); |
718 EXPECT_TRUE(TestAndResetAvailable()); | 718 EXPECT_TRUE(TestAndResetAvailable()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { | 750 : public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer { |
751 public: | 751 public: |
752 void BeginTest() override { | 752 void BeginTest() override { |
753 // Generate a frame with two resources in it. | 753 // Generate a frame with two resources in it. |
754 scoped_ptr<DelegatedFrameData> frame = | 754 scoped_ptr<DelegatedFrameData> frame = |
755 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 755 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
756 AddTextureQuad(frame.get(), 999); | 756 AddTextureQuad(frame.get(), 999); |
757 AddTransferableResource(frame.get(), 999); | 757 AddTransferableResource(frame.get(), 999); |
758 AddTextureQuad(frame.get(), 555); | 758 AddTextureQuad(frame.get(), 555); |
759 AddTransferableResource(frame.get(), 555); | 759 AddTransferableResource(frame.get(), 555); |
760 SetFrameData(frame.Pass()); | 760 SetFrameData(std::move(frame)); |
761 | 761 |
762 PostSetNeedsCommitToMainThread(); | 762 PostSetNeedsCommitToMainThread(); |
763 } | 763 } |
764 | 764 |
765 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 765 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
766 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); | 766 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
767 FakeDelegatedRendererLayerImpl* delegated_impl = | 767 FakeDelegatedRendererLayerImpl* delegated_impl = |
768 static_cast<FakeDelegatedRendererLayerImpl*>( | 768 static_cast<FakeDelegatedRendererLayerImpl*>( |
769 root_impl->children()[0].get()); | 769 root_impl->children()[0].get()); |
770 | 770 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 807 |
808 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 808 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
809 switch (next_source_frame_number) { | 809 switch (next_source_frame_number) { |
810 case 1: | 810 case 1: |
811 // Generate a frame with two resources in it. | 811 // Generate a frame with two resources in it. |
812 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 812 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
813 AddTextureQuad(frame.get(), 999); | 813 AddTextureQuad(frame.get(), 999); |
814 AddTransferableResource(frame.get(), 999); | 814 AddTransferableResource(frame.get(), 999); |
815 AddTextureQuad(frame.get(), 555); | 815 AddTextureQuad(frame.get(), 555); |
816 AddTransferableResource(frame.get(), 555); | 816 AddTransferableResource(frame.get(), 555); |
817 SetFrameData(frame.Pass()); | 817 SetFrameData(std::move(frame)); |
818 break; | 818 break; |
819 case 2: | 819 case 2: |
820 // All of the resources are in use. | 820 // All of the resources are in use. |
821 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 821 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
822 EXPECT_EQ(0u, resources.size()); | 822 EXPECT_EQ(0u, resources.size()); |
823 EXPECT_FALSE(TestAndResetAvailable()); | 823 EXPECT_FALSE(TestAndResetAvailable()); |
824 | 824 |
825 // Keep using 999 but stop using 555. | 825 // Keep using 999 but stop using 555. |
826 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 826 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
827 AddTextureQuad(frame.get(), 999); | 827 AddTextureQuad(frame.get(), 999); |
828 AddTransferableResource(frame.get(), 999); | 828 AddTransferableResource(frame.get(), 999); |
829 AddTextureQuad(frame.get(), 444); | 829 AddTextureQuad(frame.get(), 444); |
830 AddTransferableResource(frame.get(), 444); | 830 AddTransferableResource(frame.get(), 444); |
831 SetFrameData(frame.Pass()); | 831 SetFrameData(std::move(frame)); |
832 break; | 832 break; |
833 case 3: | 833 case 3: |
834 // 555 is no longer in use. | 834 // 555 is no longer in use. |
835 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 835 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
836 { | 836 { |
837 unsigned expected[] = {555}; | 837 unsigned expected[] = {555}; |
838 EXPECT_RESOURCES(expected, resources); | 838 EXPECT_RESOURCES(expected, resources); |
839 EXPECT_TRUE(TestAndResetAvailable()); | 839 EXPECT_TRUE(TestAndResetAvailable()); |
840 } | 840 } |
841 | 841 |
842 // Stop using any resources. | 842 // Stop using any resources. |
843 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 843 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
844 SetFrameData(frame.Pass()); | 844 SetFrameData(std::move(frame)); |
845 break; | 845 break; |
846 case 4: | 846 case 4: |
847 // Postpone collecting resources for a frame. They should still be there | 847 // Postpone collecting resources for a frame. They should still be there |
848 // the next frame. | 848 // the next frame. |
849 layer_tree_host()->SetNeedsCommit(); | 849 layer_tree_host()->SetNeedsCommit(); |
850 return; | 850 return; |
851 case 5: | 851 case 5: |
852 // 444 and 999 are no longer in use. We sent two refs to 999, so we | 852 // 444 and 999 are no longer in use. We sent two refs to 999, so we |
853 // should get two back. | 853 // should get two back. |
854 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 854 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 switch (next_source_frame_number) { | 890 switch (next_source_frame_number) { |
891 case 1: | 891 case 1: |
892 // Generate a frame with some resources in it. | 892 // Generate a frame with some resources in it. |
893 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 893 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
894 AddTextureQuad(frame.get(), 999); | 894 AddTextureQuad(frame.get(), 999); |
895 AddTransferableResource(frame.get(), 999); | 895 AddTransferableResource(frame.get(), 999); |
896 AddTextureQuad(frame.get(), 555); | 896 AddTextureQuad(frame.get(), 555); |
897 AddTransferableResource(frame.get(), 555); | 897 AddTransferableResource(frame.get(), 555); |
898 AddTextureQuad(frame.get(), 444); | 898 AddTextureQuad(frame.get(), 444); |
899 AddTransferableResource(frame.get(), 444); | 899 AddTransferableResource(frame.get(), 444); |
900 SetFrameData(frame.Pass()); | 900 SetFrameData(std::move(frame)); |
901 break; | 901 break; |
902 case 2: | 902 case 2: |
903 // All of the resources are in use. | 903 // All of the resources are in use. |
904 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 904 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
905 EXPECT_EQ(0u, resources.size()); | 905 EXPECT_EQ(0u, resources.size()); |
906 EXPECT_FALSE(TestAndResetAvailable()); | 906 EXPECT_FALSE(TestAndResetAvailable()); |
907 | 907 |
908 // Keep using 999 but stop using 555 and 444. | 908 // Keep using 999 but stop using 555 and 444. |
909 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 909 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
910 AddTextureQuad(frame.get(), 999); | 910 AddTextureQuad(frame.get(), 999); |
911 AddTransferableResource(frame.get(), 999); | 911 AddTransferableResource(frame.get(), 999); |
912 SetFrameData(frame.Pass()); | 912 SetFrameData(std::move(frame)); |
913 | 913 |
914 // Resource are not immediately released. | 914 // Resource are not immediately released. |
915 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 915 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
916 EXPECT_EQ(0u, resources.size()); | 916 EXPECT_EQ(0u, resources.size()); |
917 EXPECT_FALSE(TestAndResetAvailable()); | 917 EXPECT_FALSE(TestAndResetAvailable()); |
918 | 918 |
919 // Now using 555 and 444 again, but not 999. | 919 // Now using 555 and 444 again, but not 999. |
920 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 920 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
921 AddTextureQuad(frame.get(), 555); | 921 AddTextureQuad(frame.get(), 555); |
922 AddTransferableResource(frame.get(), 555); | 922 AddTransferableResource(frame.get(), 555); |
923 AddTextureQuad(frame.get(), 444); | 923 AddTextureQuad(frame.get(), 444); |
924 AddTransferableResource(frame.get(), 444); | 924 AddTransferableResource(frame.get(), 444); |
925 SetFrameData(frame.Pass()); | 925 SetFrameData(std::move(frame)); |
926 break; | 926 break; |
927 case 3: | 927 case 3: |
928 // The 999 resource is the only unused one. Two references were sent, so | 928 // The 999 resource is the only unused one. Two references were sent, so |
929 // two should be returned. | 929 // two should be returned. |
930 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 930 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
931 { | 931 { |
932 unsigned expected[] = {999, 999}; | 932 unsigned expected[] = {999, 999}; |
933 EXPECT_RESOURCES(expected, resources); | 933 EXPECT_RESOURCES(expected, resources); |
934 EXPECT_TRUE(TestAndResetAvailable()); | 934 EXPECT_TRUE(TestAndResetAvailable()); |
935 } | 935 } |
(...skipping 22 matching lines...) Expand all Loading... |
958 switch (next_source_frame_number) { | 958 switch (next_source_frame_number) { |
959 case 1: | 959 case 1: |
960 // Generate a frame with some resources in it. | 960 // Generate a frame with some resources in it. |
961 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 961 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
962 AddTextureQuad(frame.get(), 999); | 962 AddTextureQuad(frame.get(), 999); |
963 AddTransferableResource(frame.get(), 999); | 963 AddTransferableResource(frame.get(), 999); |
964 AddTextureQuad(frame.get(), 555); | 964 AddTextureQuad(frame.get(), 555); |
965 AddTransferableResource(frame.get(), 555); | 965 AddTransferableResource(frame.get(), 555); |
966 AddTextureQuad(frame.get(), 444); | 966 AddTextureQuad(frame.get(), 444); |
967 AddTransferableResource(frame.get(), 444); | 967 AddTransferableResource(frame.get(), 444); |
968 SetFrameData(frame.Pass()); | 968 SetFrameData(std::move(frame)); |
969 break; | 969 break; |
970 case 2: | 970 case 2: |
971 // All of the resources are in use. | 971 // All of the resources are in use. |
972 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 972 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
973 EXPECT_EQ(0u, resources.size()); | 973 EXPECT_EQ(0u, resources.size()); |
974 EXPECT_FALSE(TestAndResetAvailable()); | 974 EXPECT_FALSE(TestAndResetAvailable()); |
975 | 975 |
976 // Keep using 999 but stop using 555 and 444. | 976 // Keep using 999 but stop using 555 and 444. |
977 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 977 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
978 AddTextureQuad(frame.get(), 999); | 978 AddTextureQuad(frame.get(), 999); |
979 AddTransferableResource(frame.get(), 999); | 979 AddTransferableResource(frame.get(), 999); |
980 SetFrameData(frame.Pass()); | 980 SetFrameData(std::move(frame)); |
981 | 981 |
982 // Resource are not immediately released. | 982 // Resource are not immediately released. |
983 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 983 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
984 EXPECT_EQ(0u, resources.size()); | 984 EXPECT_EQ(0u, resources.size()); |
985 EXPECT_FALSE(TestAndResetAvailable()); | 985 EXPECT_FALSE(TestAndResetAvailable()); |
986 | 986 |
987 // The parent compositor (this one) does a commit. | 987 // The parent compositor (this one) does a commit. |
988 break; | 988 break; |
989 case 3: | 989 case 3: |
990 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 990 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
991 { | 991 { |
992 unsigned expected[] = {444, 555}; | 992 unsigned expected[] = {444, 555}; |
993 EXPECT_RESOURCES(expected, resources); | 993 EXPECT_RESOURCES(expected, resources); |
994 EXPECT_TRUE(TestAndResetAvailable()); | 994 EXPECT_TRUE(TestAndResetAvailable()); |
995 } | 995 } |
996 | 996 |
997 // The child compositor sends a frame referring to resources not in the | 997 // The child compositor sends a frame referring to resources not in the |
998 // frame. | 998 // frame. |
999 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 999 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1000 AddTextureQuad(frame.get(), 999); | 1000 AddTextureQuad(frame.get(), 999); |
1001 AddTextureQuad(frame.get(), 555); | 1001 AddTextureQuad(frame.get(), 555); |
1002 AddTextureQuad(frame.get(), 444); | 1002 AddTextureQuad(frame.get(), 444); |
1003 SetFrameData(frame.Pass()); | 1003 SetFrameData(std::move(frame)); |
1004 break; | 1004 break; |
1005 } | 1005 } |
1006 } | 1006 } |
1007 | 1007 |
1008 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 1008 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
1009 if (host_impl->active_tree()->source_frame_number() != 3) | 1009 if (host_impl->active_tree()->source_frame_number() != 3) |
1010 return; | 1010 return; |
1011 | 1011 |
1012 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); | 1012 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
1013 FakeDelegatedRendererLayerImpl* delegated_impl = | 1013 FakeDelegatedRendererLayerImpl* delegated_impl = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 switch (next_source_frame_number) { | 1056 switch (next_source_frame_number) { |
1057 case 1: | 1057 case 1: |
1058 // Generate a frame with some resources in it. | 1058 // Generate a frame with some resources in it. |
1059 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1059 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1060 AddTextureQuad(frame.get(), 999); | 1060 AddTextureQuad(frame.get(), 999); |
1061 AddTransferableResource(frame.get(), 999); | 1061 AddTransferableResource(frame.get(), 999); |
1062 AddTextureQuad(frame.get(), 555); | 1062 AddTextureQuad(frame.get(), 555); |
1063 AddTransferableResource(frame.get(), 555); | 1063 AddTransferableResource(frame.get(), 555); |
1064 AddTextureQuad(frame.get(), 444); | 1064 AddTextureQuad(frame.get(), 444); |
1065 AddTransferableResource(frame.get(), 444); | 1065 AddTransferableResource(frame.get(), 444); |
1066 SetFrameData(frame.Pass()); | 1066 SetFrameData(std::move(frame)); |
1067 break; | 1067 break; |
1068 case 2: | 1068 case 2: |
1069 // All of the resources are in use. | 1069 // All of the resources are in use. |
1070 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1070 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1071 EXPECT_EQ(0u, resources.size()); | 1071 EXPECT_EQ(0u, resources.size()); |
1072 EXPECT_FALSE(TestAndResetAvailable()); | 1072 EXPECT_FALSE(TestAndResetAvailable()); |
1073 | 1073 |
1074 // Keep using 999 but stop using 555 and 444. | 1074 // Keep using 999 but stop using 555 and 444. |
1075 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1075 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1076 AddTextureQuad(frame.get(), 999); | 1076 AddTextureQuad(frame.get(), 999); |
1077 AddTransferableResource(frame.get(), 999); | 1077 AddTransferableResource(frame.get(), 999); |
1078 SetFrameData(frame.Pass()); | 1078 SetFrameData(std::move(frame)); |
1079 | 1079 |
1080 // Resource are not immediately released. | 1080 // Resource are not immediately released. |
1081 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1081 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1082 EXPECT_EQ(0u, resources.size()); | 1082 EXPECT_EQ(0u, resources.size()); |
1083 EXPECT_FALSE(TestAndResetAvailable()); | 1083 EXPECT_FALSE(TestAndResetAvailable()); |
1084 | 1084 |
1085 // The parent compositor (this one) does a commit. | 1085 // The parent compositor (this one) does a commit. |
1086 break; | 1086 break; |
1087 case 3: | 1087 case 3: |
1088 // The child compositor sends a frame before taking resources back | 1088 // The child compositor sends a frame before taking resources back |
1089 // from the previous commit. This frame makes use of the resources 555 | 1089 // from the previous commit. This frame makes use of the resources 555 |
1090 // and 444, which were just released during commit. | 1090 // and 444, which were just released during commit. |
1091 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1091 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1092 AddTextureQuad(frame.get(), 999); | 1092 AddTextureQuad(frame.get(), 999); |
1093 AddTransferableResource(frame.get(), 999); | 1093 AddTransferableResource(frame.get(), 999); |
1094 AddTextureQuad(frame.get(), 555); | 1094 AddTextureQuad(frame.get(), 555); |
1095 AddTransferableResource(frame.get(), 555); | 1095 AddTransferableResource(frame.get(), 555); |
1096 AddTextureQuad(frame.get(), 444); | 1096 AddTextureQuad(frame.get(), 444); |
1097 AddTransferableResource(frame.get(), 444); | 1097 AddTransferableResource(frame.get(), 444); |
1098 SetFrameData(frame.Pass()); | 1098 SetFrameData(std::move(frame)); |
1099 | 1099 |
1100 // The resources are used by the new frame but are returned anyway since | 1100 // The resources are used by the new frame but are returned anyway since |
1101 // we passed them again. | 1101 // we passed them again. |
1102 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1102 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1103 { | 1103 { |
1104 unsigned expected[] = {444, 555}; | 1104 unsigned expected[] = {444, 555}; |
1105 EXPECT_RESOURCES(expected, resources); | 1105 EXPECT_RESOURCES(expected, resources); |
1106 EXPECT_TRUE(TestAndResetAvailable()); | 1106 EXPECT_TRUE(TestAndResetAvailable()); |
1107 } | 1107 } |
1108 break; | 1108 break; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 | 1172 |
1173 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1173 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1174 switch (next_source_frame_number) { | 1174 switch (next_source_frame_number) { |
1175 case 1: | 1175 case 1: |
1176 // Generate a frame with some resources in it. | 1176 // Generate a frame with some resources in it. |
1177 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1177 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1178 AddTextureQuad(frame.get(), 999); | 1178 AddTextureQuad(frame.get(), 999); |
1179 AddTransferableResource(frame.get(), 999); | 1179 AddTransferableResource(frame.get(), 999); |
1180 AddTextureQuad(frame.get(), 555); | 1180 AddTextureQuad(frame.get(), 555); |
1181 AddTransferableResource(frame.get(), 555); | 1181 AddTransferableResource(frame.get(), 555); |
1182 SetFrameData(frame.Pass()); | 1182 SetFrameData(std::move(frame)); |
1183 break; | 1183 break; |
1184 case 2: | 1184 case 2: |
1185 // All of the resources are in use. | 1185 // All of the resources are in use. |
1186 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1186 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1187 EXPECT_EQ(0u, resources.size()); | 1187 EXPECT_EQ(0u, resources.size()); |
1188 EXPECT_FALSE(TestAndResetAvailable()); | 1188 EXPECT_FALSE(TestAndResetAvailable()); |
1189 | 1189 |
1190 // Generate a bad frame with a resource the layer doesn't have. The | 1190 // Generate a bad frame with a resource the layer doesn't have. The |
1191 // 885 and 775 resources are unknown, while ownership of the legit 444 | 1191 // 885 and 775 resources are unknown, while ownership of the legit 444 |
1192 // resource is passed in here. The bad frame does not use any of the | 1192 // resource is passed in here. The bad frame does not use any of the |
1193 // previous resources, 999 or 555. | 1193 // previous resources, 999 or 555. |
1194 // A bad quad is present both before and after the good quad. | 1194 // A bad quad is present both before and after the good quad. |
1195 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1195 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1196 AddTextureQuad(frame.get(), 885); | 1196 AddTextureQuad(frame.get(), 885); |
1197 AddTextureQuad(frame.get(), 444); | 1197 AddTextureQuad(frame.get(), 444); |
1198 AddTransferableResource(frame.get(), 444); | 1198 AddTransferableResource(frame.get(), 444); |
1199 AddTextureQuad(frame.get(), 775); | 1199 AddTextureQuad(frame.get(), 775); |
1200 SetFrameData(frame.Pass()); | 1200 SetFrameData(std::move(frame)); |
1201 | 1201 |
1202 // The parent compositor (this one) does a commit. | 1202 // The parent compositor (this one) does a commit. |
1203 break; | 1203 break; |
1204 case 3: | 1204 case 3: |
1205 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1205 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1206 EXPECT_EQ(0u, resources.size()); | 1206 EXPECT_EQ(0u, resources.size()); |
1207 EXPECT_FALSE(TestAndResetAvailable()); | 1207 EXPECT_FALSE(TestAndResetAvailable()); |
1208 | 1208 |
1209 // Now send a good frame with 999 again. | 1209 // Now send a good frame with 999 again. |
1210 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1210 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1211 AddTextureQuad(frame.get(), 999); | 1211 AddTextureQuad(frame.get(), 999); |
1212 SetFrameData(frame.Pass()); | 1212 SetFrameData(std::move(frame)); |
1213 | 1213 |
1214 // The bad frame's resource is given back to the child compositor. | 1214 // The bad frame's resource is given back to the child compositor. |
1215 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1215 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1216 { | 1216 { |
1217 unsigned expected[] = {444}; | 1217 unsigned expected[] = {444}; |
1218 EXPECT_RESOURCES(expected, resources); | 1218 EXPECT_RESOURCES(expected, resources); |
1219 EXPECT_TRUE(TestAndResetAvailable()); | 1219 EXPECT_TRUE(TestAndResetAvailable()); |
1220 } | 1220 } |
1221 break; | 1221 break; |
1222 case 4: | 1222 case 4: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 ReturnedResourceArray resources; | 1326 ReturnedResourceArray resources; |
1327 | 1327 |
1328 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1328 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1329 switch (next_source_frame_number) { | 1329 switch (next_source_frame_number) { |
1330 case 1: | 1330 case 1: |
1331 // This frame includes two resources in it, but only uses one. | 1331 // This frame includes two resources in it, but only uses one. |
1332 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1332 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1333 AddTransferableResource(frame.get(), 999); | 1333 AddTransferableResource(frame.get(), 999); |
1334 AddTextureQuad(frame.get(), 555); | 1334 AddTextureQuad(frame.get(), 555); |
1335 AddTransferableResource(frame.get(), 555); | 1335 AddTransferableResource(frame.get(), 555); |
1336 SetFrameData(frame.Pass()); | 1336 SetFrameData(std::move(frame)); |
1337 break; | 1337 break; |
1338 case 2: | 1338 case 2: |
1339 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1339 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1340 EXPECT_EQ(0u, resources.size()); | 1340 EXPECT_EQ(0u, resources.size()); |
1341 EXPECT_FALSE(TestAndResetAvailable()); | 1341 EXPECT_FALSE(TestAndResetAvailable()); |
1342 | 1342 |
1343 // Now send an empty frame. | 1343 // Now send an empty frame. |
1344 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1344 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1345 SetFrameData(frame.Pass()); | 1345 SetFrameData(std::move(frame)); |
1346 | 1346 |
1347 // The unused resource should be returned. | 1347 // The unused resource should be returned. |
1348 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1348 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1349 { | 1349 { |
1350 unsigned expected[] = {999}; | 1350 unsigned expected[] = {999}; |
1351 EXPECT_RESOURCES(expected, resources); | 1351 EXPECT_RESOURCES(expected, resources); |
1352 EXPECT_TRUE(TestAndResetAvailable()); | 1352 EXPECT_TRUE(TestAndResetAvailable()); |
1353 } | 1353 } |
1354 | 1354 |
1355 EndTest(); | 1355 EndTest(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 | 1392 |
1393 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1393 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1394 switch (next_source_frame_number) { | 1394 switch (next_source_frame_number) { |
1395 case 1: | 1395 case 1: |
1396 // This frame includes two resources in it. | 1396 // This frame includes two resources in it. |
1397 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1397 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1398 AddTextureQuad(frame.get(), 999); | 1398 AddTextureQuad(frame.get(), 999); |
1399 AddTransferableResource(frame.get(), 999); | 1399 AddTransferableResource(frame.get(), 999); |
1400 AddTextureQuad(frame.get(), 555); | 1400 AddTextureQuad(frame.get(), 555); |
1401 AddTransferableResource(frame.get(), 555); | 1401 AddTransferableResource(frame.get(), 555); |
1402 SetFrameData(frame.Pass()); | 1402 SetFrameData(std::move(frame)); |
1403 | 1403 |
1404 // But then we immediately stop using 999. | 1404 // But then we immediately stop using 999. |
1405 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1405 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1406 AddTextureQuad(frame.get(), 555); | 1406 AddTextureQuad(frame.get(), 555); |
1407 AddTransferableResource(frame.get(), 555); | 1407 AddTransferableResource(frame.get(), 555); |
1408 SetFrameData(frame.Pass()); | 1408 SetFrameData(std::move(frame)); |
1409 break; | 1409 break; |
1410 case 2: | 1410 case 2: |
1411 // The unused resources should be returned. 555 is still used, but it's | 1411 // The unused resources should be returned. 555 is still used, but it's |
1412 // returned once to account for the first frame. | 1412 // returned once to account for the first frame. |
1413 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1413 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1414 { | 1414 { |
1415 unsigned expected[] = {555, 999}; | 1415 unsigned expected[] = {555, 999}; |
1416 EXPECT_RESOURCES(expected, resources); | 1416 EXPECT_RESOURCES(expected, resources); |
1417 EXPECT_TRUE(TestAndResetAvailable()); | 1417 EXPECT_TRUE(TestAndResetAvailable()); |
1418 } | 1418 } |
1419 // Send a frame with no resources in it. | 1419 // Send a frame with no resources in it. |
1420 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1420 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1421 SetFrameData(frame.Pass()); | 1421 SetFrameData(std::move(frame)); |
1422 break; | 1422 break; |
1423 case 3: | 1423 case 3: |
1424 // The now unused resource 555 should be returned. | 1424 // The now unused resource 555 should be returned. |
1425 resources.clear(); | 1425 resources.clear(); |
1426 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1426 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1427 { | 1427 { |
1428 unsigned expected[] = {555}; | 1428 unsigned expected[] = {555}; |
1429 EXPECT_RESOURCES(expected, resources); | 1429 EXPECT_RESOURCES(expected, resources); |
1430 EXPECT_TRUE(TestAndResetAvailable()); | 1430 EXPECT_TRUE(TestAndResetAvailable()); |
1431 } | 1431 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 | 1471 |
1472 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1472 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1473 switch (next_source_frame_number) { | 1473 switch (next_source_frame_number) { |
1474 case 1: | 1474 case 1: |
1475 // This frame includes two resources in it. | 1475 // This frame includes two resources in it. |
1476 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1476 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1477 AddTextureQuad(frame.get(), 999); | 1477 AddTextureQuad(frame.get(), 999); |
1478 AddTransferableResource(frame.get(), 999); | 1478 AddTransferableResource(frame.get(), 999); |
1479 AddTextureQuad(frame.get(), 555); | 1479 AddTextureQuad(frame.get(), 555); |
1480 AddTransferableResource(frame.get(), 555); | 1480 AddTransferableResource(frame.get(), 555); |
1481 SetFrameData(frame.Pass()); | 1481 SetFrameData(std::move(frame)); |
1482 break; | 1482 break; |
1483 case 2: | 1483 case 2: |
1484 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1484 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1485 EXPECT_EQ(0u, resources.size()); | 1485 EXPECT_EQ(0u, resources.size()); |
1486 EXPECT_FALSE(TestAndResetAvailable()); | 1486 EXPECT_FALSE(TestAndResetAvailable()); |
1487 | 1487 |
1488 // 999 is in use in the grandparent compositor, generate a frame without | 1488 // 999 is in use in the grandparent compositor, generate a frame without |
1489 // it present. | 1489 // it present. |
1490 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1490 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1491 AddTextureQuad(frame.get(), 555); | 1491 AddTextureQuad(frame.get(), 555); |
1492 AddTransferableResource(frame.get(), 555); | 1492 AddTransferableResource(frame.get(), 555); |
1493 SetFrameData(frame.Pass()); | 1493 SetFrameData(std::move(frame)); |
1494 break; | 1494 break; |
1495 case 3: | 1495 case 3: |
1496 // Since 999 is in the grandparent it is not returned. | 1496 // Since 999 is in the grandparent it is not returned. |
1497 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1497 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1498 EXPECT_EQ(0u, resources.size()); | 1498 EXPECT_EQ(0u, resources.size()); |
1499 EXPECT_FALSE(TestAndResetAvailable()); | 1499 EXPECT_FALSE(TestAndResetAvailable()); |
1500 | 1500 |
1501 // The impl side will get back the resource at some point. | 1501 // The impl side will get back the resource at some point. |
1502 ImplThreadTaskRunner()->PostTask(FROM_HERE, | 1502 ImplThreadTaskRunner()->PostTask(FROM_HERE, |
1503 receive_resource_on_thread_); | 1503 receive_resource_on_thread_); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1611 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1612 switch (next_source_frame_number) { | 1612 switch (next_source_frame_number) { |
1613 case 1: | 1613 case 1: |
1614 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1614 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1615 AddTextureQuad(frame.get(), 999); | 1615 AddTextureQuad(frame.get(), 999); |
1616 AddTransferableResource(frame.get(), 999); | 1616 AddTransferableResource(frame.get(), 999); |
1617 AddTextureQuad(frame.get(), 555); | 1617 AddTextureQuad(frame.get(), 555); |
1618 AddTransferableResource(frame.get(), 555); | 1618 AddTransferableResource(frame.get(), 555); |
1619 AddTextureQuad(frame.get(), 444); | 1619 AddTextureQuad(frame.get(), 444); |
1620 AddTransferableResource(frame.get(), 444); | 1620 AddTransferableResource(frame.get(), 444); |
1621 SetFrameData(frame.Pass()); | 1621 SetFrameData(std::move(frame)); |
1622 break; | 1622 break; |
1623 case 2: | 1623 case 2: |
1624 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1624 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1625 EXPECT_EQ(0u, resources.size()); | 1625 EXPECT_EQ(0u, resources.size()); |
1626 EXPECT_FALSE(TestAndResetAvailable()); | 1626 EXPECT_FALSE(TestAndResetAvailable()); |
1627 | 1627 |
1628 // Stop using 999 and 444 in this frame and commit. | 1628 // Stop using 999 and 444 in this frame and commit. |
1629 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1629 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1630 AddTextureQuad(frame.get(), 555); | 1630 AddTextureQuad(frame.get(), 555); |
1631 AddTransferableResource(frame.get(), 555); | 1631 AddTransferableResource(frame.get(), 555); |
1632 SetFrameData(frame.Pass()); | 1632 SetFrameData(std::move(frame)); |
1633 // 999 and 444 will be returned for frame 1, but not 555 since it's in | 1633 // 999 and 444 will be returned for frame 1, but not 555 since it's in |
1634 // the current frame. | 1634 // the current frame. |
1635 break; | 1635 break; |
1636 case 3: | 1636 case 3: |
1637 // Don't take resources here, but set a new frame that uses 999 again. | 1637 // Don't take resources here, but set a new frame that uses 999 again. |
1638 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1638 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1639 AddTextureQuad(frame.get(), 999); | 1639 AddTextureQuad(frame.get(), 999); |
1640 AddTransferableResource(frame.get(), 999); | 1640 AddTransferableResource(frame.get(), 999); |
1641 AddTextureQuad(frame.get(), 555); | 1641 AddTextureQuad(frame.get(), 555); |
1642 AddTransferableResource(frame.get(), 555); | 1642 AddTransferableResource(frame.get(), 555); |
1643 SetFrameData(frame.Pass()); | 1643 SetFrameData(std::move(frame)); |
1644 break; | 1644 break; |
1645 case 4: | 1645 case 4: |
1646 // 555 from frame 1 and 2 isn't returned since it's still in use. 999 | 1646 // 555 from frame 1 and 2 isn't returned since it's still in use. 999 |
1647 // from frame 1 is returned though. | 1647 // from frame 1 is returned though. |
1648 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1648 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1649 { | 1649 { |
1650 unsigned expected[] = {444, 999}; | 1650 unsigned expected[] = {444, 999}; |
1651 EXPECT_RESOURCES(expected, resources); | 1651 EXPECT_RESOURCES(expected, resources); |
1652 EXPECT_TRUE(TestAndResetAvailable()); | 1652 EXPECT_TRUE(TestAndResetAvailable()); |
1653 } | 1653 } |
1654 | 1654 |
1655 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1655 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1656 SetFrameData(frame.Pass()); | 1656 SetFrameData(std::move(frame)); |
1657 // 555 will be returned 3 times for frames 1 2 and 3, and 999 will be | 1657 // 555 will be returned 3 times for frames 1 2 and 3, and 999 will be |
1658 // returned once for frame 3. | 1658 // returned once for frame 3. |
1659 break; | 1659 break; |
1660 case 5: | 1660 case 5: |
1661 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1661 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1662 { | 1662 { |
1663 unsigned expected[] = {555, 555, 555, 999}; | 1663 unsigned expected[] = {555, 555, 555, 999}; |
1664 EXPECT_RESOURCES(expected, resources); | 1664 EXPECT_RESOURCES(expected, resources); |
1665 EXPECT_TRUE(TestAndResetAvailable()); | 1665 EXPECT_TRUE(TestAndResetAvailable()); |
1666 } | 1666 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 protected: | 1721 protected: |
1722 DelegatedFrameIsActivatedDuringCommit() : returned_resource_count_(0) {} | 1722 DelegatedFrameIsActivatedDuringCommit() : returned_resource_count_(0) {} |
1723 | 1723 |
1724 void BeginTest() override { | 1724 void BeginTest() override { |
1725 activate_count_ = 0; | 1725 activate_count_ = 0; |
1726 | 1726 |
1727 scoped_ptr<DelegatedFrameData> frame = | 1727 scoped_ptr<DelegatedFrameData> frame = |
1728 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1728 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1729 AddTextureQuad(frame.get(), 999); | 1729 AddTextureQuad(frame.get(), 999); |
1730 AddTransferableResource(frame.get(), 999); | 1730 AddTransferableResource(frame.get(), 999); |
1731 SetFrameData(frame.Pass()); | 1731 SetFrameData(std::move(frame)); |
1732 | 1732 |
1733 PostSetNeedsCommitToMainThread(); | 1733 PostSetNeedsCommitToMainThread(); |
1734 } | 1734 } |
1735 | 1735 |
1736 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 1736 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
1737 base::AutoLock lock(activate_count_lock_); | 1737 base::AutoLock lock(activate_count_lock_); |
1738 ++activate_count_; | 1738 ++activate_count_; |
1739 } | 1739 } |
1740 | 1740 |
1741 void DidCommit() override { | 1741 void DidCommit() override { |
1742 // The first frame doesn't cause anything to be returned so it does not | 1742 // The first frame doesn't cause anything to be returned so it does not |
1743 // need to wait for activation. | 1743 // need to wait for activation. |
1744 if (layer_tree_host()->source_frame_number() > 1) { | 1744 if (layer_tree_host()->source_frame_number() > 1) { |
1745 base::AutoLock lock(activate_count_lock_); | 1745 base::AutoLock lock(activate_count_lock_); |
1746 // The activate happened before commit is done on the main side. | 1746 // The activate happened before commit is done on the main side. |
1747 EXPECT_EQ(activate_count_, layer_tree_host()->source_frame_number()); | 1747 EXPECT_EQ(activate_count_, layer_tree_host()->source_frame_number()); |
1748 } | 1748 } |
1749 | 1749 |
1750 switch (layer_tree_host()->source_frame_number()) { | 1750 switch (layer_tree_host()->source_frame_number()) { |
1751 case 1: { | 1751 case 1: { |
1752 // The first frame has been committed and will activate. Set a new | 1752 // The first frame has been committed and will activate. Set a new |
1753 // frame, and expect the next commit to finish *after* it is activated. | 1753 // frame, and expect the next commit to finish *after* it is activated. |
1754 scoped_ptr<DelegatedFrameData> frame = | 1754 scoped_ptr<DelegatedFrameData> frame = |
1755 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1755 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1756 AddTextureQuad(frame.get(), 555); | 1756 AddTextureQuad(frame.get(), 555); |
1757 AddTransferableResource(frame.get(), 555); | 1757 AddTransferableResource(frame.get(), 555); |
1758 SetFrameData(frame.Pass()); | 1758 SetFrameData(std::move(frame)); |
1759 break; | 1759 break; |
1760 } | 1760 } |
1761 case 2: | 1761 case 2: |
1762 // The second frame has been activated. Remove the layer from | 1762 // The second frame has been activated. Remove the layer from |
1763 // the tree to cause another commit/activation. The commit should | 1763 // the tree to cause another commit/activation. The commit should |
1764 // finish *after* the layer is removed from the active tree. | 1764 // finish *after* the layer is removed from the active tree. |
1765 delegated_->RemoveFromParent(); | 1765 delegated_->RemoveFromParent(); |
1766 break; | 1766 break; |
1767 case 3: | 1767 case 3: |
1768 // Finish the test by releasing resources on the next frame. | 1768 // Finish the test by releasing resources on the next frame. |
1769 scoped_ptr<DelegatedFrameData> frame = | 1769 scoped_ptr<DelegatedFrameData> frame = |
1770 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1770 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1771 SetFrameData(frame.Pass()); | 1771 SetFrameData(std::move(frame)); |
1772 break; | 1772 break; |
1773 } | 1773 } |
1774 } | 1774 } |
1775 | 1775 |
1776 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 1776 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
1777 // The activate didn't happen before commit is done on the impl side (but it | 1777 // The activate didn't happen before commit is done on the impl side (but it |
1778 // should happen before the main thread is done). | 1778 // should happen before the main thread is done). |
1779 EXPECT_EQ(activate_count_, host_impl->sync_tree()->source_frame_number()); | 1779 EXPECT_EQ(activate_count_, host_impl->sync_tree()->source_frame_number()); |
1780 } | 1780 } |
1781 | 1781 |
(...skipping 30 matching lines...) Expand all Loading... |
1812 ReturnedResourceArray resources; | 1812 ReturnedResourceArray resources; |
1813 | 1813 |
1814 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1814 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1815 switch (next_source_frame_number) { | 1815 switch (next_source_frame_number) { |
1816 case 1: | 1816 case 1: |
1817 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1817 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1818 AddTextureQuad(frame.get(), 999); | 1818 AddTextureQuad(frame.get(), 999); |
1819 AddTransferableResource(frame.get(), 999); | 1819 AddTransferableResource(frame.get(), 999); |
1820 AddTextureQuad(frame.get(), 555); | 1820 AddTextureQuad(frame.get(), 555); |
1821 AddTransferableResource(frame.get(), 555); | 1821 AddTransferableResource(frame.get(), 555); |
1822 SetFrameData(frame.Pass()); | 1822 SetFrameData(std::move(frame)); |
1823 break; | 1823 break; |
1824 case 2: | 1824 case 2: |
1825 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1825 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1826 EXPECT_EQ(0u, resources.size()); | 1826 EXPECT_EQ(0u, resources.size()); |
1827 EXPECT_FALSE(TestAndResetAvailable()); | 1827 EXPECT_FALSE(TestAndResetAvailable()); |
1828 | 1828 |
1829 // Remove the delegated layer and replace it with a new one. Use the | 1829 // Remove the delegated layer and replace it with a new one. Use the |
1830 // same frame and resources for it. | 1830 // same frame and resources for it. |
1831 delegated_->RemoveFromParent(); | 1831 delegated_->RemoveFromParent(); |
1832 delegated_ = CreateDelegatedLayer(frame_provider_.get()); | 1832 delegated_ = CreateDelegatedLayer(frame_provider_.get()); |
1833 break; | 1833 break; |
1834 case 3: | 1834 case 3: |
1835 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1835 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1836 EXPECT_EQ(0u, resources.size()); | 1836 EXPECT_EQ(0u, resources.size()); |
1837 EXPECT_FALSE(TestAndResetAvailable()); | 1837 EXPECT_FALSE(TestAndResetAvailable()); |
1838 | 1838 |
1839 // Use a frame with no resources in it. | 1839 // Use a frame with no resources in it. |
1840 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1840 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1841 SetFrameData(frame.Pass()); | 1841 SetFrameData(std::move(frame)); |
1842 break; | 1842 break; |
1843 case 4: | 1843 case 4: |
1844 // We gave one frame to the frame provider, so we should get one | 1844 // We gave one frame to the frame provider, so we should get one |
1845 // ref back for each resource. | 1845 // ref back for each resource. |
1846 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1846 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1847 { | 1847 { |
1848 unsigned expected[] = {555, 999}; | 1848 unsigned expected[] = {555, 999}; |
1849 EXPECT_RESOURCES(expected, resources); | 1849 EXPECT_RESOURCES(expected, resources); |
1850 EXPECT_TRUE(TestAndResetAvailable()); | 1850 EXPECT_TRUE(TestAndResetAvailable()); |
1851 } | 1851 } |
(...skipping 19 matching lines...) Expand all Loading... |
1871 ReturnedResourceArray resources; | 1871 ReturnedResourceArray resources; |
1872 | 1872 |
1873 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1873 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1874 switch (next_source_frame_number) { | 1874 switch (next_source_frame_number) { |
1875 case 1: | 1875 case 1: |
1876 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1876 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1877 AddTextureQuad(frame.get(), 999); | 1877 AddTextureQuad(frame.get(), 999); |
1878 AddTransferableResource(frame.get(), 999); | 1878 AddTransferableResource(frame.get(), 999); |
1879 AddTextureQuad(frame.get(), 555); | 1879 AddTextureQuad(frame.get(), 555); |
1880 AddTransferableResource(frame.get(), 555); | 1880 AddTransferableResource(frame.get(), 555); |
1881 SetFrameData(frame.Pass()); | 1881 SetFrameData(std::move(frame)); |
1882 break; | 1882 break; |
1883 case 2: | 1883 case 2: |
1884 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1884 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1885 EXPECT_EQ(0u, resources.size()); | 1885 EXPECT_EQ(0u, resources.size()); |
1886 EXPECT_FALSE(TestAndResetAvailable()); | 1886 EXPECT_FALSE(TestAndResetAvailable()); |
1887 | 1887 |
1888 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1888 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1889 AddTextureQuad(frame.get(), 999); | 1889 AddTextureQuad(frame.get(), 999); |
1890 AddTransferableResource(frame.get(), 999); | 1890 AddTransferableResource(frame.get(), 999); |
1891 AddTextureQuad(frame.get(), 555); | 1891 AddTextureQuad(frame.get(), 555); |
1892 AddTransferableResource(frame.get(), 555); | 1892 AddTransferableResource(frame.get(), 555); |
1893 | 1893 |
1894 // Remove the delegated layer and replace it with a new one. Make a new | 1894 // Remove the delegated layer and replace it with a new one. Make a new |
1895 // frame but with the same resources for it. | 1895 // frame but with the same resources for it. |
1896 delegated_->RemoveFromParent(); | 1896 delegated_->RemoveFromParent(); |
1897 delegated_ = NULL; | 1897 delegated_ = NULL; |
1898 | 1898 |
1899 frame_provider_->SetFrameData(frame.Pass()); | 1899 frame_provider_->SetFrameData(std::move(frame)); |
1900 delegated_ = CreateDelegatedLayer(frame_provider_.get()); | 1900 delegated_ = CreateDelegatedLayer(frame_provider_.get()); |
1901 break; | 1901 break; |
1902 case 3: | 1902 case 3: |
1903 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1903 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1904 EXPECT_EQ(0u, resources.size()); | 1904 EXPECT_EQ(0u, resources.size()); |
1905 EXPECT_FALSE(TestAndResetAvailable()); | 1905 EXPECT_FALSE(TestAndResetAvailable()); |
1906 | 1906 |
1907 // Use a frame with no resources in it. | 1907 // Use a frame with no resources in it. |
1908 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1908 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1909 SetFrameData(frame.Pass()); | 1909 SetFrameData(std::move(frame)); |
1910 break; | 1910 break; |
1911 case 4: | 1911 case 4: |
1912 // We gave two frames to the frame provider, so we should get two | 1912 // We gave two frames to the frame provider, so we should get two |
1913 // refs back for each resource. | 1913 // refs back for each resource. |
1914 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 1914 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
1915 { | 1915 { |
1916 unsigned expected[] = {555, 555, 999, 999}; | 1916 unsigned expected[] = {555, 555, 999, 999}; |
1917 EXPECT_RESOURCES(expected, resources); | 1917 EXPECT_RESOURCES(expected, resources); |
1918 EXPECT_TRUE(TestAndResetAvailable()); | 1918 EXPECT_TRUE(TestAndResetAvailable()); |
1919 } | 1919 } |
(...skipping 22 matching lines...) Expand all Loading... |
1942 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 1942 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
1943 switch (next_source_frame_number) { | 1943 switch (next_source_frame_number) { |
1944 case 1: | 1944 case 1: |
1945 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 1945 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
1946 AddTextureQuad(frame.get(), 999); | 1946 AddTextureQuad(frame.get(), 999); |
1947 AddTransferableResource(frame.get(), 999); | 1947 AddTransferableResource(frame.get(), 999); |
1948 AddTextureQuad(frame.get(), 555); | 1948 AddTextureQuad(frame.get(), 555); |
1949 AddTransferableResource(frame.get(), 555); | 1949 AddTransferableResource(frame.get(), 555); |
1950 | 1950 |
1951 // Create a DelegatedRendererLayer using the frame. | 1951 // Create a DelegatedRendererLayer using the frame. |
1952 SetFrameData(frame.Pass()); | 1952 SetFrameData(std::move(frame)); |
1953 break; | 1953 break; |
1954 case 2: | 1954 case 2: |
1955 // Create a second DelegatedRendererLayer using the same frame provider. | 1955 // Create a second DelegatedRendererLayer using the same frame provider. |
1956 delegated_thief_ = CreateDelegatedLayer(frame_provider_.get()); | 1956 delegated_thief_ = CreateDelegatedLayer(frame_provider_.get()); |
1957 root_->AddChild(delegated_thief_); | 1957 root_->AddChild(delegated_thief_); |
1958 | 1958 |
1959 // And drop our ref on the frame provider so only the layers keep it | 1959 // And drop our ref on the frame provider so only the layers keep it |
1960 // alive. | 1960 // alive. |
1961 frame_provider_ = NULL; | 1961 frame_provider_ = NULL; |
1962 break; | 1962 break; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 2029 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
2030 switch (next_source_frame_number) { | 2030 switch (next_source_frame_number) { |
2031 case 1: | 2031 case 1: |
2032 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 2032 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
2033 AddTextureQuad(frame.get(), 999); | 2033 AddTextureQuad(frame.get(), 999); |
2034 AddTransferableResource(frame.get(), 999); | 2034 AddTransferableResource(frame.get(), 999); |
2035 AddTextureQuad(frame.get(), 555); | 2035 AddTextureQuad(frame.get(), 555); |
2036 AddTransferableResource(frame.get(), 555); | 2036 AddTransferableResource(frame.get(), 555); |
2037 | 2037 |
2038 // Create a DelegatedRendererLayer using the frame. | 2038 // Create a DelegatedRendererLayer using the frame. |
2039 SetFrameData(frame.Pass()); | 2039 SetFrameData(std::move(frame)); |
2040 break; | 2040 break; |
2041 case 2: | 2041 case 2: |
2042 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2042 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2043 EXPECT_EQ(0u, resources.size()); | 2043 EXPECT_EQ(0u, resources.size()); |
2044 EXPECT_FALSE(TestAndResetAvailable()); | 2044 EXPECT_FALSE(TestAndResetAvailable()); |
2045 | 2045 |
2046 // Remove the layer from the tree. The resources should not be returned | 2046 // Remove the layer from the tree. The resources should not be returned |
2047 // since they are still on the main thread layer. | 2047 // since they are still on the main thread layer. |
2048 delegated_->RemoveFromParent(); | 2048 delegated_->RemoveFromParent(); |
2049 break; | 2049 break; |
2050 case 3: | 2050 case 3: |
2051 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2051 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2052 EXPECT_EQ(0u, resources.size()); | 2052 EXPECT_EQ(0u, resources.size()); |
2053 EXPECT_FALSE(TestAndResetAvailable()); | 2053 EXPECT_FALSE(TestAndResetAvailable()); |
2054 | 2054 |
2055 // Add the layer back to the tree. | 2055 // Add the layer back to the tree. |
2056 layer_tree_host()->root_layer()->AddChild(delegated_); | 2056 layer_tree_host()->root_layer()->AddChild(delegated_); |
2057 break; | 2057 break; |
2058 case 4: | 2058 case 4: |
2059 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2059 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2060 EXPECT_EQ(0u, resources.size()); | 2060 EXPECT_EQ(0u, resources.size()); |
2061 EXPECT_FALSE(TestAndResetAvailable()); | 2061 EXPECT_FALSE(TestAndResetAvailable()); |
2062 | 2062 |
2063 // Set a new frame. Resources should be returned. | 2063 // Set a new frame. Resources should be returned. |
2064 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 2064 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
2065 AddTextureQuad(frame.get(), 888); | 2065 AddTextureQuad(frame.get(), 888); |
2066 AddTransferableResource(frame.get(), 888); | 2066 AddTransferableResource(frame.get(), 888); |
2067 AddTextureQuad(frame.get(), 777); | 2067 AddTextureQuad(frame.get(), 777); |
2068 AddTransferableResource(frame.get(), 777); | 2068 AddTransferableResource(frame.get(), 777); |
2069 SetFrameData(frame.Pass()); | 2069 SetFrameData(std::move(frame)); |
2070 break; | 2070 break; |
2071 case 5: | 2071 case 5: |
2072 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2072 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2073 { | 2073 { |
2074 unsigned expected[] = {555, 999}; | 2074 unsigned expected[] = {555, 999}; |
2075 EXPECT_RESOURCES(expected, resources); | 2075 EXPECT_RESOURCES(expected, resources); |
2076 EXPECT_TRUE(TestAndResetAvailable()); | 2076 EXPECT_TRUE(TestAndResetAvailable()); |
2077 } | 2077 } |
2078 | 2078 |
2079 // Destroy the layer. | 2079 // Destroy the layer. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 int next_source_frame_number = layer_tree_host()->source_frame_number(); | 2120 int next_source_frame_number = layer_tree_host()->source_frame_number(); |
2121 switch (next_source_frame_number) { | 2121 switch (next_source_frame_number) { |
2122 case 1: | 2122 case 1: |
2123 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 2123 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
2124 AddTextureQuad(frame.get(), 999); | 2124 AddTextureQuad(frame.get(), 999); |
2125 AddTransferableResource(frame.get(), 999); | 2125 AddTransferableResource(frame.get(), 999); |
2126 AddTextureQuad(frame.get(), 555); | 2126 AddTextureQuad(frame.get(), 555); |
2127 AddTransferableResource(frame.get(), 555); | 2127 AddTransferableResource(frame.get(), 555); |
2128 | 2128 |
2129 // Create a DelegatedRendererLayer using the frame. | 2129 // Create a DelegatedRendererLayer using the frame. |
2130 SetFrameData(frame.Pass()); | 2130 SetFrameData(std::move(frame)); |
2131 break; | 2131 break; |
2132 case 2: | 2132 case 2: |
2133 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2133 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2134 EXPECT_EQ(0u, resources.size()); | 2134 EXPECT_EQ(0u, resources.size()); |
2135 EXPECT_FALSE(TestAndResetAvailable()); | 2135 EXPECT_FALSE(TestAndResetAvailable()); |
2136 | 2136 |
2137 // Remove the layer from the tree. The resources should not be returned | 2137 // Remove the layer from the tree. The resources should not be returned |
2138 // since they are still on the main thread layer. | 2138 // since they are still on the main thread layer. |
2139 delegated_->RemoveFromParent(); | 2139 delegated_->RemoveFromParent(); |
2140 break; | 2140 break; |
2141 case 3: | 2141 case 3: |
2142 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2142 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2143 EXPECT_EQ(0u, resources.size()); | 2143 EXPECT_EQ(0u, resources.size()); |
2144 EXPECT_FALSE(TestAndResetAvailable()); | 2144 EXPECT_FALSE(TestAndResetAvailable()); |
2145 | 2145 |
2146 // Set a new frame. Resources should be returned immediately. | 2146 // Set a new frame. Resources should be returned immediately. |
2147 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 2147 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
2148 AddTextureQuad(frame.get(), 888); | 2148 AddTextureQuad(frame.get(), 888); |
2149 AddTransferableResource(frame.get(), 888); | 2149 AddTransferableResource(frame.get(), 888); |
2150 AddTextureQuad(frame.get(), 777); | 2150 AddTextureQuad(frame.get(), 777); |
2151 AddTransferableResource(frame.get(), 777); | 2151 AddTransferableResource(frame.get(), 777); |
2152 SetFrameData(frame.Pass()); | 2152 SetFrameData(std::move(frame)); |
2153 | 2153 |
2154 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); | 2154 resource_collection_->TakeUnusedResourcesForChildCompositor(&resources); |
2155 { | 2155 { |
2156 unsigned expected[] = {555, 999}; | 2156 unsigned expected[] = {555, 999}; |
2157 EXPECT_RESOURCES(expected, resources); | 2157 EXPECT_RESOURCES(expected, resources); |
2158 EXPECT_TRUE(TestAndResetAvailable()); | 2158 EXPECT_TRUE(TestAndResetAvailable()); |
2159 resources.clear(); | 2159 resources.clear(); |
2160 } | 2160 } |
2161 | 2161 |
2162 // Destroy the frame provider. | 2162 // Destroy the frame provider. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2197 : drew_with_pending_tree_(false) {} | 2197 : drew_with_pending_tree_(false) {} |
2198 | 2198 |
2199 void DidCommitAndDrawFrame() override { | 2199 void DidCommitAndDrawFrame() override { |
2200 scoped_ptr<DelegatedFrameData> frame; | 2200 scoped_ptr<DelegatedFrameData> frame; |
2201 switch (layer_tree_host()->source_frame_number()) { | 2201 switch (layer_tree_host()->source_frame_number()) { |
2202 case 1: | 2202 case 1: |
2203 // This frame goes to the active tree. | 2203 // This frame goes to the active tree. |
2204 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 2204 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
2205 AddTextureQuad(frame.get(), 999); | 2205 AddTextureQuad(frame.get(), 999); |
2206 AddTransferableResource(frame.get(), 999); | 2206 AddTransferableResource(frame.get(), 999); |
2207 SetFrameData(frame.Pass()); | 2207 SetFrameData(std::move(frame)); |
2208 break; | 2208 break; |
2209 case 2: | 2209 case 2: |
2210 // This frame stops in the pending tree while we redraw the active tree. | 2210 // This frame stops in the pending tree while we redraw the active tree. |
2211 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 2211 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
2212 AddTextureQuad(frame.get(), 555); | 2212 AddTextureQuad(frame.get(), 555); |
2213 AddTransferableResource(frame.get(), 555); | 2213 AddTransferableResource(frame.get(), 555); |
2214 SetFrameData(frame.Pass()); | 2214 SetFrameData(std::move(frame)); |
2215 break; | 2215 break; |
2216 } | 2216 } |
2217 } | 2217 } |
2218 | 2218 |
2219 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 2219 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
2220 if (host_impl->active_tree()->source_frame_number() < 1) | 2220 if (host_impl->active_tree()->source_frame_number() < 1) |
2221 return; | 2221 return; |
2222 | 2222 |
2223 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); | 2223 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
2224 FakeDelegatedRendererLayerImpl* delegated_impl = | 2224 FakeDelegatedRendererLayerImpl* delegated_impl = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 } | 2263 } |
2264 | 2264 |
2265 bool drew_with_pending_tree_; | 2265 bool drew_with_pending_tree_; |
2266 }; | 2266 }; |
2267 | 2267 |
2268 // This test blocks activation which is not supported for single thread mode. | 2268 // This test blocks activation which is not supported for single thread mode. |
2269 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid); | 2269 MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostDelegatedTestActiveFrameIsValid); |
2270 | 2270 |
2271 } // namespace | 2271 } // namespace |
2272 } // namespace cc | 2272 } // namespace cc |
OLD | NEW |