Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: cc/trees/damage_tracker_unittest.cc

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/tiled_layer_test_common.cc ('k') | cc/trees/layer_tree_host_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Allow us to set damage on child too. 533 // Allow us to set damage on child too.
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());
543 child->SetHasRenderSurface(true);
545 child->SetFilters(filters); 544 child->SetFilters(filters);
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
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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(nullptr); 1107 grand_child1->SetReplicaLayer(nullptr);
1108 grand_child1->SetHasRenderSurface(false);
1109 EmulateDrawingOneFrame(root.get()); 1109 EmulateDrawingOneFrame(root.get());
1110 ASSERT_EQ(old_content_rect.width(), 1110 ASSERT_EQ(old_content_rect.width(),
1111 child1->render_surface()->content_rect().width()); 1111 child1->render_surface()->content_rect().width());
1112 ASSERT_EQ(old_content_rect.height(), 1112 ASSERT_EQ(old_content_rect.height(),
1113 child1->render_surface()->content_rect().height()); 1113 child1->render_surface()->content_rect().height());
1114 1114
1115 EXPECT_FALSE(grand_child1->render_surface()); 1115 EXPECT_FALSE(grand_child1->render_surface());
1116 child_damage_rect = 1116 child_damage_rect =
1117 child1->render_surface()->damage_tracker()->current_damage_rect(); 1117 child1->render_surface()->damage_tracker()->current_damage_rect();
1118 root_damage_rect = 1118 root_damage_rect =
(...skipping 14 matching lines...) Expand all
1133 ClearDamageForAllSurfaces(root.get()); 1133 ClearDamageForAllSurfaces(root.get());
1134 1134
1135 // Set up the mask layer. 1135 // Set up the mask layer.
1136 { 1136 {
1137 scoped_ptr<LayerImpl> mask_layer = 1137 scoped_ptr<LayerImpl> mask_layer =
1138 LayerImpl::Create(host_impl_.active_tree(), 3); 1138 LayerImpl::Create(host_impl_.active_tree(), 3);
1139 mask_layer->SetPosition(child->position()); 1139 mask_layer->SetPosition(child->position());
1140 mask_layer->SetBounds(child->bounds()); 1140 mask_layer->SetBounds(child->bounds());
1141 mask_layer->SetContentBounds(child->bounds()); 1141 mask_layer->SetContentBounds(child->bounds());
1142 child->SetMaskLayer(mask_layer.Pass()); 1142 child->SetMaskLayer(mask_layer.Pass());
1143 child->SetHasRenderSurface(true);
1143 } 1144 }
1144 LayerImpl* mask_layer = child->mask_layer(); 1145 LayerImpl* mask_layer = child->mask_layer();
1145 1146
1146 // Add opacity and a grand_child so that the render surface persists even 1147 // Add opacity and a grand_child so that the render surface persists even
1147 // after we remove the mask. 1148 // after we remove the mask.
1148 child->SetOpacity(0.5f);
1149 { 1149 {
1150 scoped_ptr<LayerImpl> grand_child = 1150 scoped_ptr<LayerImpl> grand_child =
1151 LayerImpl::Create(host_impl_.active_tree(), 4); 1151 LayerImpl::Create(host_impl_.active_tree(), 4);
1152 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); 1152 grand_child->SetPosition(gfx::PointF(2.f, 2.f));
1153 grand_child->SetBounds(gfx::Size(2, 2)); 1153 grand_child->SetBounds(gfx::Size(2, 2));
1154 grand_child->SetContentBounds(gfx::Size(2, 2)); 1154 grand_child->SetContentBounds(gfx::Size(2, 2));
1155 grand_child->SetDrawsContent(true); 1155 grand_child->SetDrawsContent(true);
1156 child->AddChild(grand_child.Pass()); 1156 child->AddChild(grand_child.Pass());
1157 } 1157 }
1158 EmulateDrawingOneFrame(root.get()); 1158 EmulateDrawingOneFrame(root.get());
1159 1159
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 1160 // CASE 1: the update_rect on a mask layer should damage the entire target
1164 // surface. 1161 // surface.
1165 ClearDamageForAllSurfaces(root.get()); 1162 ClearDamageForAllSurfaces(root.get());
1166 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); 1163 mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4));
1167 EmulateDrawingOneFrame(root.get()); 1164 EmulateDrawingOneFrame(root.get());
1168 gfx::Rect child_damage_rect = 1165 gfx::Rect child_damage_rect =
1169 child->render_surface()->damage_tracker()->current_damage_rect(); 1166 child->render_surface()->damage_tracker()->current_damage_rect();
1170 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString()); 1167 EXPECT_EQ(gfx::Rect(30, 30).ToString(), child_damage_rect.ToString());
1171 1168
1172 // CASE 2: a property change on the mask layer should damage the entire 1169 // 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
1226 1223
1227 // Create a reflection about the left edge of grand_child1. 1224 // Create a reflection about the left edge of grand_child1.
1228 { 1225 {
1229 scoped_ptr<LayerImpl> grand_child1_replica = 1226 scoped_ptr<LayerImpl> grand_child1_replica =
1230 LayerImpl::Create(host_impl_.active_tree(), 6); 1227 LayerImpl::Create(host_impl_.active_tree(), 6);
1231 grand_child1_replica->SetPosition(gfx::PointF()); 1228 grand_child1_replica->SetPosition(gfx::PointF());
1232 gfx::Transform reflection; 1229 gfx::Transform reflection;
1233 reflection.Scale3d(-1.0, 1.0, 1.0); 1230 reflection.Scale3d(-1.0, 1.0, 1.0);
1234 grand_child1_replica->SetTransform(reflection); 1231 grand_child1_replica->SetTransform(reflection);
1235 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); 1232 grand_child1->SetReplicaLayer(grand_child1_replica.Pass());
1233 grand_child1->SetHasRenderSurface(true);
1236 } 1234 }
1237 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); 1235 LayerImpl* grand_child1_replica = grand_child1->replica_layer();
1238 1236
1239 // Set up the mask layer on the replica layer 1237 // Set up the mask layer on the replica layer
1240 { 1238 {
1241 scoped_ptr<LayerImpl> replica_mask_layer = 1239 scoped_ptr<LayerImpl> replica_mask_layer =
1242 LayerImpl::Create(host_impl_.active_tree(), 7); 1240 LayerImpl::Create(host_impl_.active_tree(), 7);
1243 replica_mask_layer->SetPosition(gfx::PointF()); 1241 replica_mask_layer->SetPosition(gfx::PointF());
1244 replica_mask_layer->SetBounds(grand_child1->bounds()); 1242 replica_mask_layer->SetBounds(grand_child1->bounds());
1245 replica_mask_layer->SetContentBounds(grand_child1->bounds()); 1243 replica_mask_layer->SetContentBounds(grand_child1->bounds());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 LayerImpl::Create(host_impl_.active_tree(), 6); 1301 LayerImpl::Create(host_impl_.active_tree(), 6);
1304 grand_child1_replica->SetPosition(gfx::PointF()); 1302 grand_child1_replica->SetPosition(gfx::PointF());
1305 1303
1306 // This is the anchor being tested. 1304 // This is the anchor being tested.
1307 grand_child1_replica->SetTransformOrigin( 1305 grand_child1_replica->SetTransformOrigin(
1308 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f)); 1306 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f));
1309 gfx::Transform reflection; 1307 gfx::Transform reflection;
1310 reflection.Scale3d(-1.0, 1.0, 1.0); 1308 reflection.Scale3d(-1.0, 1.0, 1.0);
1311 grand_child1_replica->SetTransform(reflection); 1309 grand_child1_replica->SetTransform(reflection);
1312 grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); 1310 grand_child1->SetReplicaLayer(grand_child1_replica.Pass());
1311 grand_child1->SetHasRenderSurface(true);
1313 } 1312 }
1314 LayerImpl* grand_child1_replica = grand_child1->replica_layer(); 1313 LayerImpl* grand_child1_replica = grand_child1->replica_layer();
1315 1314
1316 // Set up the mask layer on the replica layer 1315 // Set up the mask layer on the replica layer
1317 { 1316 {
1318 scoped_ptr<LayerImpl> replica_mask_layer = 1317 scoped_ptr<LayerImpl> replica_mask_layer =
1319 LayerImpl::Create(host_impl_.active_tree(), 7); 1318 LayerImpl::Create(host_impl_.active_tree(), 7);
1320 replica_mask_layer->SetPosition(gfx::PointF()); 1319 replica_mask_layer->SetPosition(gfx::PointF());
1321 // Note: this is not the transform origin being tested. 1320 // Note: this is not the transform origin being tested.
1322 replica_mask_layer->SetBounds(grand_child1->bounds()); 1321 replica_mask_layer->SetBounds(grand_child1->bounds());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 root_damage_rect = 1369 root_damage_rect =
1371 root->render_surface()->damage_tracker()->current_damage_rect(); 1370 root->render_surface()->damage_tracker()->current_damage_rect();
1372 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString()); 1371 EXPECT_EQ(gfx::Rect(30, 31, 14, 15).ToString(), root_damage_rect.ToString());
1373 } 1372 }
1374 1373
1375 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { 1374 TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) {
1376 // Though it should never happen, its a good idea to verify that the damage 1375 // 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. 1376 // tracker does not crash when it receives an empty layer_list.
1378 1377
1379 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); 1378 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1);
1380 root->CreateRenderSurface(); 1379 root->SetHasRenderSurface(true);
1380 root->draw_properties().render_target = root.get();
1381 1381
1382 ASSERT_TRUE(root == root->render_target()); 1382 ASSERT_TRUE(root == root->render_target());
1383 RenderSurfaceImpl* target_surface = root->render_surface(); 1383 RenderSurfaceImpl* target_surface = root->render_surface();
1384 1384
1385 LayerImplList empty_list; 1385 LayerImplList empty_list;
1386 target_surface->damage_tracker()->UpdateDamageTrackingState( 1386 target_surface->damage_tracker()->UpdateDamageTrackingState(
1387 empty_list, 1387 empty_list,
1388 target_surface->OwningLayerId(), 1388 target_surface->OwningLayerId(),
1389 false, 1389 false,
1390 gfx::Rect(), 1390 gfx::Rect(),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 gfx::Rect root_damage_rect = 1462 gfx::Rect root_damage_rect =
1463 root->render_surface()->damage_tracker()->current_damage_rect(); 1463 root->render_surface()->damage_tracker()->current_damage_rect();
1464 gfx::Rect damage_we_care_about = gfx::Rect(i, i); 1464 gfx::Rect damage_we_care_about = gfx::Rect(i, i);
1465 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); 1465 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right());
1466 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); 1466 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom());
1467 } 1467 }
1468 } 1468 }
1469 1469
1470 } // namespace 1470 } // namespace
1471 } // namespace cc 1471 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/tiled_layer_test_common.cc ('k') | cc/trees/layer_tree_host_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698