OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 } | 1058 } |
1059 } | 1059 } |
1060 | 1060 |
1061 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | 1061 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
1062 LayerTreeHostImpl::FrameData* frame_data, | 1062 LayerTreeHostImpl::FrameData* frame_data, |
1063 DrawResult draw_result) override { | 1063 DrawResult draw_result) override { |
1064 LayerImpl* root_impl = impl->active_tree()->LayerById(root_->id()); | 1064 LayerImpl* root_impl = impl->active_tree()->LayerById(root_->id()); |
1065 LayerImpl* child_impl = impl->active_tree()->LayerById(child_->id()); | 1065 LayerImpl* child_impl = impl->active_tree()->LayerById(child_->id()); |
1066 switch (impl->active_tree()->source_frame_number()) { | 1066 switch (impl->active_tree()->source_frame_number()) { |
1067 case 0: | 1067 case 0: |
1068 EXPECT_TRUE(root_impl->render_surface()->AncestorPropertyChanged()); | 1068 EXPECT_TRUE(root_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1069 EXPECT_TRUE(child_impl->render_surface()->AncestorPropertyChanged()); | 1069 EXPECT_TRUE(child_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1070 PostSetNeedsCommitToMainThread(); | 1070 PostSetNeedsCommitToMainThread(); |
1071 break; | 1071 break; |
1072 case 1: | 1072 case 1: |
1073 EXPECT_FALSE(root_impl->render_surface()->AncestorPropertyChanged()); | 1073 EXPECT_FALSE(root_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1074 EXPECT_FALSE(child_impl->render_surface()->AncestorPropertyChanged()); | 1074 EXPECT_FALSE(child_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1075 PostSetNeedsCommitToMainThread(); | 1075 PostSetNeedsCommitToMainThread(); |
1076 break; | 1076 break; |
1077 case 2: | 1077 case 2: |
1078 EXPECT_TRUE(root_impl->render_surface()->AncestorPropertyChanged()); | 1078 EXPECT_TRUE(root_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1079 EXPECT_TRUE(child_impl->render_surface()->AncestorPropertyChanged()); | 1079 EXPECT_TRUE(child_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1080 PostSetNeedsCommitToMainThread(); | 1080 PostSetNeedsCommitToMainThread(); |
1081 break; | 1081 break; |
1082 case 3: | 1082 case 3: |
1083 EXPECT_FALSE(root_impl->render_surface()->AncestorPropertyChanged()); | 1083 EXPECT_FALSE(root_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1084 EXPECT_TRUE(child_impl->render_surface()->AncestorPropertyChanged()); | 1084 EXPECT_TRUE(child_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1085 EndTest(); | 1085 EndTest(); |
1086 PostSetNeedsCommitToMainThread(); | 1086 PostSetNeedsCommitToMainThread(); |
1087 break; | 1087 break; |
1088 case 4: | 1088 case 4: |
1089 EXPECT_FALSE(root_impl->render_surface()->AncestorPropertyChanged()); | 1089 EXPECT_FALSE(root_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1090 EXPECT_FALSE(child_impl->render_surface()->AncestorPropertyChanged()); | 1090 EXPECT_FALSE(child_impl->GetRenderSurface()->AncestorPropertyChanged()); |
1091 EndTest(); | 1091 EndTest(); |
1092 break; | 1092 break; |
1093 } | 1093 } |
1094 | 1094 |
1095 return draw_result; | 1095 return draw_result; |
1096 } | 1096 } |
1097 | 1097 |
1098 void AfterTest() override {} | 1098 void AfterTest() override {} |
1099 | 1099 |
1100 private: | 1100 private: |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 break; | 1511 break; |
1512 } | 1512 } |
1513 } | 1513 } |
1514 | 1514 |
1515 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 1515 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
1516 switch (index_) { | 1516 switch (index_) { |
1517 case 0: | 1517 case 0: |
1518 index_++; | 1518 index_++; |
1519 EXPECT_FALSE(impl->sync_tree() | 1519 EXPECT_FALSE(impl->sync_tree() |
1520 ->root_layer_for_testing() | 1520 ->root_layer_for_testing() |
1521 ->render_surface() | 1521 ->GetRenderSurface() |
1522 ->MaskLayer()); | 1522 ->MaskLayer()); |
1523 break; | 1523 break; |
1524 case 1: | 1524 case 1: |
1525 EXPECT_TRUE(impl->sync_tree() | 1525 EXPECT_TRUE(impl->sync_tree() |
1526 ->root_layer_for_testing() | 1526 ->root_layer_for_testing() |
1527 ->render_surface() | 1527 ->GetRenderSurface() |
1528 ->MaskLayer()); | 1528 ->MaskLayer()); |
1529 EndTest(); | 1529 EndTest(); |
1530 break; | 1530 break; |
1531 } | 1531 } |
1532 } | 1532 } |
1533 | 1533 |
1534 void AfterTest() override {} | 1534 void AfterTest() override {} |
1535 | 1535 |
1536 scoped_refptr<Layer> mask_layer; | 1536 scoped_refptr<Layer> mask_layer; |
1537 int index_; | 1537 int index_; |
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 // Compute all the layer transforms for the frame. | 2608 // Compute all the layer transforms for the frame. |
2609 LayerTreeHostImpl::FrameData frame_data; | 2609 LayerTreeHostImpl::FrameData frame_data; |
2610 impl->PrepareToDraw(&frame_data); | 2610 impl->PrepareToDraw(&frame_data); |
2611 impl->DidDrawAllLayers(frame_data); | 2611 impl->DidDrawAllLayers(frame_data); |
2612 | 2612 |
2613 const LayerImplList& render_surface_layer_list = | 2613 const LayerImplList& render_surface_layer_list = |
2614 *frame_data.render_surface_layer_list; | 2614 *frame_data.render_surface_layer_list; |
2615 | 2615 |
2616 // Both layers should be drawing into the root render surface. | 2616 // Both layers should be drawing into the root render surface. |
2617 ASSERT_EQ(1u, render_surface_layer_list.size()); | 2617 ASSERT_EQ(1u, render_surface_layer_list.size()); |
2618 ASSERT_EQ(root->render_surface(), | 2618 ASSERT_EQ(root->GetRenderSurface(), |
2619 render_surface_layer_list[0]->render_surface()); | 2619 render_surface_layer_list[0]->GetRenderSurface()); |
2620 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 2620 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); |
2621 | 2621 |
2622 // The root render surface is the size of the viewport. | 2622 // The root render surface is the size of the viewport. |
2623 EXPECT_EQ(gfx::Rect(0, 0, 60, 60), root->render_surface()->content_rect()); | 2623 EXPECT_EQ(gfx::Rect(0, 0, 60, 60), |
| 2624 root->GetRenderSurface()->content_rect()); |
2624 | 2625 |
2625 // The max tiling scale of the child should be scaled. | 2626 // The max tiling scale of the child should be scaled. |
2626 EXPECT_FLOAT_EQ(1.5f, child->MaximumTilingContentsScale()); | 2627 EXPECT_FLOAT_EQ(1.5f, child->MaximumTilingContentsScale()); |
2627 | 2628 |
2628 gfx::Transform scale_transform; | 2629 gfx::Transform scale_transform; |
2629 scale_transform.Scale(impl->active_tree()->device_scale_factor(), | 2630 scale_transform.Scale(impl->active_tree()->device_scale_factor(), |
2630 impl->active_tree()->device_scale_factor()); | 2631 impl->active_tree()->device_scale_factor()); |
2631 | 2632 |
2632 // The root layer is scaled by 2x. | 2633 // The root layer is scaled by 2x. |
2633 gfx::Transform root_screen_space_transform = scale_transform; | 2634 gfx::Transform root_screen_space_transform = scale_transform; |
(...skipping 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5577 grand_child_->SetForceRenderSurfaceForTesting(true); | 5578 grand_child_->SetForceRenderSurfaceForTesting(true); |
5578 | 5579 |
5579 LayerTreeHostTest::SetupTree(); | 5580 LayerTreeHostTest::SetupTree(); |
5580 } | 5581 } |
5581 | 5582 |
5582 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5583 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
5583 if (host_impl->sync_tree()->source_frame_number() >= 1) { | 5584 if (host_impl->sync_tree()->source_frame_number() >= 1) { |
5584 LayerImpl* grand_child_impl = | 5585 LayerImpl* grand_child_impl = |
5585 host_impl->sync_tree()->LayerById(grand_child_->id()); | 5586 host_impl->sync_tree()->LayerById(grand_child_->id()); |
5586 EXPECT_EQ(grand_child_impl->effect_tree_index(), | 5587 EXPECT_EQ(grand_child_impl->effect_tree_index(), |
5587 grand_child_impl->render_surface()->EffectTreeIndex()); | 5588 grand_child_impl->GetRenderSurface()->EffectTreeIndex()); |
5588 } | 5589 } |
5589 } | 5590 } |
5590 | 5591 |
5591 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 5592 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
5592 LayerImpl* grand_child_impl = | 5593 LayerImpl* grand_child_impl = |
5593 host_impl->active_tree()->LayerById(grand_child_->id()); | 5594 host_impl->active_tree()->LayerById(grand_child_->id()); |
5594 switch (host_impl->active_tree()->source_frame_number()) { | 5595 switch (host_impl->active_tree()->source_frame_number()) { |
5595 case 0: | 5596 case 0: |
5596 PostSetNeedsCommitToMainThread(); | 5597 PostSetNeedsCommitToMainThread(); |
5597 break; | 5598 break; |
5598 case 1: | 5599 case 1: |
5599 case 2: | 5600 case 2: |
5600 EXPECT_EQ(grand_child_impl->effect_tree_index(), | 5601 EXPECT_EQ(grand_child_impl->effect_tree_index(), |
5601 grand_child_impl->render_surface()->EffectTreeIndex()); | 5602 grand_child_impl->GetRenderSurface()->EffectTreeIndex()); |
5602 PostSetNeedsCommitToMainThread(); | 5603 PostSetNeedsCommitToMainThread(); |
5603 break; | 5604 break; |
5604 case 3: | 5605 case 3: |
5605 EXPECT_EQ(grand_child_impl->effect_tree_index(), | 5606 EXPECT_EQ(grand_child_impl->effect_tree_index(), |
5606 grand_child_impl->render_surface()->EffectTreeIndex()); | 5607 grand_child_impl->GetRenderSurface()->EffectTreeIndex()); |
5607 EndTest(); | 5608 EndTest(); |
5608 } | 5609 } |
5609 } | 5610 } |
5610 | 5611 |
5611 void DidCommit() override { | 5612 void DidCommit() override { |
5612 switch (layer_tree_host()->SourceFrameNumber()) { | 5613 switch (layer_tree_host()->SourceFrameNumber()) { |
5613 case 2: | 5614 case 2: |
5614 // Setting an empty viewport causes draws to get skipped, so the active | 5615 // Setting an empty viewport causes draws to get skipped, so the active |
5615 // tree won't update draw properties. | 5616 // tree won't update draw properties. |
5616 layer_tree_host()->SetViewportSize(gfx::Size()); | 5617 layer_tree_host()->SetViewportSize(gfx::Size()); |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7001 EndTest(); | 7002 EndTest(); |
7002 } | 7003 } |
7003 | 7004 |
7004 void AfterTest() override {} | 7005 void AfterTest() override {} |
7005 }; | 7006 }; |
7006 | 7007 |
7007 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); | 7008 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); |
7008 | 7009 |
7009 } // namespace | 7010 } // namespace |
7010 } // namespace cc | 7011 } // namespace cc |
OLD | NEW |