| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { | 79 scoped_ptr<LayerImpl> CreateTestTreeWithOneSurface() { |
| 80 scoped_ptr<LayerImpl> root = | 80 scoped_ptr<LayerImpl> root = |
| 81 LayerImpl::Create(host_impl_.active_tree(), 1); | 81 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 82 scoped_ptr<LayerImpl> child = | 82 scoped_ptr<LayerImpl> child = |
| 83 LayerImpl::Create(host_impl_.active_tree(), 2); | 83 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 84 | 84 |
| 85 root->SetPosition(gfx::PointF()); | 85 root->SetPosition(gfx::PointF()); |
| 86 root->SetBounds(gfx::Size(500, 500)); | 86 root->SetBounds(gfx::Size(500, 500)); |
| 87 root->SetContentBounds(gfx::Size(500, 500)); | 87 root->SetContentBounds(gfx::Size(500, 500)); |
| 88 root->SetDrawsContent(true); | 88 root->SetDrawsContent(true); |
| 89 root->CreateRenderSurface(); | 89 root->SetHasRenderSurface(true); |
| 90 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); | 90 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); |
| 91 | 91 |
| 92 child->SetPosition(gfx::PointF(100.f, 100.f)); | 92 child->SetPosition(gfx::PointF(100.f, 100.f)); |
| 93 child->SetBounds(gfx::Size(30, 30)); | 93 child->SetBounds(gfx::Size(30, 30)); |
| 94 child->SetContentBounds(gfx::Size(30, 30)); | 94 child->SetContentBounds(gfx::Size(30, 30)); |
| 95 child->SetDrawsContent(true); | 95 child->SetDrawsContent(true); |
| 96 root->AddChild(child.Pass()); | 96 root->AddChild(child.Pass()); |
| 97 | 97 |
| 98 return root.Pass(); | 98 return root.Pass(); |
| 99 } | 99 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 111 LayerImpl::Create(host_impl_.active_tree(), 3); | 111 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 112 scoped_ptr<LayerImpl> grand_child1 = | 112 scoped_ptr<LayerImpl> grand_child1 = |
| 113 LayerImpl::Create(host_impl_.active_tree(), 4); | 113 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 114 scoped_ptr<LayerImpl> grand_child2 = | 114 scoped_ptr<LayerImpl> grand_child2 = |
| 115 LayerImpl::Create(host_impl_.active_tree(), 5); | 115 LayerImpl::Create(host_impl_.active_tree(), 5); |
| 116 | 116 |
| 117 root->SetPosition(gfx::PointF()); | 117 root->SetPosition(gfx::PointF()); |
| 118 root->SetBounds(gfx::Size(500, 500)); | 118 root->SetBounds(gfx::Size(500, 500)); |
| 119 root->SetContentBounds(gfx::Size(500, 500)); | 119 root->SetContentBounds(gfx::Size(500, 500)); |
| 120 root->SetDrawsContent(true); | 120 root->SetDrawsContent(true); |
| 121 root->CreateRenderSurface(); | 121 root->SetHasRenderSurface(true); |
| 122 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); | 122 root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); |
| 123 | 123 |
| 124 child1->SetPosition(gfx::PointF(100.f, 100.f)); | 124 child1->SetPosition(gfx::PointF(100.f, 100.f)); |
| 125 child1->SetBounds(gfx::Size(30, 30)); | 125 child1->SetBounds(gfx::Size(30, 30)); |
| 126 child1->SetContentBounds(gfx::Size(30, 30)); | 126 child1->SetContentBounds(gfx::Size(30, 30)); |
| 127 // With a child that draws_content, opacity will cause the layer to create | 127 // With a child that draws_content, opacity will cause the layer to create |
| 128 // its own RenderSurface. This layer does not draw, but is intended to | 128 // its own RenderSurface. This layer does not draw, but is intended to |
| 129 // create its own RenderSurface. TODO: setting opacity and | 129 // create its own RenderSurface. |
| 130 // ForceRenderSurface may be redundant here. | |
| 131 child1->SetOpacity(0.5f); | |
| 132 child1->SetDrawsContent(false); | 130 child1->SetDrawsContent(false); |
| 133 child1->SetForceRenderSurface(true); | 131 child1->SetHasRenderSurface(true); |
| 134 | 132 |
| 135 child2->SetPosition(gfx::PointF(11.f, 11.f)); | 133 child2->SetPosition(gfx::PointF(11.f, 11.f)); |
| 136 child2->SetBounds(gfx::Size(18, 18)); | 134 child2->SetBounds(gfx::Size(18, 18)); |
| 137 child2->SetContentBounds(gfx::Size(18, 18)); | 135 child2->SetContentBounds(gfx::Size(18, 18)); |
| 138 child2->SetDrawsContent(true); | 136 child2->SetDrawsContent(true); |
| 139 | 137 |
| 140 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); | 138 grand_child1->SetPosition(gfx::PointF(200.f, 200.f)); |
| 141 grand_child1->SetBounds(gfx::Size(6, 8)); | 139 grand_child1->SetBounds(gfx::Size(6, 8)); |
| 142 grand_child1->SetContentBounds(gfx::Size(6, 8)); | 140 grand_child1->SetContentBounds(gfx::Size(6, 8)); |
| 143 grand_child1->SetDrawsContent(true); | 141 grand_child1->SetDrawsContent(true); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 child->SetDrawsContent(true); | 534 child->SetDrawsContent(true); |
| 537 | 535 |
| 538 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( | 536 skia::RefPtr<SkImageFilter> filter = skia::AdoptRef( |
| 539 SkBlurImageFilter::Create(SkIntToScalar(2), SkIntToScalar(2))); | 537 SkBlurImageFilter::Create(SkIntToScalar(2), SkIntToScalar(2))); |
| 540 FilterOperations filters; | 538 FilterOperations filters; |
| 541 filters.Append(FilterOperation::CreateReferenceFilter(filter)); | 539 filters.Append(FilterOperation::CreateReferenceFilter(filter)); |
| 542 | 540 |
| 543 // Setting the filter will damage the whole surface. | 541 // Setting the filter will damage the whole surface. |
| 544 ClearDamageForAllSurfaces(root.get()); | 542 ClearDamageForAllSurfaces(root.get()); |
| 545 child->SetFilters(filters); | 543 child->SetFilters(filters); |
| 544 child->SetHasRenderSurface(true); |
| 546 EmulateDrawingOneFrame(root.get()); | 545 EmulateDrawingOneFrame(root.get()); |
| 547 root_damage_rect = | 546 root_damage_rect = |
| 548 root->render_surface()->damage_tracker()->current_damage_rect(); | 547 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 549 child_damage_rect = | 548 child_damage_rect = |
| 550 child->render_surface()->damage_tracker()->current_damage_rect(); | 549 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 551 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), | 550 EXPECT_EQ(gfx::Rect(100, 100, 30, 30).ToString(), |
| 552 root_damage_rect.ToString()); | 551 root_damage_rect.ToString()); |
| 553 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); | 552 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
| 554 | 553 |
| 555 // CASE 1: Setting the update rect should damage the whole surface (for now) | 554 // CASE 1: Setting the update rect should damage the whole surface (for now) |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 | 918 |
| 920 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { | 919 TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { |
| 921 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 920 scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); |
| 922 LayerImpl* child1 = root->children()[0]; | 921 LayerImpl* child1 = root->children()[0]; |
| 923 gfx::Rect child_damage_rect; | 922 gfx::Rect child_damage_rect; |
| 924 gfx::Rect root_damage_rect; | 923 gfx::Rect root_damage_rect; |
| 925 | 924 |
| 926 // CASE 1: If a descendant surface disappears, its entire old area becomes | 925 // CASE 1: If a descendant surface disappears, its entire old area becomes |
| 927 // exposed. | 926 // exposed. |
| 928 ClearDamageForAllSurfaces(root.get()); | 927 ClearDamageForAllSurfaces(root.get()); |
| 929 child1->SetOpacity(1.f); | 928 child1->SetHasRenderSurface(false); |
| 930 child1->SetForceRenderSurface(false); | |
| 931 EmulateDrawingOneFrame(root.get()); | 929 EmulateDrawingOneFrame(root.get()); |
| 932 | 930 |
| 933 // Sanity check that there is only one surface now. | 931 // Sanity check that there is only one surface now. |
| 934 ASSERT_FALSE(child1->render_surface()); | 932 ASSERT_FALSE(child1->render_surface()); |
| 935 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); | 933 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); |
| 936 | 934 |
| 937 root_damage_rect = | 935 root_damage_rect = |
| 938 root->render_surface()->damage_tracker()->current_damage_rect(); | 936 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 939 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), | 937 EXPECT_EQ(gfx::Rect(290, 290, 16, 18).ToString(), |
| 940 root_damage_rect.ToString()); | 938 root_damage_rect.ToString()); |
| 941 | 939 |
| 942 // CASE 2: If a descendant surface appears, its entire old area becomes | 940 // CASE 2: If a descendant surface appears, its entire old area becomes |
| 943 // exposed. | 941 // exposed. |
| 944 | 942 |
| 945 // Cycle one frame of no change, just to sanity check that the next rect is | 943 // Cycle one frame of no change, just to sanity check that the next rect is |
| 946 // not because of the old damage state. | 944 // not because of the old damage state. |
| 947 ClearDamageForAllSurfaces(root.get()); | 945 ClearDamageForAllSurfaces(root.get()); |
| 948 EmulateDrawingOneFrame(root.get()); | 946 EmulateDrawingOneFrame(root.get()); |
| 949 root_damage_rect = | 947 root_damage_rect = |
| 950 root->render_surface()->damage_tracker()->current_damage_rect(); | 948 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 951 EXPECT_TRUE(root_damage_rect.IsEmpty()); | 949 EXPECT_TRUE(root_damage_rect.IsEmpty()); |
| 952 | 950 |
| 953 // Then change the tree so that the render surface is added back. | 951 // Then change the tree so that the render surface is added back. |
| 954 ClearDamageForAllSurfaces(root.get()); | 952 ClearDamageForAllSurfaces(root.get()); |
| 955 child1->SetOpacity(0.5f); | 953 child1->SetHasRenderSurface(true); |
| 956 child1->SetForceRenderSurface(true); | 954 |
| 957 EmulateDrawingOneFrame(root.get()); | 955 EmulateDrawingOneFrame(root.get()); |
| 958 | 956 |
| 959 // Sanity check that there is a new surface now. | 957 // Sanity check that there is a new surface now. |
| 960 ASSERT_TRUE(child1->render_surface()); | 958 ASSERT_TRUE(child1->render_surface()); |
| 961 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); | 959 EXPECT_EQ(3u, root->render_surface()->layer_list().size()); |
| 962 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); | 960 EXPECT_EQ(2u, child1->render_surface()->layer_list().size()); |
| 963 | 961 |
| 964 child_damage_rect = | 962 child_damage_rect = |
| 965 child1->render_surface()->damage_tracker()->current_damage_rect(); | 963 child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 966 root_damage_rect = | 964 root_damage_rect = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 // | 1047 // |
| 1050 ClearDamageForAllSurfaces(root.get()); | 1048 ClearDamageForAllSurfaces(root.get()); |
| 1051 { | 1049 { |
| 1052 scoped_ptr<LayerImpl> grand_child1_replica = | 1050 scoped_ptr<LayerImpl> grand_child1_replica = |
| 1053 LayerImpl::Create(host_impl_.active_tree(), 7); | 1051 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1054 grand_child1_replica->SetPosition(gfx::PointF()); | 1052 grand_child1_replica->SetPosition(gfx::PointF()); |
| 1055 gfx::Transform reflection; | 1053 gfx::Transform reflection; |
| 1056 reflection.Scale3d(-1.0, 1.0, 1.0); | 1054 reflection.Scale3d(-1.0, 1.0, 1.0); |
| 1057 grand_child1_replica->SetTransform(reflection); | 1055 grand_child1_replica->SetTransform(reflection); |
| 1058 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); | 1056 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); |
| 1057 grand_child1->SetHasRenderSurface(true); |
| 1059 } | 1058 } |
| 1060 EmulateDrawingOneFrame(root.get()); | 1059 EmulateDrawingOneFrame(root.get()); |
| 1061 | 1060 |
| 1062 gfx::Rect grand_child_damage_rect = | 1061 gfx::Rect grand_child_damage_rect = |
| 1063 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); | 1062 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 1064 gfx::Rect child_damage_rect = | 1063 gfx::Rect child_damage_rect = |
| 1065 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1064 child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 1066 gfx::Rect root_damage_rect = | 1065 gfx::Rect root_damage_rect = |
| 1067 root->render_surface()->damage_tracker()->current_damage_rect(); | 1066 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1068 | 1067 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1099 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); | 1098 EXPECT_EQ(gfx::Rect(6, 8).ToString(), grand_child_damage_rect.ToString()); |
| 1100 EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(), | 1099 EXPECT_EQ(gfx::Rect(189, 200, 17, 13).ToString(), |
| 1101 child_damage_rect.ToString()); | 1100 child_damage_rect.ToString()); |
| 1102 EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(), | 1101 EXPECT_EQ(gfx::Rect(289, 300, 17, 13).ToString(), |
| 1103 root_damage_rect.ToString()); | 1102 root_damage_rect.ToString()); |
| 1104 | 1103 |
| 1105 // CASE 3: removing the reflection should cause the entire region including | 1104 // CASE 3: removing the reflection should cause the entire region including |
| 1106 // reflection to damage the target surface. | 1105 // reflection to damage the target surface. |
| 1107 ClearDamageForAllSurfaces(root.get()); | 1106 ClearDamageForAllSurfaces(root.get()); |
| 1108 grand_child1->SetReplicaLayer(scoped_ptr<LayerImpl>()); | 1107 grand_child1->SetReplicaLayer(scoped_ptr<LayerImpl>()); |
| 1108 grand_child1->SetHasRenderSurface(false); |
| 1109 |
| 1109 EmulateDrawingOneFrame(root.get()); | 1110 EmulateDrawingOneFrame(root.get()); |
| 1110 ASSERT_EQ(old_content_rect.width(), | 1111 ASSERT_EQ(old_content_rect.width(), |
| 1111 child1->render_surface()->content_rect().width()); | 1112 child1->render_surface()->content_rect().width()); |
| 1112 ASSERT_EQ(old_content_rect.height(), | 1113 ASSERT_EQ(old_content_rect.height(), |
| 1113 child1->render_surface()->content_rect().height()); | 1114 child1->render_surface()->content_rect().height()); |
| 1114 | 1115 |
| 1115 EXPECT_FALSE(grand_child1->render_surface()); | 1116 EXPECT_FALSE(grand_child1->render_surface()); |
| 1116 child_damage_rect = | 1117 child_damage_rect = |
| 1117 child1->render_surface()->damage_tracker()->current_damage_rect(); | 1118 child1->render_surface()->damage_tracker()->current_damage_rect(); |
| 1118 root_damage_rect = | 1119 root_damage_rect = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1133 ClearDamageForAllSurfaces(root.get()); | 1134 ClearDamageForAllSurfaces(root.get()); |
| 1134 | 1135 |
| 1135 // Set up the mask layer. | 1136 // Set up the mask layer. |
| 1136 { | 1137 { |
| 1137 scoped_ptr<LayerImpl> mask_layer = | 1138 scoped_ptr<LayerImpl> mask_layer = |
| 1138 LayerImpl::Create(host_impl_.active_tree(), 3); | 1139 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 1139 mask_layer->SetPosition(child->position()); | 1140 mask_layer->SetPosition(child->position()); |
| 1140 mask_layer->SetBounds(child->bounds()); | 1141 mask_layer->SetBounds(child->bounds()); |
| 1141 mask_layer->SetContentBounds(child->bounds()); | 1142 mask_layer->SetContentBounds(child->bounds()); |
| 1142 child->SetMaskLayer(mask_layer.Pass()); | 1143 child->SetMaskLayer(mask_layer.Pass()); |
| 1144 child->SetHasRenderSurface(true); |
| 1143 } | 1145 } |
| 1144 LayerImpl* mask_layer = child->mask_layer(); | 1146 LayerImpl* mask_layer = child->mask_layer(); |
| 1145 | 1147 |
| 1146 // Add opacity and a grand_child so that the render surface persists even | 1148 // Add opacity and a grand_child so that the render surface persists even |
| 1147 // after we remove the mask. | 1149 // after we remove the mask. |
| 1148 child->SetOpacity(0.5f); | |
| 1149 { | 1150 { |
| 1150 scoped_ptr<LayerImpl> grand_child = | 1151 scoped_ptr<LayerImpl> grand_child = |
| 1151 LayerImpl::Create(host_impl_.active_tree(), 4); | 1152 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 1152 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); | 1153 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 1153 grand_child->SetBounds(gfx::Size(2, 2)); | 1154 grand_child->SetBounds(gfx::Size(2, 2)); |
| 1154 grand_child->SetContentBounds(gfx::Size(2, 2)); | 1155 grand_child->SetContentBounds(gfx::Size(2, 2)); |
| 1155 grand_child->SetDrawsContent(true); | 1156 grand_child->SetDrawsContent(true); |
| 1156 child->AddChild(grand_child.Pass()); | 1157 child->AddChild(grand_child.Pass()); |
| 1157 } | 1158 } |
| 1158 EmulateDrawingOneFrame(root.get()); | 1159 EmulateDrawingOneFrame(root.get()); |
| 1159 | 1160 |
| 1160 // Sanity check that a new surface was created for the child. | |
| 1161 ASSERT_TRUE(child->render_surface()); | |
| 1162 | |
| 1163 // CASE 1: the update_rect on a mask layer should damage the entire target | 1161 // CASE 1: the update_rect on a mask layer should damage the entire target |
| 1164 // surface. | 1162 // surface. |
| 1165 ClearDamageForAllSurfaces(root.get()); | 1163 ClearDamageForAllSurfaces(root.get()); |
| 1166 mask_layer->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); | 1164 mask_layer->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); |
| 1167 EmulateDrawingOneFrame(root.get()); | 1165 EmulateDrawingOneFrame(root.get()); |
| 1168 gfx::Rect child_damage_rect = | 1166 gfx::Rect child_damage_rect = |
| 1169 child->render_surface()->damage_tracker()->current_damage_rect(); | 1167 child->render_surface()->damage_tracker()->current_damage_rect(); |
| 1170 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); | 1168 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); |
| 1171 | 1169 |
| 1172 // CASE 2: a property change on the mask layer should damage the entire | 1170 // CASE 2: a property change on the mask layer should damage the entire |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 | 1224 |
| 1227 // Create a reflection about the left edge of grand_child1. | 1225 // Create a reflection about the left edge of grand_child1. |
| 1228 { | 1226 { |
| 1229 scoped_ptr<LayerImpl> grand_child1_replica = | 1227 scoped_ptr<LayerImpl> grand_child1_replica = |
| 1230 LayerImpl::Create(host_impl_.active_tree(), 6); | 1228 LayerImpl::Create(host_impl_.active_tree(), 6); |
| 1231 grand_child1_replica->SetPosition(gfx::PointF()); | 1229 grand_child1_replica->SetPosition(gfx::PointF()); |
| 1232 gfx::Transform reflection; | 1230 gfx::Transform reflection; |
| 1233 reflection.Scale3d(-1.0, 1.0, 1.0); | 1231 reflection.Scale3d(-1.0, 1.0, 1.0); |
| 1234 grand_child1_replica->SetTransform(reflection); | 1232 grand_child1_replica->SetTransform(reflection); |
| 1235 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); | 1233 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); |
| 1234 grand_child1->SetHasRenderSurface(true); |
| 1236 } | 1235 } |
| 1237 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1236 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
| 1238 | 1237 |
| 1239 // Set up the mask layer on the replica layer | 1238 // Set up the mask layer on the replica layer |
| 1240 { | 1239 { |
| 1241 scoped_ptr<LayerImpl> replica_mask_layer = | 1240 scoped_ptr<LayerImpl> replica_mask_layer = |
| 1242 LayerImpl::Create(host_impl_.active_tree(), 7); | 1241 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1243 replica_mask_layer->SetPosition(gfx::PointF()); | 1242 replica_mask_layer->SetPosition(gfx::PointF()); |
| 1244 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1243 replica_mask_layer->SetBounds(grand_child1->bounds()); |
| 1245 replica_mask_layer->SetContentBounds(grand_child1->bounds()); | 1244 replica_mask_layer->SetContentBounds(grand_child1->bounds()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 LayerImpl::Create(host_impl_.active_tree(), 6); | 1302 LayerImpl::Create(host_impl_.active_tree(), 6); |
| 1304 grand_child1_replica->SetPosition(gfx::PointF()); | 1303 grand_child1_replica->SetPosition(gfx::PointF()); |
| 1305 | 1304 |
| 1306 // This is the anchor being tested. | 1305 // This is the anchor being tested. |
| 1307 grand_child1_replica->SetTransformOrigin( | 1306 grand_child1_replica->SetTransformOrigin( |
| 1308 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); | 1307 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); |
| 1309 gfx::Transform reflection; | 1308 gfx::Transform reflection; |
| 1310 reflection.Scale3d(-1.0, 1.0, 1.0); | 1309 reflection.Scale3d(-1.0, 1.0, 1.0); |
| 1311 grand_child1_replica->SetTransform(reflection); | 1310 grand_child1_replica->SetTransform(reflection); |
| 1312 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); | 1311 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); |
| 1312 grand_child1->SetHasRenderSurface(true); |
| 1313 } | 1313 } |
| 1314 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); | 1314 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); |
| 1315 | 1315 |
| 1316 // Set up the mask layer on the replica layer | 1316 // Set up the mask layer on the replica layer |
| 1317 { | 1317 { |
| 1318 scoped_ptr<LayerImpl> replica_mask_layer = | 1318 scoped_ptr<LayerImpl> replica_mask_layer = |
| 1319 LayerImpl::Create(host_impl_.active_tree(), 7); | 1319 LayerImpl::Create(host_impl_.active_tree(), 7); |
| 1320 replica_mask_layer->SetPosition(gfx::PointF()); | 1320 replica_mask_layer->SetPosition(gfx::PointF()); |
| 1321 // Note: this is not the transform origin being tested. | 1321 // Note: this is not the transform origin being tested. |
| 1322 replica_mask_layer->SetBounds(grand_child1->bounds()); | 1322 replica_mask_layer->SetBounds(grand_child1->bounds()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 root_damage_rect = | 1370 root_damage_rect = |
| 1371 root->render_surface()->damage_tracker()->current_damage_rect(); | 1371 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1372 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); | 1372 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { | 1375 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { |
| 1376 // Though it should never happen, its a good idea to verify that the damage | 1376 // Though it should never happen, its a good idea to verify that the damage |
| 1377 // tracker does not crash when it receives an empty layer_list. | 1377 // tracker does not crash when it receives an empty layer_list. |
| 1378 | 1378 |
| 1379 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); | 1379 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); |
| 1380 root->CreateRenderSurface(); | 1380 root->SetHasRenderSurface(true); |
| 1381 root->draw_properties().render_target = root.get(); |
| 1381 | 1382 |
| 1382 ASSERT_TRUE(root == root->render_target()); | 1383 ASSERT_TRUE(root == root->render_target()); |
| 1383 RenderSurfaceImpl* target_surface = root->render_surface(); | 1384 RenderSurfaceImpl* target_surface = root->render_surface(); |
| 1384 | 1385 |
| 1385 LayerImplList empty_list; | 1386 LayerImplList empty_list; |
| 1386 target_surface->damage_tracker()->UpdateDamageTrackingState( | 1387 target_surface->damage_tracker()->UpdateDamageTrackingState( |
| 1387 empty_list, | 1388 empty_list, |
| 1388 target_surface->OwningLayerId(), | 1389 target_surface->OwningLayerId(), |
| 1389 false, | 1390 false, |
| 1390 gfx::Rect(), | 1391 gfx::Rect(), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 gfx::Rect root_damage_rect = | 1463 gfx::Rect root_damage_rect = |
| 1463 root->render_surface()->damage_tracker()->current_damage_rect(); | 1464 root->render_surface()->damage_tracker()->current_damage_rect(); |
| 1464 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1465 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
| 1465 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1466 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
| 1466 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1467 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
| 1467 } | 1468 } |
| 1468 } | 1469 } |
| 1469 | 1470 |
| 1470 } // namespace | 1471 } // namespace |
| 1471 } // namespace cc | 1472 } // namespace cc |
| OLD | NEW |