| 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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "cc/delegated_frame_data.h" | 7 #include "cc/delegated_frame_data.h" |
| 8 #include "cc/delegated_renderer_layer.h" | 8 #include "cc/delegated_renderer_layer.h" |
| 9 #include "cc/delegated_renderer_layer_impl.h" | 9 #include "cc/delegated_renderer_layer_impl.h" |
| 10 #include "cc/layer_tree_impl.h" | 10 #include "cc/layer_tree_impl.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 did_reset_child_id_(false) {} | 103 did_reset_child_id_(false) {} |
| 104 | 104 |
| 105 virtual void didCommit() OVERRIDE { | 105 virtual void didCommit() OVERRIDE { |
| 106 if (testEnded()) | 106 if (testEnded()) |
| 107 return; | 107 return; |
| 108 delegated_->SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), | 108 delegated_->SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), |
| 109 gfx::Rect(0, 0, 1, 1))); | 109 gfx::Rect(0, 0, 1, 1))); |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 112 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 113 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 113 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 114 FakeDelegatedRendererLayerImpl* delegated_impl = | 114 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 115 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 115 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 116 | 116 |
| 117 ++num_activates_; | 117 ++num_activates_; |
| 118 switch(num_activates_) { | 118 switch(num_activates_) { |
| 119 case 2: | 119 case 2: |
| 120 EXPECT_TRUE(delegated_impl->ChildId()); | 120 EXPECT_TRUE(delegated_impl->ChildId()); |
| 121 EXPECT_FALSE(did_reset_child_id_); | 121 EXPECT_FALSE(did_reset_child_id_); |
| 122 | 122 |
| 123 host_impl->resourceProvider()->GraphicsContext3D()->loseContextCHROMIUM( | 123 host_impl->resource_provider()->GraphicsContext3D()->loseContextCHROMIUM
( |
| 124 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 124 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 125 break; | 125 break; |
| 126 case 3: | 126 case 3: |
| 127 EXPECT_TRUE(delegated_impl->ChildId()); | 127 EXPECT_TRUE(delegated_impl->ChildId()); |
| 128 EXPECT_TRUE(did_reset_child_id_); | 128 EXPECT_TRUE(did_reset_child_id_); |
| 129 endTest(); | 129 endTest(); |
| 130 break; | 130 break; |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 virtual void initializedRendererOnThread(LayerTreeHostImpl* host_impl, | 134 virtual void initializedRendererOnThread(LayerTreeHostImpl* host_impl, |
| 135 bool success) OVERRIDE { | 135 bool success) OVERRIDE { |
| 136 EXPECT_TRUE(success); | 136 EXPECT_TRUE(success); |
| 137 | 137 |
| 138 if (num_activates_ < 2) | 138 if (num_activates_ < 2) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 141 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 142 FakeDelegatedRendererLayerImpl* delegated_impl = | 142 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 143 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 143 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 144 | 144 |
| 145 EXPECT_EQ(2, num_activates_); | 145 EXPECT_EQ(2, num_activates_); |
| 146 EXPECT_FALSE(delegated_impl->ChildId()); | 146 EXPECT_FALSE(delegated_impl->ChildId()); |
| 147 did_reset_child_id_ = true; | 147 did_reset_child_id_ = true; |
| 148 } | 148 } |
| 149 | 149 |
| 150 virtual void afterTest() OVERRIDE {} | 150 virtual void afterTest() OVERRIDE {} |
| 151 | 151 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 break; | 235 break; |
| 236 case 14: | 236 case 14: |
| 237 // Should create zero damage. | 237 // Should create zero damage. |
| 238 m_layerTreeHost->SetNeedsCommit(); | 238 m_layerTreeHost->SetNeedsCommit(); |
| 239 break; | 239 break; |
| 240 } | 240 } |
| 241 first_draw_for_source_frame_ = true; | 241 first_draw_for_source_frame_ = true; |
| 242 } | 242 } |
| 243 | 243 |
| 244 virtual bool prepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 244 virtual bool prepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 245 LayerTreeHostImpl::FrameData& frame, | 245 LayerTreeHostImpl::FrameData* frame, |
| 246 bool result) { | 246 bool result) { |
| 247 EXPECT_TRUE(result); | 247 EXPECT_TRUE(result); |
| 248 | 248 |
| 249 if (!first_draw_for_source_frame_) | 249 if (!first_draw_for_source_frame_) |
| 250 return result; | 250 return result; |
| 251 | 251 |
| 252 gfx::RectF damage_rect = frame.renderPasses.back()->damage_rect; | 252 gfx::RectF damage_rect = frame->render_passes.back()->damage_rect; |
| 253 | 253 |
| 254 switch (host_impl->activeTree()->source_frame_number()) { | 254 switch (host_impl->active_tree()->source_frame_number()) { |
| 255 case 0: | 255 case 0: |
| 256 // Before the layer has a frame to display it should not | 256 // Before the layer has a frame to display it should not |
| 257 // be visible at all, and not damage anything. | 257 // be visible at all, and not damage anything. |
| 258 EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), | 258 EXPECT_EQ(gfx::RectF(0.f, 0.f, 0.f, 0.f).ToString(), |
| 259 damage_rect.ToString()); | 259 damage_rect.ToString()); |
| 260 break; | 260 break; |
| 261 case 1: | 261 case 1: |
| 262 EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), | 262 EXPECT_EQ(gfx::RectF(0.f, 0.f, 10.f, 10.f).ToString(), |
| 263 damage_rect.ToString()); | 263 damage_rect.ToString()); |
| 264 break; | 264 break; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 344 CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
| 345 AddTextureQuad(frame2.get(), 999); | 345 AddTextureQuad(frame2.get(), 999); |
| 346 AddTextureQuad(frame2.get(), 555); | 346 AddTextureQuad(frame2.get(), 555); |
| 347 AddTransferableResource(frame2.get(), 555); | 347 AddTransferableResource(frame2.get(), 555); |
| 348 delegated_->SetFrameData(frame2.Pass()); | 348 delegated_->SetFrameData(frame2.Pass()); |
| 349 | 349 |
| 350 postSetNeedsCommitToMainThread(); | 350 postSetNeedsCommitToMainThread(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 353 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 354 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 354 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 355 FakeDelegatedRendererLayerImpl* delegated_impl = | 355 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 356 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 356 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 357 | 357 |
| 358 const ResourceProvider::ResourceIdMap& map = | 358 const ResourceProvider::ResourceIdMap& map = |
| 359 host_impl->resourceProvider()->GetChildToParentMap( | 359 host_impl->resource_provider()->GetChildToParentMap( |
| 360 delegated_impl->ChildId()); | 360 delegated_impl->ChildId()); |
| 361 | 361 |
| 362 // Both frames' resources should be in the parent's resource provider. | 362 // Both frames' resources should be in the parent's resource provider. |
| 363 EXPECT_EQ(2u, map.size()); | 363 EXPECT_EQ(2u, map.size()); |
| 364 EXPECT_EQ(1u, map.count(999)); | 364 EXPECT_EQ(1u, map.count(999)); |
| 365 EXPECT_EQ(1u, map.count(555)); | 365 EXPECT_EQ(1u, map.count(555)); |
| 366 | 366 |
| 367 EXPECT_EQ(2u, delegated_impl->Resources().size()); | 367 EXPECT_EQ(2u, delegated_impl->Resources().size()); |
| 368 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); | 368 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); |
| 369 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 369 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 386 AddTextureQuad(frame.get(), 999); | 386 AddTextureQuad(frame.get(), 999); |
| 387 AddTransferableResource(frame.get(), 999); | 387 AddTransferableResource(frame.get(), 999); |
| 388 AddTextureQuad(frame.get(), 555); | 388 AddTextureQuad(frame.get(), 555); |
| 389 AddTransferableResource(frame.get(), 555); | 389 AddTransferableResource(frame.get(), 555); |
| 390 delegated_->SetFrameData(frame.Pass()); | 390 delegated_->SetFrameData(frame.Pass()); |
| 391 | 391 |
| 392 postSetNeedsCommitToMainThread(); | 392 postSetNeedsCommitToMainThread(); |
| 393 } | 393 } |
| 394 | 394 |
| 395 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 395 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 396 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 396 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 397 FakeDelegatedRendererLayerImpl* delegated_impl = | 397 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 398 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 398 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 399 | 399 |
| 400 const ResourceProvider::ResourceIdMap& map = | 400 const ResourceProvider::ResourceIdMap& map = |
| 401 host_impl->resourceProvider()->GetChildToParentMap( | 401 host_impl->resource_provider()->GetChildToParentMap( |
| 402 delegated_impl->ChildId()); | 402 delegated_impl->ChildId()); |
| 403 | 403 |
| 404 // The frame's resource should be in the parent's resource provider. | 404 // The frame's resource should be in the parent's resource provider. |
| 405 EXPECT_EQ(2u, map.size()); | 405 EXPECT_EQ(2u, map.size()); |
| 406 EXPECT_EQ(1u, map.count(999)); | 406 EXPECT_EQ(1u, map.count(999)); |
| 407 EXPECT_EQ(1u, map.count(555)); | 407 EXPECT_EQ(1u, map.count(555)); |
| 408 | 408 |
| 409 ResourceProvider::ResourceId parent_resource_id1 = map.find(999)->second; | 409 ResourceProvider::ResourceId parent_resource_id1 = map.find(999)->second; |
| 410 EXPECT_NE(parent_resource_id1, 999); | 410 EXPECT_NE(parent_resource_id1, 999); |
| 411 ResourceProvider::ResourceId parent_resource_id2 = map.find(555)->second; | 411 ResourceProvider::ResourceId parent_resource_id2 = map.find(555)->second; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); | 612 frame = CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)); |
| 613 AddTextureQuad(frame.get(), 999); | 613 AddTextureQuad(frame.get(), 999); |
| 614 AddTextureQuad(frame.get(), 555); | 614 AddTextureQuad(frame.get(), 555); |
| 615 AddTextureQuad(frame.get(), 444); | 615 AddTextureQuad(frame.get(), 444); |
| 616 delegated_->SetFrameData(frame.Pass()); | 616 delegated_->SetFrameData(frame.Pass()); |
| 617 break; | 617 break; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 621 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 622 if (host_impl->activeTree()->source_frame_number() != 3) | 622 if (host_impl->active_tree()->source_frame_number() != 3) |
| 623 return; | 623 return; |
| 624 | 624 |
| 625 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 625 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 626 FakeDelegatedRendererLayerImpl* delegated_impl = | 626 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 627 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 627 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 628 | 628 |
| 629 const ResourceProvider::ResourceIdMap& map = | 629 const ResourceProvider::ResourceIdMap& map = |
| 630 host_impl->resourceProvider()->GetChildToParentMap( | 630 host_impl->resource_provider()->GetChildToParentMap( |
| 631 delegated_impl->ChildId()); | 631 delegated_impl->ChildId()); |
| 632 | 632 |
| 633 // The bad frame should be dropped. So we should only have one quad (the | 633 // The bad frame should be dropped. So we should only have one quad (the |
| 634 // one with resource 999) on the impl tree. And only 999 will be present | 634 // one with resource 999) on the impl tree. And only 999 will be present |
| 635 // in the parent's resource provider. | 635 // in the parent's resource provider. |
| 636 EXPECT_EQ(1u, map.size()); | 636 EXPECT_EQ(1u, map.size()); |
| 637 EXPECT_EQ(1u, map.count(999)); | 637 EXPECT_EQ(1u, map.count(999)); |
| 638 | 638 |
| 639 EXPECT_EQ(1u, delegated_impl->Resources().size()); | 639 EXPECT_EQ(1u, delegated_impl->Resources().size()); |
| 640 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); | 640 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 break; | 709 break; |
| 710 case 4: | 710 case 4: |
| 711 delegated_->TakeUnusedResourcesForChildCompositor(&resources); | 711 delegated_->TakeUnusedResourcesForChildCompositor(&resources); |
| 712 EXPECT_EQ(0u, resources.size()); | 712 EXPECT_EQ(0u, resources.size()); |
| 713 endTest(); | 713 endTest(); |
| 714 break; | 714 break; |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 718 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 719 if (host_impl->activeTree()->source_frame_number() != 3) | 719 if (host_impl->active_tree()->source_frame_number() != 3) |
| 720 return; | 720 return; |
| 721 | 721 |
| 722 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 722 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 723 FakeDelegatedRendererLayerImpl* delegated_impl = | 723 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 724 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 724 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 725 | 725 |
| 726 const ResourceProvider::ResourceIdMap& map = | 726 const ResourceProvider::ResourceIdMap& map = |
| 727 host_impl->resourceProvider()->GetChildToParentMap( | 727 host_impl->resource_provider()->GetChildToParentMap( |
| 728 delegated_impl->ChildId()); | 728 delegated_impl->ChildId()); |
| 729 | 729 |
| 730 // The third frame has all of the resources in it again, the delegated | 730 // The third frame has all of the resources in it again, the delegated |
| 731 // renderer layer should continue to own the resources for it. | 731 // renderer layer should continue to own the resources for it. |
| 732 EXPECT_EQ(3u, map.size()); | 732 EXPECT_EQ(3u, map.size()); |
| 733 EXPECT_EQ(1u, map.count(999)); | 733 EXPECT_EQ(1u, map.count(999)); |
| 734 EXPECT_EQ(1u, map.count(555)); | 734 EXPECT_EQ(1u, map.count(555)); |
| 735 EXPECT_EQ(1u, map.count(444)); | 735 EXPECT_EQ(1u, map.count(444)); |
| 736 | 736 |
| 737 EXPECT_EQ(3u, delegated_impl->Resources().size()); | 737 EXPECT_EQ(3u, delegated_impl->Resources().size()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 delegated_->TakeUnusedResourcesForChildCompositor(&resources); | 815 delegated_->TakeUnusedResourcesForChildCompositor(&resources); |
| 816 EXPECT_EQ(1u, resources.size()); | 816 EXPECT_EQ(1u, resources.size()); |
| 817 EXPECT_EQ(555, resources[0].id); | 817 EXPECT_EQ(555, resources[0].id); |
| 818 | 818 |
| 819 endTest(); | 819 endTest(); |
| 820 break; | 820 break; |
| 821 } | 821 } |
| 822 } | 822 } |
| 823 | 823 |
| 824 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 824 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 825 if (host_impl->activeTree()->source_frame_number() < 1) | 825 if (host_impl->active_tree()->source_frame_number() < 1) |
| 826 return; | 826 return; |
| 827 | 827 |
| 828 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 828 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 829 FakeDelegatedRendererLayerImpl* delegated_impl = | 829 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 830 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 830 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 831 | 831 |
| 832 const ResourceProvider::ResourceIdMap& map = | 832 const ResourceProvider::ResourceIdMap& map = |
| 833 host_impl->resourceProvider()->GetChildToParentMap( | 833 host_impl->resource_provider()->GetChildToParentMap( |
| 834 delegated_impl->ChildId()); | 834 delegated_impl->ChildId()); |
| 835 | 835 |
| 836 switch (host_impl->activeTree()->source_frame_number()) { | 836 switch (host_impl->active_tree()->source_frame_number()) { |
| 837 case 1: { | 837 case 1: { |
| 838 // We have the first good frame with just 990 and 555 in it. | 838 // We have the first good frame with just 990 and 555 in it. |
| 839 // layer. | 839 // layer. |
| 840 EXPECT_EQ(2u, map.size()); | 840 EXPECT_EQ(2u, map.size()); |
| 841 EXPECT_EQ(1u, map.count(999)); | 841 EXPECT_EQ(1u, map.count(999)); |
| 842 EXPECT_EQ(1u, map.count(555)); | 842 EXPECT_EQ(1u, map.count(555)); |
| 843 | 843 |
| 844 EXPECT_EQ(2u, delegated_impl->Resources().size()); | 844 EXPECT_EQ(2u, delegated_impl->Resources().size()); |
| 845 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); | 845 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); |
| 846 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 846 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 delegated_->TakeUnusedResourcesForChildCompositor(&resources); | 926 delegated_->TakeUnusedResourcesForChildCompositor(&resources); |
| 927 EXPECT_EQ(1u, resources.size()); | 927 EXPECT_EQ(1u, resources.size()); |
| 928 EXPECT_EQ(999, resources[0].id); | 928 EXPECT_EQ(999, resources[0].id); |
| 929 | 929 |
| 930 endTest(); | 930 endTest(); |
| 931 break; | 931 break; |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 | 934 |
| 935 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 935 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 936 if (host_impl->activeTree()->source_frame_number() != 1) | 936 if (host_impl->active_tree()->source_frame_number() != 1) |
| 937 return; | 937 return; |
| 938 | 938 |
| 939 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 939 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 940 FakeDelegatedRendererLayerImpl* delegated_impl = | 940 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 941 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 941 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 942 | 942 |
| 943 const ResourceProvider::ResourceIdMap& map = | 943 const ResourceProvider::ResourceIdMap& map = |
| 944 host_impl->resourceProvider()->GetChildToParentMap( | 944 host_impl->resource_provider()->GetChildToParentMap( |
| 945 delegated_impl->ChildId()); | 945 delegated_impl->ChildId()); |
| 946 | 946 |
| 947 // The layer only held on to the resource that was used. | 947 // The layer only held on to the resource that was used. |
| 948 EXPECT_EQ(1u, map.size()); | 948 EXPECT_EQ(1u, map.size()); |
| 949 EXPECT_EQ(1u, map.count(555)); | 949 EXPECT_EQ(1u, map.count(555)); |
| 950 | 950 |
| 951 EXPECT_EQ(1u, delegated_impl->Resources().size()); | 951 EXPECT_EQ(1u, delegated_impl->Resources().size()); |
| 952 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 952 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| 953 } | 953 } |
| 954 | 954 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 delegated_->TakeUnusedResourcesForChildCompositor(&resources); | 989 delegated_->TakeUnusedResourcesForChildCompositor(&resources); |
| 990 EXPECT_EQ(1u, resources.size()); | 990 EXPECT_EQ(1u, resources.size()); |
| 991 EXPECT_EQ(999, resources[0].id); | 991 EXPECT_EQ(999, resources[0].id); |
| 992 | 992 |
| 993 endTest(); | 993 endTest(); |
| 994 break; | 994 break; |
| 995 } | 995 } |
| 996 } | 996 } |
| 997 | 997 |
| 998 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 998 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 999 if (host_impl->activeTree()->source_frame_number() != 1) | 999 if (host_impl->active_tree()->source_frame_number() != 1) |
| 1000 return; | 1000 return; |
| 1001 | 1001 |
| 1002 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 1002 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 1003 FakeDelegatedRendererLayerImpl* delegated_impl = | 1003 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 1004 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 1004 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 1005 | 1005 |
| 1006 const ResourceProvider::ResourceIdMap& map = | 1006 const ResourceProvider::ResourceIdMap& map = |
| 1007 host_impl->resourceProvider()->GetChildToParentMap( | 1007 host_impl->resource_provider()->GetChildToParentMap( |
| 1008 delegated_impl->ChildId()); | 1008 delegated_impl->ChildId()); |
| 1009 | 1009 |
| 1010 // The layer only held on to the resource that was used. | 1010 // The layer only held on to the resource that was used. |
| 1011 EXPECT_EQ(1u, map.size()); | 1011 EXPECT_EQ(1u, map.size()); |
| 1012 EXPECT_EQ(1u, map.count(555)); | 1012 EXPECT_EQ(1u, map.count(555)); |
| 1013 | 1013 |
| 1014 EXPECT_EQ(1u, delegated_impl->Resources().size()); | 1014 EXPECT_EQ(1u, delegated_impl->Resources().size()); |
| 1015 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 1015 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 delegated_->TakeUnusedResourcesForChildCompositor(&resources); | 1066 delegated_->TakeUnusedResourcesForChildCompositor(&resources); |
| 1067 EXPECT_EQ(1u, resources.size()); | 1067 EXPECT_EQ(1u, resources.size()); |
| 1068 EXPECT_EQ(999, resources[0].id); | 1068 EXPECT_EQ(999, resources[0].id); |
| 1069 | 1069 |
| 1070 endTest(); | 1070 endTest(); |
| 1071 break; | 1071 break; |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 1075 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 1076 if (host_impl->activeTree()->source_frame_number() < 1) | 1076 if (host_impl->active_tree()->source_frame_number() < 1) |
| 1077 return; | 1077 return; |
| 1078 | 1078 |
| 1079 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 1079 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 1080 FakeDelegatedRendererLayerImpl* delegated_impl = | 1080 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 1081 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 1081 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 1082 | 1082 |
| 1083 const ResourceProvider::ResourceIdMap& map = | 1083 const ResourceProvider::ResourceIdMap& map = |
| 1084 host_impl->resourceProvider()->GetChildToParentMap( | 1084 host_impl->resource_provider()->GetChildToParentMap( |
| 1085 delegated_impl->ChildId()); | 1085 delegated_impl->ChildId()); |
| 1086 | 1086 |
| 1087 switch (host_impl->activeTree()->source_frame_number()) { | 1087 switch (host_impl->active_tree()->source_frame_number()) { |
| 1088 case 1: { | 1088 case 1: { |
| 1089 EXPECT_EQ(2u, map.size()); | 1089 EXPECT_EQ(2u, map.size()); |
| 1090 EXPECT_EQ(1u, map.count(999)); | 1090 EXPECT_EQ(1u, map.count(999)); |
| 1091 EXPECT_EQ(1u, map.count(555)); | 1091 EXPECT_EQ(1u, map.count(555)); |
| 1092 | 1092 |
| 1093 EXPECT_EQ(2u, delegated_impl->Resources().size()); | 1093 EXPECT_EQ(2u, delegated_impl->Resources().size()); |
| 1094 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); | 1094 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); |
| 1095 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 1095 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| 1096 | 1096 |
| 1097 // The 999 resource is sent to a grandparent compositor. | 1097 // The 999 resource is sent to a grandparent compositor. |
| 1098 ResourceProvider::ResourceIdArray resources_for_parent; | 1098 ResourceProvider::ResourceIdArray resources_for_parent; |
| 1099 resources_for_parent.push_back(map.find(999)->second); | 1099 resources_for_parent.push_back(map.find(999)->second); |
| 1100 TransferableResourceArray transferable_resources; | 1100 TransferableResourceArray transferable_resources; |
| 1101 host_impl->resourceProvider()->PrepareSendToParent( | 1101 host_impl->resource_provider()->PrepareSendToParent( |
| 1102 resources_for_parent, &transferable_resources); | 1102 resources_for_parent, &transferable_resources); |
| 1103 break; | 1103 break; |
| 1104 } | 1104 } |
| 1105 case 2: { | 1105 case 2: { |
| 1106 EXPECT_EQ(2u, map.size()); | 1106 EXPECT_EQ(2u, map.size()); |
| 1107 EXPECT_EQ(1u, map.count(999)); | 1107 EXPECT_EQ(1u, map.count(999)); |
| 1108 EXPECT_EQ(1u, map.count(555)); | 1108 EXPECT_EQ(1u, map.count(555)); |
| 1109 | 1109 |
| 1110 /// 999 is in the parent, so not held by delegated renderer layer. | 1110 /// 999 is in the parent, so not held by delegated renderer layer. |
| 1111 EXPECT_EQ(1u, delegated_impl->Resources().size()); | 1111 EXPECT_EQ(1u, delegated_impl->Resources().size()); |
| 1112 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 1112 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| 1113 | 1113 |
| 1114 // Receive 999 back from the grandparent. | 1114 // Receive 999 back from the grandparent. |
| 1115 TransferableResource resource; | 1115 TransferableResource resource; |
| 1116 resource.id = map.find(999)->second; | 1116 resource.id = map.find(999)->second; |
| 1117 TransferableResourceArray transferable_resources; | 1117 TransferableResourceArray transferable_resources; |
| 1118 transferable_resources.push_back(resource); | 1118 transferable_resources.push_back(resource); |
| 1119 host_impl->resourceProvider()->ReceiveFromParent( | 1119 host_impl->resource_provider()->ReceiveFromParent( |
| 1120 transferable_resources); | 1120 transferable_resources); |
| 1121 break; | 1121 break; |
| 1122 } | 1122 } |
| 1123 case 3: | 1123 case 3: |
| 1124 // 999 should be released. | 1124 // 999 should be released. |
| 1125 EXPECT_EQ(1u, map.size()); | 1125 EXPECT_EQ(1u, map.size()); |
| 1126 EXPECT_EQ(1u, map.count(555)); | 1126 EXPECT_EQ(1u, map.count(555)); |
| 1127 | 1127 |
| 1128 EXPECT_EQ(1u, delegated_impl->Resources().size()); | 1128 EXPECT_EQ(1u, delegated_impl->Resources().size()); |
| 1129 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 1129 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 delegated_->TakeUnusedResourcesForChildCompositor(&resources); | 1181 delegated_->TakeUnusedResourcesForChildCompositor(&resources); |
| 1182 EXPECT_EQ(1u, resources.size()); | 1182 EXPECT_EQ(1u, resources.size()); |
| 1183 EXPECT_EQ(444, resources[0].id); | 1183 EXPECT_EQ(444, resources[0].id); |
| 1184 | 1184 |
| 1185 endTest(); | 1185 endTest(); |
| 1186 break; | 1186 break; |
| 1187 } | 1187 } |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 1190 virtual void treeActivatedOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 1191 if (host_impl->activeTree()->source_frame_number() < 1) | 1191 if (host_impl->active_tree()->source_frame_number() < 1) |
| 1192 return; | 1192 return; |
| 1193 | 1193 |
| 1194 LayerImpl* root_impl = host_impl->activeTree()->RootLayer(); | 1194 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
| 1195 FakeDelegatedRendererLayerImpl* delegated_impl = | 1195 FakeDelegatedRendererLayerImpl* delegated_impl = |
| 1196 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); | 1196 static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]); |
| 1197 | 1197 |
| 1198 const ResourceProvider::ResourceIdMap& map = | 1198 const ResourceProvider::ResourceIdMap& map = |
| 1199 host_impl->resourceProvider()->GetChildToParentMap( | 1199 host_impl->resource_provider()->GetChildToParentMap( |
| 1200 delegated_impl->ChildId()); | 1200 delegated_impl->ChildId()); |
| 1201 | 1201 |
| 1202 switch (host_impl->activeTree()->source_frame_number()) { | 1202 switch (host_impl->active_tree()->source_frame_number()) { |
| 1203 case 1: | 1203 case 1: |
| 1204 EXPECT_EQ(3u, map.size()); | 1204 EXPECT_EQ(3u, map.size()); |
| 1205 EXPECT_EQ(1u, map.count(999)); | 1205 EXPECT_EQ(1u, map.count(999)); |
| 1206 EXPECT_EQ(1u, map.count(555)); | 1206 EXPECT_EQ(1u, map.count(555)); |
| 1207 EXPECT_EQ(1u, map.count(444)); | 1207 EXPECT_EQ(1u, map.count(444)); |
| 1208 | 1208 |
| 1209 EXPECT_EQ(3u, delegated_impl->Resources().size()); | 1209 EXPECT_EQ(3u, delegated_impl->Resources().size()); |
| 1210 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); | 1210 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(999)->second)); |
| 1211 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); | 1211 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(555)->second)); |
| 1212 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(444)->second)); | 1212 EXPECT_EQ(1u, delegated_impl->Resources().count(map.find(444)->second)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1229 } | 1229 } |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 virtual void afterTest() OVERRIDE {} | 1232 virtual void afterTest() OVERRIDE {} |
| 1233 }; | 1233 }; |
| 1234 | 1234 |
| 1235 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCommitWithoutTake) | 1235 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCommitWithoutTake) |
| 1236 | 1236 |
| 1237 } // namespace | 1237 } // namespace |
| 1238 } // namespace cc | 1238 } // namespace cc |
| OLD | NEW |