| 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/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" |
| 6 | 6 |
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
| 9 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
| 10 #include "cc/output/filter_operations.h" | 10 #include "cc/output/filter_operations.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} | 82 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} |
| 83 | 83 |
| 84 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { | 84 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { |
| 85 scoped_ptr<LayerImpl> root = | 85 scoped_ptr<LayerImpl> root = |
| 86 LayerImpl::Create(host_impl_.active_tree(), 1); | 86 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 87 scoped_ptr<LayerImpl> child = | 87 scoped_ptr<LayerImpl> child = |
| 88 LayerImpl::Create(host_impl_.active_tree(), 2); | 88 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 89 | 89 |
| 90 root->SetPosition(gfx::PointF()); | 90 root->SetPosition(gfx::PointF()); |
| 91 root->SetBounds(gfx::Size(500, 500)); | 91 root->SetBounds(gfx::Size(500, 500)); |
| 92 root->SetContentBounds(gfx::Size(500, 500)); | |
| 93 root->SetDrawsContent(true); | 92 root->SetDrawsContent(true); |
| 94 root->SetHasRenderSurface(true); | 93 root->SetHasRenderSurface(true); |
| 95 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); | 94 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); |
| 96 | 95 |
| 97 child->SetPosition(gfx::PointF(100.f, 100.f)); | 96 child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 98 child->SetBounds(gfx::Size(30, 30)); | 97 child->SetBounds(gfx::Size(30, 30)); |
| 99 child->SetContentBounds(gfx::Size(30, 30)); | |
| 100 child->SetDrawsContent(true); | 98 child->SetDrawsContent(true); |
| 101 root->AddChild(child.Pass()); | 99 root->AddChild(child.Pass()); |
| 102 | 100 |
| 103 return root.Pass(); | 101 return root.Pass(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 scoped_ptr<LayerImpl> CreateTestTreeWithTwoSurfaces() { | 104 scoped_ptr<LayerImpl> CreateTestTreeWithTwoSurfaces() { |
| 107 // This test tree has two render surfaces: one for the root, and one for | 105 // This test tree has two render surfaces: one for the root, and one for |
| 108 // child1. Additionally, the root has a second child layer, and child1 has | 106 // child1. Additionally, the root has a second child layer, and child1 has |
| 109 // two children of its own. | 107 // two children of its own. |
| 110 | 108 |
| 111 scoped_ptr<LayerImpl> root = | 109 scoped_ptr<LayerImpl> root = |
| 112 LayerImpl::Create(host_impl_.active_tree(), 1); | 110 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 113 scoped_ptr<LayerImpl> child1 = | 111 scoped_ptr<LayerImpl> child1 = |
| 114 LayerImpl::Create(host_impl_.active_tree(), 2); | 112 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 115 scoped_ptr<LayerImpl> child2 = | 113 scoped_ptr<LayerImpl> child2 = |
| 116 LayerImpl::Create(host_impl_.active_tree(), 3); | 114 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 117 scoped_ptr<LayerImpl> grand_child1 = | 115 scoped_ptr<LayerImpl> grand_child1 = |
| 118 LayerImpl::Create(host_impl_.active_tree(), 4); | 116 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 119 scoped_ptr<LayerImpl> grand_child2 = | 117 scoped_ptr<LayerImpl> grand_child2 = |
| 120 LayerImpl::Create(host_impl_.active_tree(), 5); | 118 LayerImpl::Create(host_impl_.active_tree(), 5); |
| 121 | 119 |
| 122 root->SetPosition(gfx::PointF()); | 120 root->SetPosition(gfx::PointF()); |
| 123 root->SetBounds(gfx::Size(500, 500)); | 121 root->SetBounds(gfx::Size(500, 500)); |
| 124 root->SetContentBounds(gfx::Size(500, 500)); | |
| 125 root->SetDrawsContent(true); | 122 root->SetDrawsContent(true); |
| 126 root->SetHasRenderSurface(true); | 123 root->SetHasRenderSurface(true); |
| 127 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); | 124 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); |
| 128 | 125 |
| 129 child1->SetPosition(gfx::PointF(100.f, 100.f)); | 126 child1->SetPosition(gfx::PointF(100.f, 100.f)); |
| 130 child1->SetBounds(gfx::Size(30, 30)); | 127 child1->SetBounds(gfx::Size(30, 30)); |
| 131 child1->SetContentBounds(gfx::Size(30, 30)); | |
| 132 // With a child that draws_content, opacity will cause the layer to create | 128 // With a child that draws_content, opacity will cause the layer to create |
| 133 // its own RenderSurface. This layer does not draw, but is intended to | 129 // its own RenderSurface. This layer does not draw, but is intended to |
| 134 // create its own RenderSurface. | 130 // create its own RenderSurface. |
| 135 child1->SetDrawsContent(false); | 131 child1->SetDrawsContent(false); |
| 136 child1->SetHasRenderSurface(true); | 132 child1->SetHasRenderSurface(true); |
| 137 | 133 |
| 138 child2->SetPosition(gfx::PointF(11.f, 11.f)); | 134 child2->SetPosition(gfx::PointF(11.f, 11.f)); |
| 139 child2->SetBounds(gfx::Size(18, 18)); | 135 child2->SetBounds(gfx::Size(18, 18)); |
| 140 child2->SetContentBounds(gfx::Size(18, 18)); | |
| 141 child2->SetDrawsContent(true); | 136 child2->SetDrawsContent(true); |
| 142 | 137 |
| 143 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); | 138 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); |
| 144 grand_child1->SetBounds(gfx::Size(6, 8)); | 139 grand_child1->SetBounds(gfx::Size(6, 8)); |
| 145 grand_child1->SetContentBounds(gfx::Size(6, 8)); | |
| 146 grand_child1->SetDrawsContent(true); | 140 grand_child1->SetDrawsContent(true); |
| 147 | 141 |
| 148 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); | 142 grand_child2->SetPosition(gfx::PointF(190.f, 190.f)); |
| 149 grand_child2->SetBounds(gfx::Size(6, 8)); | 143 grand_child2->SetBounds(gfx::Size(6, 8)); |
| 150 grand_child2->SetContentBounds(gfx::Size(6, 8)); | |
| 151 grand_child2->SetDrawsContent(true); | 144 grand_child2->SetDrawsContent(true); |
| 152 | 145 |
| 153 child1->AddChild(grand_child1.Pass()); | 146 child1->AddChild(grand_child1.Pass()); |
| 154 child1->AddChild(grand_child2.Pass()); | 147 child1->AddChild(grand_child2.Pass()); |
| 155 root->AddChild(child1.Pass()); | 148 root->AddChild(child1.Pass()); |
| 156 root->AddChild(child2.Pass()); | 149 root->AddChild(child2.Pass()); |
| 157 | 150 |
| 158 return root.Pass(); | 151 return root.Pass(); |
| 159 } | 152 } |
| 160 | 153 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 458 |
| 466 gfx::Transform transform; | 459 gfx::Transform transform; |
| 467 transform.Translate3d(500.0, 500.0, 0.0); | 460 transform.Translate3d(500.0, 500.0, 0.0); |
| 468 transform.ApplyPerspectiveDepth(1.0); | 461 transform.ApplyPerspectiveDepth(1.0); |
| 469 transform.RotateAboutYAxis(45.0); | 462 transform.RotateAboutYAxis(45.0); |
| 470 transform.Translate3d(-50.0, -50.0, 0.0); | 463 transform.Translate3d(-50.0, -50.0, 0.0); |
| 471 | 464 |
| 472 // Set up the child | 465 // Set up the child |
| 473 child->SetPosition(gfx::PointF(0.f, 0.f)); | 466 child->SetPosition(gfx::PointF(0.f, 0.f)); |
| 474 child->SetBounds(gfx::Size(100, 100)); | 467 child->SetBounds(gfx::Size(100, 100)); |
| 475 child->SetContentBounds(gfx::Size(100, 100)); | |
| 476 child->SetTransform(transform); | 468 child->SetTransform(transform); |
| 477 EmulateDrawingOneFrame(root.get()); | 469 EmulateDrawingOneFrame(root.get()); |
| 478 | 470 |
| 479 // Sanity check that the child layer's bounds would actually get clipped by | 471 // Sanity check that the child layer's bounds would actually get clipped by |
| 480 // w < 0, otherwise this test is not actually testing the intended scenario. | 472 // w < 0, otherwise this test is not actually testing the intended scenario. |
| 481 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); | 473 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); |
| 482 bool clipped = false; | 474 bool clipped = false; |
| 483 MathUtil::MapQuad(transform, test_quad, &clipped); | 475 MathUtil::MapQuad(transform, test_quad, &clipped); |
| 484 EXPECT_TRUE(clipped); | 476 EXPECT_TRUE(clipped); |
| 485 | 477 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 LayerImpl* child1 = root->children()[0]; | 695 LayerImpl* child1 = root->children()[0]; |
| 704 | 696 |
| 705 // CASE 1: Adding a new layer should cause the appropriate damage. | 697 // CASE 1: Adding a new layer should cause the appropriate damage. |
| 706 // | 698 // |
| 707 ClearDamageForAllSurfaces(root.get()); | 699 ClearDamageForAllSurfaces(root.get()); |
| 708 { | 700 { |
| 709 scoped_ptr<LayerImpl> child2 = | 701 scoped_ptr<LayerImpl> child2 = |
| 710 LayerImpl::Create(host_impl_.active_tree(), 3); | 702 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 711 child2->SetPosition(gfx::PointF(400.f, 380.f)); | 703 child2->SetPosition(gfx::PointF(400.f, 380.f)); |
| 712 child2->SetBounds(gfx::Size(6, 8)); | 704 child2->SetBounds(gfx::Size(6, 8)); |
| 713 child2->SetContentBounds(gfx::Size(6, 8)); | |
| 714 child2->SetDrawsContent(true); | 705 child2->SetDrawsContent(true); |
| 715 root->AddChild(child2.Pass()); | 706 root->AddChild(child2.Pass()); |
| 716 } | 707 } |
| 717 EmulateDrawingOneFrame(root.get()); | 708 EmulateDrawingOneFrame(root.get()); |
| 718 | 709 |
| 719 // Sanity check - all 3 layers should be on the same render surface; render | 710 // Sanity check - all 3 layers should be on the same render surface; render |
| 720 // surfaces are tested elsewhere. | 711 // surfaces are tested elsewhere. |
| 721 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); | 712 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); |
| 722 | 713 |
| 723 gfx::Rect root_damage_rect = | 714 gfx::Rect root_damage_rect = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 752 // damage of its own, it should still indeed damage the target surface. | 743 // damage of its own, it should still indeed damage the target surface. |
| 753 | 744 |
| 754 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); | 745 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithOneSurface(); |
| 755 | 746 |
| 756 ClearDamageForAllSurfaces(root.get()); | 747 ClearDamageForAllSurfaces(root.get()); |
| 757 { | 748 { |
| 758 scoped_ptr<LayerImpl> child2 = | 749 scoped_ptr<LayerImpl> child2 = |
| 759 LayerImpl::Create(host_impl_.active_tree(), 3); | 750 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 760 child2->SetPosition(gfx::PointF(400.f, 380.f)); | 751 child2->SetPosition(gfx::PointF(400.f, 380.f)); |
| 761 child2->SetBounds(gfx::Size(6, 8)); | 752 child2->SetBounds(gfx::Size(6, 8)); |
| 762 child2->SetContentBounds(gfx::Size(6, 8)); | |
| 763 child2->SetDrawsContent(true); | 753 child2->SetDrawsContent(true); |
| 764 child2->ResetAllChangeTrackingForSubtree(); | 754 child2->ResetAllChangeTrackingForSubtree(); |
| 765 // Sanity check the initial conditions of the test, if these asserts | 755 // Sanity check the initial conditions of the test, if these asserts |
| 766 // trigger, it means the test no longer actually covers the intended | 756 // trigger, it means the test no longer actually covers the intended |
| 767 // scenario. | 757 // scenario. |
| 768 ASSERT_FALSE(child2->LayerPropertyChanged()); | 758 ASSERT_FALSE(child2->LayerPropertyChanged()); |
| 769 ASSERT_TRUE(child2->update_rect().IsEmpty()); | 759 ASSERT_TRUE(child2->update_rect().IsEmpty()); |
| 770 root->AddChild(child2.Pass()); | 760 root->AddChild(child2.Pass()); |
| 771 } | 761 } |
| 772 EmulateDrawingOneFrame(root.get()); | 762 EmulateDrawingOneFrame(root.get()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 785 LayerImpl* child1 = root->children()[0]; | 775 LayerImpl* child1 = root->children()[0]; |
| 786 | 776 |
| 787 // In this test we don't want the above tree manipulation to be considered | 777 // In this test we don't want the above tree manipulation to be considered |
| 788 // part of the same frame. | 778 // part of the same frame. |
| 789 ClearDamageForAllSurfaces(root.get()); | 779 ClearDamageForAllSurfaces(root.get()); |
| 790 { | 780 { |
| 791 scoped_ptr<LayerImpl> child2 = | 781 scoped_ptr<LayerImpl> child2 = |
| 792 LayerImpl::Create(host_impl_.active_tree(), 3); | 782 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 793 child2->SetPosition(gfx::PointF(400.f, 380.f)); | 783 child2->SetPosition(gfx::PointF(400.f, 380.f)); |
| 794 child2->SetBounds(gfx::Size(6, 8)); | 784 child2->SetBounds(gfx::Size(6, 8)); |
| 795 child2->SetContentBounds(gfx::Size(6, 8)); | |
| 796 child2->SetDrawsContent(true); | 785 child2->SetDrawsContent(true); |
| 797 root->AddChild(child2.Pass()); | 786 root->AddChild(child2.Pass()); |
| 798 } | 787 } |
| 799 LayerImpl* child2 = root->children()[1]; | 788 LayerImpl* child2 = root->children()[1]; |
| 800 EmulateDrawingOneFrame(root.get()); | 789 EmulateDrawingOneFrame(root.get()); |
| 801 | 790 |
| 802 // Damaging two layers simultaneously should cause combined damage. | 791 // Damaging two layers simultaneously should cause combined damage. |
| 803 // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); | 792 // - child1 update rect in surface space: gfx::Rect(100, 100, 1, 2); |
| 804 // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); | 793 // - child2 update rect in surface space: gfx::Rect(400, 380, 3, 4); |
| 805 ClearDamageForAllSurfaces(root.get()); | 794 ClearDamageForAllSurfaces(root.get()); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 | 1024 |
| 1036 // For this test case, we modify grand_child2, and add grand_child3 to extend | 1025 // For this test case, we modify grand_child2, and add grand_child3 to extend |
| 1037 // the bounds of child1's surface. This way, we can test reflection changes | 1026 // the bounds of child1's surface. This way, we can test reflection changes |
| 1038 // without changing content_bounds of the surface. | 1027 // without changing content_bounds of the surface. |
| 1039 grand_child2->SetPosition(gfx::PointF(180.f, 180.f)); | 1028 grand_child2->SetPosition(gfx::PointF(180.f, 180.f)); |
| 1040 { | 1029 { |
| 1041 scoped_ptr<LayerImpl> grand_child3 = | 1030 scoped_ptr<LayerImpl> grand_child3 = |
| 1042 LayerImpl::Create(host_impl_.active_tree(), 6); | 1031 LayerImpl::Create(host_impl_.active_tree(), 6); |
| 1043 grand_child3->SetPosition(gfx::PointF(240.f, 240.f)); | 1032 grand_child3->SetPosition(gfx::PointF(240.f, 240.f)); |
| 1044 grand_child3->SetBounds(gfx::Size(10, 10)); | 1033 grand_child3->SetBounds(gfx::Size(10, 10)); |
| 1045 grand_child3->SetContentBounds(gfx::Size(10, 10)); | |
| 1046 grand_child3->SetDrawsContent(true); | 1034 grand_child3->SetDrawsContent(true); |
| 1047 child1->AddChild(grand_child3.Pass()); | 1035 child1->AddChild(grand_child3.Pass()); |
| 1048 } | 1036 } |
| 1049 child1->SetOpacity(0.5f); | 1037 child1->SetOpacity(0.5f); |
| 1050 EmulateDrawingOneFrame(root.get()); | 1038 EmulateDrawingOneFrame(root.get()); |
| 1051 | 1039 |
| 1052 // CASE 1: adding a reflection about the left edge of grand_child1. | 1040 // CASE 1: adding a reflection about the left edge of grand_child1. |
| 1053 // | 1041 // |
| 1054 ClearDamageForAllSurfaces(root.get()); | 1042 ClearDamageForAllSurfaces(root.get()); |
| 1055 { | 1043 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 // layers should damage the entire corresponding surface. | 1125 // layers should damage the entire corresponding surface. |
| 1138 | 1126 |
| 1139 ClearDamageForAllSurfaces(root.get()); | 1127 ClearDamageForAllSurfaces(root.get()); |
| 1140 | 1128 |
| 1141 // Set up the mask layer. | 1129 // Set up the mask layer. |
| 1142 { | 1130 { |
| 1143 scoped_ptr<LayerImpl> mask_layer = | 1131 scoped_ptr<LayerImpl> mask_layer = |
| 1144 LayerImpl::Create(host_impl_.active_tree(), 3); | 1132 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 1145 mask_layer->SetPosition(child->position()); | 1133 mask_layer->SetPosition(child->position()); |
| 1146 mask_layer->SetBounds(child->bounds()); | 1134 mask_layer->SetBounds(child->bounds()); |
| 1147 mask_layer->SetContentBounds(child->bounds()); | |
| 1148 child->SetMaskLayer(mask_layer.Pass()); | 1135 child->SetMaskLayer(mask_layer.Pass()); |
| 1149 child->SetHasRenderSurface(true); | 1136 child->SetHasRenderSurface(true); |
| 1150 } | 1137 } |
| 1151 LayerImpl* mask_layer = child->mask_layer(); | 1138 LayerImpl* mask_layer = child->mask_layer(); |
| 1152 | 1139 |
| 1153 // Add opacity and a grand_child so that the render surface persists even | 1140 // Add opacity and a grand_child so that the render surface persists even |
| 1154 // after we remove the mask. | 1141 // after we remove the mask. |
| 1155 { | 1142 { |
| 1156 scoped_ptr<LayerImpl> grand_child = | 1143 scoped_ptr<LayerImpl> grand_child = |
| 1157 LayerImpl::Create(host_impl_.active_tree(), 4); | 1144 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 1158 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); | 1145 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 1159 grand_child->SetBounds(gfx::Size(2, 2)); | 1146 grand_child->SetBounds(gfx::Size(2, 2)); |
| 1160 grand_child->SetContentBounds(gfx::Size(2, 2)); | |
| 1161 grand_child->SetDrawsContent(true); | 1147 grand_child->SetDrawsContent(true); |
| 1162 child->AddChild(grand_child.Pass()); | 1148 child->AddChild(grand_child.Pass()); |
| 1163 } | 1149 } |
| 1164 EmulateDrawingOneFrame(root.get()); | 1150 EmulateDrawingOneFrame(root.get()); |
| 1165 | 1151 |
| 1166 // CASE 1: the update_rect on a mask layer should damage the entire target | 1152 // CASE 1: the update_rect on a mask layer should damage the entire target |
| 1167 // surface. | 1153 // surface. |
| 1168 ClearDamageForAllSurfaces(root.get()); | 1154 ClearDamageForAllSurfaces(root.get()); |
| 1169 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); | 1155 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); |
| 1170 EmulateDrawingOneFrame(root.get()); | 1156 EmulateDrawingOneFrame(root.get()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 grand_child1->SetHasRenderSurface(true); | 1225 grand_child1->SetHasRenderSurface(true); |
| 1240 } | 1226 } |
| 1241 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1227 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
| 1242 | 1228 |
| 1243 // Set up the mask layer on the replica layer | 1229 // Set up the mask layer on the replica layer |
| 1244 { | 1230 { |
| 1245 scoped_ptr<LayerImpl> replica_mask_layer = | 1231 scoped_ptr<LayerImpl> replica_mask_layer = |
| 1246 LayerImpl::Create(host_impl_.active_tree(), 7); | 1232 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1247 replica_mask_layer->SetPosition(gfx::PointF()); | 1233 replica_mask_layer->SetPosition(gfx::PointF()); |
| 1248 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1234 replica_mask_layer->SetBounds(grand_child1->bounds()); |
| 1249 replica_mask_layer->SetContentBounds(grand_child1->bounds()); | |
| 1250 grand_child1_replica->SetMaskLayer(replica_mask_layer.Pass()); | 1235 grand_child1_replica->SetMaskLayer(replica_mask_layer.Pass()); |
| 1251 } | 1236 } |
| 1252 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); | 1237 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); |
| 1253 | 1238 |
| 1254 EmulateDrawingOneFrame(root.get()); | 1239 EmulateDrawingOneFrame(root.get()); |
| 1255 | 1240 |
| 1256 // Sanity check that the appropriate render surfaces were created | 1241 // Sanity check that the appropriate render surfaces were created |
| 1257 ASSERT_TRUE(grand_child1->render_surface()); | 1242 ASSERT_TRUE(grand_child1->render_surface()); |
| 1258 | 1243 |
| 1259 // CASE 1: a property change on the mask should damage only the reflected | 1244 // CASE 1: a property change on the mask should damage only the reflected |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 } | 1303 } |
| 1319 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1304 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
| 1320 | 1305 |
| 1321 // Set up the mask layer on the replica layer | 1306 // Set up the mask layer on the replica layer |
| 1322 { | 1307 { |
| 1323 scoped_ptr<LayerImpl> replica_mask_layer = | 1308 scoped_ptr<LayerImpl> replica_mask_layer = |
| 1324 LayerImpl::Create(host_impl_.active_tree(), 7); | 1309 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1325 replica_mask_layer->SetPosition(gfx::PointF()); | 1310 replica_mask_layer->SetPosition(gfx::PointF()); |
| 1326 // Note: this is not the transform origin being tested. | 1311 // Note: this is not the transform origin being tested. |
| 1327 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1312 replica_mask_layer->SetBounds(grand_child1->bounds()); |
| 1328 replica_mask_layer->SetContentBounds(grand_child1->bounds()); | |
| 1329 grand_child1_replica->SetMaskLayer(replica_mask_layer.Pass()); | 1313 grand_child1_replica->SetMaskLayer(replica_mask_layer.Pass()); |
| 1330 } | 1314 } |
| 1331 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); | 1315 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); |
| 1332 | 1316 |
| 1333 EmulateDrawingOneFrame(root.get()); | 1317 EmulateDrawingOneFrame(root.get()); |
| 1334 | 1318 |
| 1335 // Sanity check that the appropriate render surfaces were created | 1319 // Sanity check that the appropriate render surfaces were created |
| 1336 ASSERT_TRUE(grand_child1->render_surface()); | 1320 ASSERT_TRUE(grand_child1->render_surface()); |
| 1337 | 1321 |
| 1338 // A property change on the replica_mask should damage the reflected region on | 1322 // A property change on the replica_mask should damage the reflected region on |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 scoped_ptr<LayerImpl> root = CreateTestTreeWithOneSurface(); | 1436 scoped_ptr<LayerImpl> root = CreateTestTreeWithOneSurface(); |
| 1453 LayerImpl* child = root->children()[0]; | 1437 LayerImpl* child = root->children()[0]; |
| 1454 | 1438 |
| 1455 gfx::Transform transform; | 1439 gfx::Transform transform; |
| 1456 transform.Translate(-kBigNumber, -kBigNumber); | 1440 transform.Translate(-kBigNumber, -kBigNumber); |
| 1457 | 1441 |
| 1458 // The child layer covers (0, 0, i, i) of the viewport, | 1442 // The child layer covers (0, 0, i, i) of the viewport, |
| 1459 // but has a huge negative position. | 1443 // but has a huge negative position. |
| 1460 child->SetPosition(gfx::PointF()); | 1444 child->SetPosition(gfx::PointF()); |
| 1461 child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); | 1445 child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); |
| 1462 child->SetContentBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); | |
| 1463 child->SetTransform(transform); | 1446 child->SetTransform(transform); |
| 1464 EmulateDrawingOneFrame(root.get()); | 1447 EmulateDrawingOneFrame(root.get()); |
| 1465 | 1448 |
| 1466 // The expected damage should cover the visible part of the child layer, | 1449 // The expected damage should cover the visible part of the child layer, |
| 1467 // which is (0, 0, i, i) in the viewport. | 1450 // which is (0, 0, i, i) in the viewport. |
| 1468 gfx::Rect root_damage_rect = | 1451 gfx::Rect root_damage_rect = |
| 1469 root->render_surface()->damage_tracker()->current_damage_rect(); | 1452 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1470 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1453 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1471 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1454 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1472 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1455 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1473 } | 1456 } |
| 1474 } | 1457 } |
| 1475 | 1458 |
| 1476 } // namespace | 1459 } // namespace |
| 1477 } // namespace cc | 1460 } // namespace cc |
| OLD | NEW |