| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 class DamageTrackerTest : public testing::Test { | 83 class DamageTrackerTest : public testing::Test { |
| 84 public: | 84 public: |
| 85 DamageTrackerTest() | 85 DamageTrackerTest() |
| 86 : host_impl_(&task_runner_provider_, | 86 : host_impl_(&task_runner_provider_, |
| 87 &shared_bitmap_manager_, | 87 &shared_bitmap_manager_, |
| 88 &task_graph_runner_) {} | 88 &task_graph_runner_) {} |
| 89 | 89 |
| 90 LayerImpl* CreateTestTreeWithOneSurface() { | 90 LayerImpl* CreateTestTreeWithOneSurface() { |
| 91 host_impl_.active_tree()->ClearLayers(); | 91 host_impl_.active_tree()->ClearLayers(); |
| 92 scoped_ptr<LayerImpl> root = | 92 std::unique_ptr<LayerImpl> root = |
| 93 LayerImpl::Create(host_impl_.active_tree(), 1); | 93 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 94 scoped_ptr<LayerImpl> child = | 94 std::unique_ptr<LayerImpl> child = |
| 95 LayerImpl::Create(host_impl_.active_tree(), 2); | 95 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 96 | 96 |
| 97 root->SetPosition(gfx::PointF()); | 97 root->SetPosition(gfx::PointF()); |
| 98 root->SetBounds(gfx::Size(500, 500)); | 98 root->SetBounds(gfx::Size(500, 500)); |
| 99 root->SetDrawsContent(true); | 99 root->SetDrawsContent(true); |
| 100 root->SetForceRenderSurface(true); | 100 root->SetForceRenderSurface(true); |
| 101 | 101 |
| 102 child->SetPosition(gfx::PointF(100.f, 100.f)); | 102 child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 103 child->SetBounds(gfx::Size(30, 30)); | 103 child->SetBounds(gfx::Size(30, 30)); |
| 104 child->SetDrawsContent(true); | 104 child->SetDrawsContent(true); |
| 105 root->AddChild(std::move(child)); | 105 root->AddChild(std::move(child)); |
| 106 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 106 host_impl_.active_tree()->SetRootLayer(std::move(root)); |
| 107 | 107 |
| 108 return host_impl_.active_tree()->root_layer(); | 108 return host_impl_.active_tree()->root_layer(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 LayerImpl* CreateTestTreeWithTwoSurfaces() { | 111 LayerImpl* CreateTestTreeWithTwoSurfaces() { |
| 112 // This test tree has two render surfaces: one for the root, and one for | 112 // This test tree has two render surfaces: one for the root, and one for |
| 113 // child1. Additionally, the root has a second child layer, and child1 has | 113 // child1. Additionally, the root has a second child layer, and child1 has |
| 114 // two children of its own. | 114 // two children of its own. |
| 115 | 115 |
| 116 host_impl_.active_tree()->ClearLayers(); | 116 host_impl_.active_tree()->ClearLayers(); |
| 117 scoped_ptr<LayerImpl> root = | 117 std::unique_ptr<LayerImpl> root = |
| 118 LayerImpl::Create(host_impl_.active_tree(), 1); | 118 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 119 scoped_ptr<LayerImpl> child1 = | 119 std::unique_ptr<LayerImpl> child1 = |
| 120 LayerImpl::Create(host_impl_.active_tree(), 2); | 120 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 121 scoped_ptr<LayerImpl> child2 = | 121 std::unique_ptr<LayerImpl> child2 = |
| 122 LayerImpl::Create(host_impl_.active_tree(), 3); | 122 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 123 scoped_ptr<LayerImpl> grand_child1 = | 123 std::unique_ptr<LayerImpl> grand_child1 = |
| 124 LayerImpl::Create(host_impl_.active_tree(), 4); | 124 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 125 scoped_ptr<LayerImpl> grand_child2 = | 125 std::unique_ptr<LayerImpl> grand_child2 = |
| 126 LayerImpl::Create(host_impl_.active_tree(), 5); | 126 LayerImpl::Create(host_impl_.active_tree(), 5); |
| 127 | 127 |
| 128 root->SetPosition(gfx::PointF()); | 128 root->SetPosition(gfx::PointF()); |
| 129 root->SetBounds(gfx::Size(500, 500)); | 129 root->SetBounds(gfx::Size(500, 500)); |
| 130 root->SetDrawsContent(true); | 130 root->SetDrawsContent(true); |
| 131 root->SetForceRenderSurface(true); | 131 root->SetForceRenderSurface(true); |
| 132 | 132 |
| 133 child1->SetPosition(gfx::PointF(100.f, 100.f)); | 133 child1->SetPosition(gfx::PointF(100.f, 100.f)); |
| 134 child1->SetBounds(gfx::Size(30, 30)); | 134 child1->SetBounds(gfx::Size(30, 30)); |
| 135 // With a child that draws_content, opacity will cause the layer to create | 135 // With a child that draws_content, opacity will cause the layer to create |
| 136 // its own RenderSurface. This layer does not draw, but is intended to | 136 // its own RenderSurface. This layer does not draw, but is intended to |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 } | 745 } |
| 746 | 746 |
| 747 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { | 747 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingLayer) { |
| 748 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 748 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 749 LayerImpl* child1 = root->children()[0]; | 749 LayerImpl* child1 = root->children()[0]; |
| 750 | 750 |
| 751 // CASE 1: Adding a new layer should cause the appropriate damage. | 751 // CASE 1: Adding a new layer should cause the appropriate damage. |
| 752 // | 752 // |
| 753 ClearDamageForAllSurfaces(root); | 753 ClearDamageForAllSurfaces(root); |
| 754 { | 754 { |
| 755 scoped_ptr<LayerImpl> child2 = | 755 std::unique_ptr<LayerImpl> child2 = |
| 756 LayerImpl::Create(host_impl_.active_tree(), 3); | 756 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 757 child2->SetPosition(gfx::PointF(400.f, 380.f)); | 757 child2->SetPosition(gfx::PointF(400.f, 380.f)); |
| 758 child2->SetBounds(gfx::Size(6, 8)); | 758 child2->SetBounds(gfx::Size(6, 8)); |
| 759 child2->SetDrawsContent(true); | 759 child2->SetDrawsContent(true); |
| 760 root->AddChild(std::move(child2)); | 760 root->AddChild(std::move(child2)); |
| 761 } | 761 } |
| 762 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 762 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 763 EmulateDrawingOneFrame(root); | 763 EmulateDrawingOneFrame(root); |
| 764 | 764 |
| 765 // Sanity check - all 3 layers should be on the same render surface; render | 765 // Sanity check - all 3 layers should be on the same render surface; render |
| 766 // surfaces are tested elsewhere. | 766 // surfaces are tested elsewhere. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 796 } | 796 } |
| 797 | 797 |
| 798 TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { | 798 TEST_F(DamageTrackerTest, VerifyDamageForNewUnchangedLayer) { |
| 799 // If child2 is added to the layer tree, but it doesn't have any explicit | 799 // If child2 is added to the layer tree, but it doesn't have any explicit |
| 800 // damage of its own, it should still indeed damage the target surface. | 800 // damage of its own, it should still indeed damage the target surface. |
| 801 | 801 |
| 802 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 802 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 803 | 803 |
| 804 ClearDamageForAllSurfaces(root); | 804 ClearDamageForAllSurfaces(root); |
| 805 { | 805 { |
| 806 scoped_ptr<LayerImpl> child2 = | 806 std::unique_ptr<LayerImpl> child2 = |
| 807 LayerImpl::Create(host_impl_.active_tree(), 3); | 807 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 808 child2->SetPosition(gfx::PointF(400.f, 380.f)); | 808 child2->SetPosition(gfx::PointF(400.f, 380.f)); |
| 809 child2->SetBounds(gfx::Size(6, 8)); | 809 child2->SetBounds(gfx::Size(6, 8)); |
| 810 child2->SetDrawsContent(true); | 810 child2->SetDrawsContent(true); |
| 811 root->AddChild(std::move(child2)); | 811 root->AddChild(std::move(child2)); |
| 812 host_impl_.active_tree()->ResetAllChangeTracking( | 812 host_impl_.active_tree()->ResetAllChangeTracking( |
| 813 PropertyTrees::ResetFlags::ALL_TREES); | 813 PropertyTrees::ResetFlags::ALL_TREES); |
| 814 LayerImpl* child2_ptr = host_impl_.active_tree()->LayerById(3); | 814 LayerImpl* child2_ptr = host_impl_.active_tree()->LayerById(3); |
| 815 // Sanity check the initial conditions of the test, if these asserts | 815 // Sanity check the initial conditions of the test, if these asserts |
| 816 // trigger, it means the test no longer actually covers the intended | 816 // trigger, it means the test no longer actually covers the intended |
| 817 // scenario. | 817 // scenario. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 831 } | 831 } |
| 832 | 832 |
| 833 TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { | 833 TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { |
| 834 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 834 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 835 LayerImpl* child1 = root->children()[0]; | 835 LayerImpl* child1 = root->children()[0]; |
| 836 | 836 |
| 837 // In this test we don't want the above tree manipulation to be considered | 837 // In this test we don't want the above tree manipulation to be considered |
| 838 // part of the same frame. | 838 // part of the same frame. |
| 839 ClearDamageForAllSurfaces(root); | 839 ClearDamageForAllSurfaces(root); |
| 840 { | 840 { |
| 841 scoped_ptr<LayerImpl> child2 = | 841 std::unique_ptr<LayerImpl> child2 = |
| 842 LayerImpl::Create(host_impl_.active_tree(), 3); | 842 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 843 child2->SetPosition(gfx::PointF(400.f, 380.f)); | 843 child2->SetPosition(gfx::PointF(400.f, 380.f)); |
| 844 child2->SetBounds(gfx::Size(6, 8)); | 844 child2->SetBounds(gfx::Size(6, 8)); |
| 845 child2->SetDrawsContent(true); | 845 child2->SetDrawsContent(true); |
| 846 root->AddChild(std::move(child2)); | 846 root->AddChild(std::move(child2)); |
| 847 } | 847 } |
| 848 LayerImpl* child2 = root->children()[1]; | 848 LayerImpl* child2 = root->children()[1]; |
| 849 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 849 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 850 EmulateDrawingOneFrame(root); | 850 EmulateDrawingOneFrame(root); |
| 851 | 851 |
| 852 // Damaging two layers simultaneously should cause combined damage. | 852 // Damaging two layers simultaneously should cause combined damage. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 LayerImpl* grand_child2 = child1->children()[1]; | 1099 LayerImpl* grand_child2 = child1->children()[1]; |
| 1100 | 1100 |
| 1101 // Damage on a surface that has a reflection should cause the target surface | 1101 // Damage on a surface that has a reflection should cause the target surface |
| 1102 // to receive the surface's damage and the surface's reflected damage. | 1102 // to receive the surface's damage and the surface's reflected damage. |
| 1103 | 1103 |
| 1104 // For this test case, we modify grand_child2, and add grand_child3 to extend | 1104 // For this test case, we modify grand_child2, and add grand_child3 to extend |
| 1105 // the bounds of child1's surface. This way, we can test reflection changes | 1105 // the bounds of child1's surface. This way, we can test reflection changes |
| 1106 // without changing content_bounds of the surface. | 1106 // without changing content_bounds of the surface. |
| 1107 grand_child2->SetPosition(gfx::PointF(180.f, 180.f)); | 1107 grand_child2->SetPosition(gfx::PointF(180.f, 180.f)); |
| 1108 { | 1108 { |
| 1109 scoped_ptr<LayerImpl> grand_child3 = | 1109 std::unique_ptr<LayerImpl> grand_child3 = |
| 1110 LayerImpl::Create(host_impl_.active_tree(), 6); | 1110 LayerImpl::Create(host_impl_.active_tree(), 6); |
| 1111 grand_child3->SetPosition(gfx::PointF(240.f, 240.f)); | 1111 grand_child3->SetPosition(gfx::PointF(240.f, 240.f)); |
| 1112 grand_child3->SetBounds(gfx::Size(10, 10)); | 1112 grand_child3->SetBounds(gfx::Size(10, 10)); |
| 1113 grand_child3->SetDrawsContent(true); | 1113 grand_child3->SetDrawsContent(true); |
| 1114 child1->AddChild(std::move(grand_child3)); | 1114 child1->AddChild(std::move(grand_child3)); |
| 1115 } | 1115 } |
| 1116 child1->SetOpacity(0.5f); | 1116 child1->SetOpacity(0.5f); |
| 1117 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1117 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1118 EmulateDrawingOneFrame(root); | 1118 EmulateDrawingOneFrame(root); |
| 1119 | 1119 |
| 1120 // CASE 1: adding a reflection about the left edge of grand_child1. | 1120 // CASE 1: adding a reflection about the left edge of grand_child1. |
| 1121 // | 1121 // |
| 1122 ClearDamageForAllSurfaces(root); | 1122 ClearDamageForAllSurfaces(root); |
| 1123 { | 1123 { |
| 1124 scoped_ptr<LayerImpl> grand_child1_replica = | 1124 std::unique_ptr<LayerImpl> grand_child1_replica = |
| 1125 LayerImpl::Create(host_impl_.active_tree(), 7); | 1125 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1126 grand_child1_replica->SetPosition(gfx::PointF()); | 1126 grand_child1_replica->SetPosition(gfx::PointF()); |
| 1127 gfx::Transform reflection; | 1127 gfx::Transform reflection; |
| 1128 reflection.Scale3d(-1.0, 1.0, 1.0); | 1128 reflection.Scale3d(-1.0, 1.0, 1.0); |
| 1129 grand_child1_replica->SetTransform(reflection); | 1129 grand_child1_replica->SetTransform(reflection); |
| 1130 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); | 1130 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); |
| 1131 grand_child1->SetForceRenderSurface(true); | 1131 grand_child1->SetForceRenderSurface(true); |
| 1132 } | 1132 } |
| 1133 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1133 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1134 EmulateDrawingOneFrame(root); | 1134 EmulateDrawingOneFrame(root); |
| 1135 | 1135 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); | 1205 LayerImpl* root = CreateAndSetUpTestTreeWithOneSurface(); |
| 1206 LayerImpl* child = root->children()[0]; | 1206 LayerImpl* child = root->children()[0]; |
| 1207 | 1207 |
| 1208 // In the current implementation of the damage tracker, changes to mask | 1208 // In the current implementation of the damage tracker, changes to mask |
| 1209 // layers should damage the entire corresponding surface. | 1209 // layers should damage the entire corresponding surface. |
| 1210 | 1210 |
| 1211 ClearDamageForAllSurfaces(root); | 1211 ClearDamageForAllSurfaces(root); |
| 1212 | 1212 |
| 1213 // Set up the mask layer. | 1213 // Set up the mask layer. |
| 1214 { | 1214 { |
| 1215 scoped_ptr<LayerImpl> mask_layer = | 1215 std::unique_ptr<LayerImpl> mask_layer = |
| 1216 LayerImpl::Create(host_impl_.active_tree(), 3); | 1216 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 1217 mask_layer->SetPosition(child->position()); | 1217 mask_layer->SetPosition(child->position()); |
| 1218 mask_layer->SetBounds(child->bounds()); | 1218 mask_layer->SetBounds(child->bounds()); |
| 1219 child->SetMaskLayer(std::move(mask_layer)); | 1219 child->SetMaskLayer(std::move(mask_layer)); |
| 1220 child->SetForceRenderSurface(true); | 1220 child->SetForceRenderSurface(true); |
| 1221 } | 1221 } |
| 1222 LayerImpl* mask_layer = child->mask_layer(); | 1222 LayerImpl* mask_layer = child->mask_layer(); |
| 1223 | 1223 |
| 1224 // Add opacity and a grand_child so that the render surface persists even | 1224 // Add opacity and a grand_child so that the render surface persists even |
| 1225 // after we remove the mask. | 1225 // after we remove the mask. |
| 1226 { | 1226 { |
| 1227 scoped_ptr<LayerImpl> grand_child = | 1227 std::unique_ptr<LayerImpl> grand_child = |
| 1228 LayerImpl::Create(host_impl_.active_tree(), 4); | 1228 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 1229 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); | 1229 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 1230 grand_child->SetBounds(gfx::Size(2, 2)); | 1230 grand_child->SetBounds(gfx::Size(2, 2)); |
| 1231 grand_child->SetDrawsContent(true); | 1231 grand_child->SetDrawsContent(true); |
| 1232 child->AddChild(std::move(grand_child)); | 1232 child->AddChild(std::move(grand_child)); |
| 1233 } | 1233 } |
| 1234 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1234 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1235 EmulateDrawingOneFrame(root); | 1235 EmulateDrawingOneFrame(root); |
| 1236 | 1236 |
| 1237 // CASE 1: the update_rect on a mask layer should damage the entire target | 1237 // CASE 1: the update_rect on a mask layer should damage the entire target |
| 1238 // surface. | 1238 // surface. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 LayerImpl* child1 = root->children()[0]; | 1299 LayerImpl* child1 = root->children()[0]; |
| 1300 LayerImpl* grand_child1 = child1->children()[0]; | 1300 LayerImpl* grand_child1 = child1->children()[0]; |
| 1301 | 1301 |
| 1302 // Changes to a replica's mask should not damage the original surface, | 1302 // Changes to a replica's mask should not damage the original surface, |
| 1303 // because it is not masked. But it does damage the ancestor target surface. | 1303 // because it is not masked. But it does damage the ancestor target surface. |
| 1304 | 1304 |
| 1305 ClearDamageForAllSurfaces(root); | 1305 ClearDamageForAllSurfaces(root); |
| 1306 | 1306 |
| 1307 // Create a reflection about the left edge of grand_child1. | 1307 // Create a reflection about the left edge of grand_child1. |
| 1308 { | 1308 { |
| 1309 scoped_ptr<LayerImpl> grand_child1_replica = | 1309 std::unique_ptr<LayerImpl> grand_child1_replica = |
| 1310 LayerImpl::Create(host_impl_.active_tree(), 6); | 1310 LayerImpl::Create(host_impl_.active_tree(), 6); |
| 1311 grand_child1_replica->SetPosition(gfx::PointF()); | 1311 grand_child1_replica->SetPosition(gfx::PointF()); |
| 1312 gfx::Transform reflection; | 1312 gfx::Transform reflection; |
| 1313 reflection.Scale3d(-1.0, 1.0, 1.0); | 1313 reflection.Scale3d(-1.0, 1.0, 1.0); |
| 1314 grand_child1_replica->SetTransform(reflection); | 1314 grand_child1_replica->SetTransform(reflection); |
| 1315 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); | 1315 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); |
| 1316 grand_child1->SetForceRenderSurface(true); | 1316 grand_child1->SetForceRenderSurface(true); |
| 1317 } | 1317 } |
| 1318 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1318 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
| 1319 | 1319 |
| 1320 // Set up the mask layer on the replica layer | 1320 // Set up the mask layer on the replica layer |
| 1321 { | 1321 { |
| 1322 scoped_ptr<LayerImpl> replica_mask_layer = | 1322 std::unique_ptr<LayerImpl> replica_mask_layer = |
| 1323 LayerImpl::Create(host_impl_.active_tree(), 7); | 1323 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1324 replica_mask_layer->SetPosition(gfx::PointF()); | 1324 replica_mask_layer->SetPosition(gfx::PointF()); |
| 1325 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1325 replica_mask_layer->SetBounds(grand_child1->bounds()); |
| 1326 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); | 1326 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); |
| 1327 } | 1327 } |
| 1328 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); | 1328 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); |
| 1329 | 1329 |
| 1330 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1330 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1331 EmulateDrawingOneFrame(root); | 1331 EmulateDrawingOneFrame(root); |
| 1332 | 1332 |
| 1333 // Sanity check that the appropriate render surfaces were created | 1333 // Sanity check that the appropriate render surfaces were created |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 // replica_mask. | 1375 // replica_mask. |
| 1376 ClearDamageForAllSurfaces(root); | 1376 ClearDamageForAllSurfaces(root); |
| 1377 | 1377 |
| 1378 // This is not actually the transform origin point being tested, but by | 1378 // This is not actually the transform origin point being tested, but by |
| 1379 // convention its | 1379 // convention its |
| 1380 // expected to be the same as the replica's anchor point. | 1380 // expected to be the same as the replica's anchor point. |
| 1381 grand_child1->SetTransformOrigin( | 1381 grand_child1->SetTransformOrigin( |
| 1382 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); | 1382 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); |
| 1383 | 1383 |
| 1384 { | 1384 { |
| 1385 scoped_ptr<LayerImpl> grand_child1_replica = | 1385 std::unique_ptr<LayerImpl> grand_child1_replica = |
| 1386 LayerImpl::Create(host_impl_.active_tree(), 6); | 1386 LayerImpl::Create(host_impl_.active_tree(), 6); |
| 1387 grand_child1_replica->SetPosition(gfx::PointF()); | 1387 grand_child1_replica->SetPosition(gfx::PointF()); |
| 1388 | 1388 |
| 1389 // This is the anchor being tested. | 1389 // This is the anchor being tested. |
| 1390 grand_child1_replica->SetTransformOrigin( | 1390 grand_child1_replica->SetTransformOrigin( |
| 1391 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); | 1391 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); |
| 1392 gfx::Transform reflection; | 1392 gfx::Transform reflection; |
| 1393 reflection.Scale3d(-1.0, 1.0, 1.0); | 1393 reflection.Scale3d(-1.0, 1.0, 1.0); |
| 1394 grand_child1_replica->SetTransform(reflection); | 1394 grand_child1_replica->SetTransform(reflection); |
| 1395 // We need to set parent on replica layer for property tree building. | 1395 // We need to set parent on replica layer for property tree building. |
| 1396 grand_child1_replica->SetParent(grand_child1); | 1396 grand_child1_replica->SetParent(grand_child1); |
| 1397 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); | 1397 grand_child1->SetReplicaLayer(std::move(grand_child1_replica)); |
| 1398 grand_child1->SetForceRenderSurface(true); | 1398 grand_child1->SetForceRenderSurface(true); |
| 1399 } | 1399 } |
| 1400 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1400 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
| 1401 | 1401 |
| 1402 // Set up the mask layer on the replica layer | 1402 // Set up the mask layer on the replica layer |
| 1403 { | 1403 { |
| 1404 scoped_ptr<LayerImpl> replica_mask_layer = | 1404 std::unique_ptr<LayerImpl> replica_mask_layer = |
| 1405 LayerImpl::Create(host_impl_.active_tree(), 7); | 1405 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1406 replica_mask_layer->SetPosition(gfx::PointF()); | 1406 replica_mask_layer->SetPosition(gfx::PointF()); |
| 1407 // Note: this is not the transform origin being tested. | 1407 // Note: this is not the transform origin being tested. |
| 1408 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1408 replica_mask_layer->SetBounds(grand_child1->bounds()); |
| 1409 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); | 1409 grand_child1_replica->SetMaskLayer(std::move(replica_mask_layer)); |
| 1410 } | 1410 } |
| 1411 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); | 1411 LayerImpl* replica_mask_layer = grand_child1_replica->mask_layer(); |
| 1412 | 1412 |
| 1413 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1413 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1414 EmulateDrawingOneFrame(root); | 1414 EmulateDrawingOneFrame(root); |
| 1415 | 1415 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 EmulateDrawingOneFrame(root); | 1458 EmulateDrawingOneFrame(root); |
| 1459 root_damage_rect = | 1459 root_damage_rect = |
| 1460 root->render_surface()->damage_tracker()->current_damage_rect(); | 1460 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1461 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); | 1461 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { | 1464 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { |
| 1465 // Though it should never happen, its a good idea to verify that the damage | 1465 // Though it should never happen, its a good idea to verify that the damage |
| 1466 // tracker does not crash when it receives an empty layer_list. | 1466 // tracker does not crash when it receives an empty layer_list. |
| 1467 | 1467 |
| 1468 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); | 1468 std::unique_ptr<LayerImpl> root = |
| 1469 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 1469 root->SetForceRenderSurface(true); | 1470 root->SetForceRenderSurface(true); |
| 1470 host_impl_.active_tree()->SetRootLayer(std::move(root)); | 1471 host_impl_.active_tree()->SetRootLayer(std::move(root)); |
| 1471 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer(); | 1472 LayerImpl* root_ptr = host_impl_.active_tree()->root_layer(); |
| 1472 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1473 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 1473 EmulateDrawingOneFrame(root_ptr); | 1474 EmulateDrawingOneFrame(root_ptr); |
| 1474 root_ptr->draw_properties().render_target = root_ptr; | 1475 root_ptr->draw_properties().render_target = root_ptr; |
| 1475 | 1476 |
| 1476 ASSERT_EQ(root_ptr, root_ptr->render_target()); | 1477 ASSERT_EQ(root_ptr, root_ptr->render_target()); |
| 1477 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); | 1478 RenderSurfaceImpl* target_surface = root_ptr->render_surface(); |
| 1478 | 1479 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 gfx::Rect root_damage_rect = | 1560 gfx::Rect root_damage_rect = |
| 1560 root->render_surface()->damage_tracker()->current_damage_rect(); | 1561 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1561 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1562 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1562 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1563 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1563 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1564 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1564 } | 1565 } |
| 1565 } | 1566 } |
| 1566 | 1567 |
| 1567 } // namespace | 1568 } // namespace |
| 1568 } // namespace cc | 1569 } // namespace cc |
| OLD | NEW |