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

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

Issue 2857343002: Delete LayerImpl::GetRenderSurface. (Closed)
Patch Set: none Created 3 years, 7 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/trees/layer_tree_host_unittest_video.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/layers/heads_up_display_layer_impl.h" 9 #include "cc/layers/heads_up_display_layer_impl.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 gfx::Size bounds(100, 100); 124 gfx::Size bounds(100, 100);
125 LayerImpl* root = root_layer(); 125 LayerImpl* root = root_layer();
126 root->SetBounds(bounds); 126 root->SetBounds(bounds);
127 root->SetDrawsContent(true); 127 root->SetDrawsContent(true);
128 128
129 host_impl().SetViewportSize(root->bounds()); 129 host_impl().SetViewportSize(root->bounds());
130 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 130 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
131 131
132 // Sanity check the scenario we just created. 132 // Sanity check the scenario we just created.
133 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 133 ASSERT_EQ(1u, GetRenderSurfaceList().size());
134 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 134 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
135 135
136 // Hit testing for a point outside the layer should return a null pointer. 136 // Hit testing for a point outside the layer should return a null pointer.
137 gfx::PointF test_point(101.f, 101.f); 137 gfx::PointF test_point(101.f, 101.f);
138 LayerImpl* result_layer = 138 LayerImpl* result_layer =
139 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 139 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
140 EXPECT_FALSE(result_layer); 140 EXPECT_FALSE(result_layer);
141 141
142 test_point = gfx::PointF(-1.f, -1.f); 142 test_point = gfx::PointF(-1.f, -1.f);
143 result_layer = 143 result_layer =
144 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 144 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 hud->SetBounds(gfx::Size(200, 200)); 193 hud->SetBounds(gfx::Size(200, 200));
194 hud->SetDrawsContent(true); 194 hud->SetDrawsContent(true);
195 195
196 host_impl().SetViewportSize(hud->bounds()); 196 host_impl().SetViewportSize(hud->bounds());
197 host_impl().active_tree()->set_hud_layer(hud.get()); 197 host_impl().active_tree()->set_hud_layer(hud.get());
198 root->test_properties()->AddChild(std::move(hud)); 198 root->test_properties()->AddChild(std::move(hud));
199 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 199 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
200 200
201 // Sanity check the scenario we just created. 201 // Sanity check the scenario we just created.
202 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 202 ASSERT_EQ(1u, GetRenderSurfaceList().size());
203 ASSERT_EQ(2, root_layer()->GetRenderSurface()->num_contributors()); 203 ASSERT_EQ(2, GetRenderSurface(root_layer())->num_contributors());
204 204
205 // Hit testing for a point inside HUD, but outside root should return null 205 // Hit testing for a point inside HUD, but outside root should return null
206 gfx::PointF test_point(101.f, 101.f); 206 gfx::PointF test_point(101.f, 101.f);
207 LayerImpl* result_layer = 207 LayerImpl* result_layer =
208 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 208 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
209 EXPECT_FALSE(result_layer); 209 EXPECT_FALSE(result_layer);
210 210
211 test_point = gfx::PointF(-1.f, -1.f); 211 test_point = gfx::PointF(-1.f, -1.f);
212 result_layer = 212 result_layer =
213 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 213 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
(...skipping 24 matching lines...) Expand all
238 238
239 LayerImpl* root = root_layer(); 239 LayerImpl* root = root_layer();
240 root->test_properties()->transform = uninvertible_transform; 240 root->test_properties()->transform = uninvertible_transform;
241 root->SetBounds(gfx::Size(100, 100)); 241 root->SetBounds(gfx::Size(100, 100));
242 root->SetDrawsContent(true); 242 root->SetDrawsContent(true);
243 243
244 host_impl().SetViewportSize(root->bounds()); 244 host_impl().SetViewportSize(root->bounds());
245 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 245 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
246 // Sanity check the scenario we just created. 246 // Sanity check the scenario we just created.
247 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 247 ASSERT_EQ(1u, GetRenderSurfaceList().size());
248 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 248 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
249 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); 249 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible());
250 250
251 // Hit testing any point should not hit the layer. If the invertible matrix is 251 // Hit testing any point should not hit the layer. If the invertible matrix is
252 // accidentally ignored and treated like an identity, then the hit testing 252 // accidentally ignored and treated like an identity, then the hit testing
253 // will incorrectly hit the layer when it shouldn't. 253 // will incorrectly hit the layer when it shouldn't.
254 gfx::PointF test_point(1.f, 1.f); 254 gfx::PointF test_point(1.f, 1.f);
255 LayerImpl* result_layer = 255 LayerImpl* result_layer =
256 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 256 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
257 EXPECT_FALSE(result_layer); 257 EXPECT_FALSE(result_layer);
258 258
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 LayerImpl* root = root_layer(); 293 LayerImpl* root = root_layer();
294 root->SetPosition(gfx::PointF(50.f, 50.f)); 294 root->SetPosition(gfx::PointF(50.f, 50.f));
295 root->SetBounds(gfx::Size(100, 100)); 295 root->SetBounds(gfx::Size(100, 100));
296 root->SetDrawsContent(true); 296 root->SetDrawsContent(true);
297 297
298 host_impl().SetViewportSize(root->bounds()); 298 host_impl().SetViewportSize(root->bounds());
299 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 299 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
300 300
301 // Sanity check the scenario we just created. 301 // Sanity check the scenario we just created.
302 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 302 ASSERT_EQ(1u, GetRenderSurfaceList().size());
303 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 303 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
304 304
305 // Hit testing for a point outside the layer should return a null pointer. 305 // Hit testing for a point outside the layer should return a null pointer.
306 gfx::PointF test_point(49.f, 49.f); 306 gfx::PointF test_point(49.f, 49.f);
307 LayerImpl* result_layer = 307 LayerImpl* result_layer =
308 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 308 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
309 EXPECT_FALSE(result_layer); 309 EXPECT_FALSE(result_layer);
310 310
311 // Even though the layer exists at (101, 101), it should not be visible there 311 // Even though the layer exists at (101, 101), it should not be visible there
312 // since the root render surface would clamp it. 312 // since the root render surface would clamp it.
313 test_point = gfx::PointF(101.f, 101.f); 313 test_point = gfx::PointF(101.f, 101.f);
(...skipping 24 matching lines...) Expand all
338 LayerImpl* root = root_layer(); 338 LayerImpl* root = root_layer();
339 root->test_properties()->transform = rotation45_degrees_about_center; 339 root->test_properties()->transform = rotation45_degrees_about_center;
340 root->SetBounds(gfx::Size(100, 100)); 340 root->SetBounds(gfx::Size(100, 100));
341 root->SetDrawsContent(true); 341 root->SetDrawsContent(true);
342 342
343 host_impl().SetViewportSize(root->bounds()); 343 host_impl().SetViewportSize(root->bounds());
344 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 344 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
345 345
346 // Sanity check the scenario we just created. 346 // Sanity check the scenario we just created.
347 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 347 ASSERT_EQ(1u, GetRenderSurfaceList().size());
348 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 348 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
349 349
350 // Hit testing for points outside the layer. 350 // Hit testing for points outside the layer.
351 // These corners would have been inside the un-transformed layer, but they 351 // These corners would have been inside the un-transformed layer, but they
352 // should not hit the correctly transformed layer. 352 // should not hit the correctly transformed layer.
353 gfx::PointF test_point(99.f, 99.f); 353 gfx::PointF test_point(99.f, 99.f);
354 LayerImpl* result_layer = 354 LayerImpl* result_layer =
355 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 355 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
356 EXPECT_FALSE(result_layer); 356 EXPECT_FALSE(result_layer);
357 357
358 test_point = gfx::PointF(1.f, 1.f); 358 test_point = gfx::PointF(1.f, 1.f);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 root->test_properties()->transform = 475 root->test_properties()->transform =
476 (perspective_projection_about_center * translation_by_z); 476 (perspective_projection_about_center * translation_by_z);
477 root->SetBounds(gfx::Size(100, 100)); 477 root->SetBounds(gfx::Size(100, 100));
478 root->SetDrawsContent(true); 478 root->SetDrawsContent(true);
479 479
480 host_impl().SetViewportSize(root->bounds()); 480 host_impl().SetViewportSize(root->bounds());
481 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 481 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
482 482
483 // Sanity check the scenario we just created. 483 // Sanity check the scenario we just created.
484 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 484 ASSERT_EQ(1u, GetRenderSurfaceList().size());
485 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 485 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
486 486
487 // Hit testing for points outside the layer. 487 // Hit testing for points outside the layer.
488 // These corners would have been inside the un-transformed layer, but they 488 // These corners would have been inside the un-transformed layer, but they
489 // should not hit the correctly transformed layer. 489 // should not hit the correctly transformed layer.
490 gfx::PointF test_point(24.f, 24.f); 490 gfx::PointF test_point(24.f, 24.f);
491 LayerImpl* result_layer = 491 LayerImpl* result_layer =
492 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 492 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
493 EXPECT_FALSE(result_layer); 493 EXPECT_FALSE(result_layer);
494 494
495 test_point = gfx::PointF(76.f, 76.f); 495 test_point = gfx::PointF(76.f, 76.f);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 child->SetDrawsContent(true); 533 child->SetDrawsContent(true);
534 clipping_layer->test_properties()->AddChild(std::move(child)); 534 clipping_layer->test_properties()->AddChild(std::move(child));
535 root->test_properties()->AddChild(std::move(clipping_layer)); 535 root->test_properties()->AddChild(std::move(clipping_layer));
536 } 536 }
537 537
538 host_impl().SetViewportSize(root->bounds()); 538 host_impl().SetViewportSize(root->bounds());
539 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 539 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
540 540
541 // Sanity check the scenario we just created. 541 // Sanity check the scenario we just created.
542 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 542 ASSERT_EQ(1u, GetRenderSurfaceList().size());
543 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 543 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
544 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456); 544 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456);
545 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); 545 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface());
546 546
547 // Hit testing for a point outside the layer should return a null pointer. 547 // Hit testing for a point outside the layer should return a null pointer.
548 // Despite the child layer being very large, it should be clipped to the root 548 // Despite the child layer being very large, it should be clipped to the root
549 // layer's bounds. 549 // layer's bounds.
550 gfx::PointF test_point(24.f, 24.f); 550 gfx::PointF test_point(24.f, 24.f);
551 LayerImpl* result_layer = 551 LayerImpl* result_layer =
552 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 552 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
553 EXPECT_FALSE(result_layer); 553 EXPECT_FALSE(result_layer);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 child->SetDrawsContent(true); 711 child->SetDrawsContent(true);
712 intermediate_layer->test_properties()->AddChild(std::move(child)); 712 intermediate_layer->test_properties()->AddChild(std::move(child));
713 root->test_properties()->AddChild(std::move(intermediate_layer)); 713 root->test_properties()->AddChild(std::move(intermediate_layer));
714 } 714 }
715 715
716 host_impl().SetViewportSize(root->bounds()); 716 host_impl().SetViewportSize(root->bounds());
717 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 717 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
718 718
719 // Sanity check the scenario we just created. 719 // Sanity check the scenario we just created.
720 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 720 ASSERT_EQ(1u, GetRenderSurfaceList().size());
721 ASSERT_EQ(1, root_layer()->GetRenderSurface()->num_contributors()); 721 ASSERT_EQ(1, GetRenderSurface(root_layer())->num_contributors());
722 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456); 722 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456);
723 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); 723 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface());
724 724
725 // Hit testing for a point outside the layer should return a null pointer. 725 // Hit testing for a point outside the layer should return a null pointer.
726 gfx::PointF test_point(69.f, 69.f); 726 gfx::PointF test_point(69.f, 69.f);
727 LayerImpl* result_layer = 727 LayerImpl* result_layer =
728 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 728 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
729 EXPECT_FALSE(result_layer); 729 EXPECT_FALSE(result_layer);
730 730
731 test_point = gfx::PointF(91.f, 91.f); 731 test_point = gfx::PointF(91.f, 91.f);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 793
794 host_impl().SetViewportSize(root->bounds()); 794 host_impl().SetViewportSize(root->bounds());
795 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 795 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
796 796
797 // Sanity check the scenario we just created. 797 // Sanity check the scenario we just created.
798 ASSERT_TRUE(child1); 798 ASSERT_TRUE(child1);
799 ASSERT_TRUE(child2); 799 ASSERT_TRUE(child2);
800 ASSERT_TRUE(grand_child1); 800 ASSERT_TRUE(grand_child1);
801 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 801 ASSERT_EQ(1u, GetRenderSurfaceList().size());
802 802
803 RenderSurfaceImpl* root_render_surface = root->GetRenderSurface(); 803 RenderSurfaceImpl* root_render_surface = GetRenderSurface(root);
804 ASSERT_EQ(4, root_render_surface->num_contributors()); 804 ASSERT_EQ(4, root_render_surface->num_contributors());
805 EXPECT_TRUE(root_layer()->contributes_to_drawn_render_surface()); 805 EXPECT_TRUE(root_layer()->contributes_to_drawn_render_surface());
806 EXPECT_TRUE(child1->contributes_to_drawn_render_surface()); 806 EXPECT_TRUE(child1->contributes_to_drawn_render_surface());
807 EXPECT_TRUE(child2->contributes_to_drawn_render_surface()); 807 EXPECT_TRUE(child2->contributes_to_drawn_render_surface());
808 EXPECT_TRUE(grand_child1->contributes_to_drawn_render_surface()); 808 EXPECT_TRUE(grand_child1->contributes_to_drawn_render_surface());
809 809
810 // Nothing overlaps the root at (1, 1), so hit testing there should find 810 // Nothing overlaps the root at (1, 1), so hit testing there should find
811 // the root layer. 811 // the root layer.
812 gfx::PointF test_point = gfx::PointF(1.f, 1.f); 812 gfx::PointF test_point = gfx::PointF(1.f, 1.f);
813 LayerImpl* result_layer = 813 LayerImpl* result_layer =
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 LayerImpl* child2 = root->test_properties()->children[1]; 1140 LayerImpl* child2 = root->test_properties()->children[1];
1141 LayerImpl* grand_child1 = child1->test_properties()->children[0]; 1141 LayerImpl* grand_child1 = child1->test_properties()->children[0];
1142 1142
1143 host_impl().SetViewportSize(root->bounds()); 1143 host_impl().SetViewportSize(root->bounds());
1144 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1144 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1145 1145
1146 // Sanity check the scenario we just created. 1146 // Sanity check the scenario we just created.
1147 ASSERT_TRUE(child1); 1147 ASSERT_TRUE(child1);
1148 ASSERT_TRUE(child2); 1148 ASSERT_TRUE(child2);
1149 ASSERT_TRUE(grand_child1); 1149 ASSERT_TRUE(grand_child1);
1150 ASSERT_TRUE(child1->GetRenderSurface()); 1150 ASSERT_TRUE(GetRenderSurface(child1));
1151 ASSERT_TRUE(child2->GetRenderSurface()); 1151 ASSERT_TRUE(GetRenderSurface(child2));
1152 ASSERT_TRUE(grand_child1->GetRenderSurface()); 1152 ASSERT_TRUE(GetRenderSurface(grand_child1));
1153 ASSERT_EQ(4u, GetRenderSurfaceList().size()); 1153 ASSERT_EQ(4u, GetRenderSurfaceList().size());
1154 // The root surface has the root layer, and child1's and child2's render 1154 // The root surface has the root layer, and child1's and child2's render
1155 // surfaces. 1155 // surfaces.
1156 ASSERT_EQ(3, root->GetRenderSurface()->num_contributors()); 1156 ASSERT_EQ(3, GetRenderSurface(root)->num_contributors());
1157 // The child1 surface has the child1 layer and grand_child1's render surface. 1157 // The child1 surface has the child1 layer and grand_child1's render surface.
1158 ASSERT_EQ(2, child1->GetRenderSurface()->num_contributors()); 1158 ASSERT_EQ(2, GetRenderSurface(child1)->num_contributors());
1159 ASSERT_EQ(1, child2->GetRenderSurface()->num_contributors()); 1159 ASSERT_EQ(1, GetRenderSurface(child2)->num_contributors());
1160 ASSERT_EQ(1, grand_child1->GetRenderSurface()->num_contributors()); 1160 ASSERT_EQ(1, GetRenderSurface(grand_child1)->num_contributors());
1161 EXPECT_TRUE(root_layer()->contributes_to_drawn_render_surface()); 1161 EXPECT_TRUE(root_layer()->contributes_to_drawn_render_surface());
1162 EXPECT_TRUE(child1->contributes_to_drawn_render_surface()); 1162 EXPECT_TRUE(child1->contributes_to_drawn_render_surface());
1163 EXPECT_TRUE(grand_child1->contributes_to_drawn_render_surface()); 1163 EXPECT_TRUE(grand_child1->contributes_to_drawn_render_surface());
1164 EXPECT_TRUE(child2->contributes_to_drawn_render_surface()); 1164 EXPECT_TRUE(child2->contributes_to_drawn_render_surface());
1165 1165
1166 // Nothing overlaps the root at (1, 1), so hit testing there should find 1166 // Nothing overlaps the root at (1, 1), so hit testing there should find
1167 // the root layer. 1167 // the root layer.
1168 gfx::PointF test_point(1.f, 1.f); 1168 gfx::PointF test_point(1.f, 1.f);
1169 LayerImpl* result_layer = 1169 LayerImpl* result_layer =
1170 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); 1170 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1216
1217 LayerImpl* root = root_layer(); 1217 LayerImpl* root = root_layer();
1218 root->SetBounds(gfx::Size(100, 100)); 1218 root->SetBounds(gfx::Size(100, 100));
1219 root->SetDrawsContent(true); 1219 root->SetDrawsContent(true);
1220 1220
1221 host_impl().SetViewportSize(root->bounds()); 1221 host_impl().SetViewportSize(root->bounds());
1222 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1222 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1223 1223
1224 // Sanity check the scenario we just created. 1224 // Sanity check the scenario we just created.
1225 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1225 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1226 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); 1226 ASSERT_EQ(1, GetRenderSurface(root)->num_contributors());
1227 1227
1228 // Hit checking for any point should return a null pointer for a layer without 1228 // Hit checking for any point should return a null pointer for a layer without
1229 // any touch event handler regions. 1229 // any touch event handler regions.
1230 gfx::PointF test_point(11.f, 11.f); 1230 gfx::PointF test_point(11.f, 11.f);
1231 LayerImpl* result_layer = 1231 LayerImpl* result_layer =
1232 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1232 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1233 test_point); 1233 test_point);
1234 EXPECT_FALSE(result_layer); 1234 EXPECT_FALSE(result_layer);
1235 1235
1236 root->SetTouchEventHandlerRegion(touch_handler_region); 1236 root->SetTouchEventHandlerRegion(touch_handler_region);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 root->test_properties()->transform = uninvertible_transform; 1293 root->test_properties()->transform = uninvertible_transform;
1294 root->SetBounds(gfx::Size(100, 100)); 1294 root->SetBounds(gfx::Size(100, 100));
1295 root->SetDrawsContent(true); 1295 root->SetDrawsContent(true);
1296 root->SetTouchEventHandlerRegion(touch_handler_region); 1296 root->SetTouchEventHandlerRegion(touch_handler_region);
1297 1297
1298 host_impl().SetViewportSize(root->bounds()); 1298 host_impl().SetViewportSize(root->bounds());
1299 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1299 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1300 1300
1301 // Sanity check the scenario we just created. 1301 // Sanity check the scenario we just created.
1302 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1302 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1303 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); 1303 ASSERT_EQ(1, GetRenderSurface(root)->num_contributors());
1304 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); 1304 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible());
1305 1305
1306 // Hit checking any point should not hit the touch handler region on the 1306 // Hit checking any point should not hit the touch handler region on the
1307 // layer. If the invertible matrix is accidentally ignored and treated like an 1307 // layer. If the invertible matrix is accidentally ignored and treated like an
1308 // identity, then the hit testing will incorrectly hit the layer when it 1308 // identity, then the hit testing will incorrectly hit the layer when it
1309 // shouldn't. 1309 // shouldn't.
1310 gfx::PointF test_point(1.f, 1.f); 1310 gfx::PointF test_point(1.f, 1.f);
1311 LayerImpl* result_layer = 1311 LayerImpl* result_layer =
1312 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1312 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1313 test_point); 1313 test_point);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 root->SetPosition(gfx::PointF(50.f, 50.f)); 1360 root->SetPosition(gfx::PointF(50.f, 50.f));
1361 root->SetBounds(gfx::Size(100, 100)); 1361 root->SetBounds(gfx::Size(100, 100));
1362 root->SetDrawsContent(true); 1362 root->SetDrawsContent(true);
1363 root->SetTouchEventHandlerRegion(touch_handler_region); 1363 root->SetTouchEventHandlerRegion(touch_handler_region);
1364 1364
1365 host_impl().SetViewportSize(root->bounds()); 1365 host_impl().SetViewportSize(root->bounds());
1366 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1366 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1367 1367
1368 // Sanity check the scenario we just created. 1368 // Sanity check the scenario we just created.
1369 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1369 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1370 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); 1370 ASSERT_EQ(1, GetRenderSurface(root)->num_contributors());
1371 1371
1372 // Hit checking for a point outside the layer should return a null pointer. 1372 // Hit checking for a point outside the layer should return a null pointer.
1373 gfx::PointF test_point(49.f, 49.f); 1373 gfx::PointF test_point(49.f, 49.f);
1374 LayerImpl* result_layer = 1374 LayerImpl* result_layer =
1375 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1375 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1376 test_point); 1376 test_point);
1377 EXPECT_FALSE(result_layer); 1377 EXPECT_FALSE(result_layer);
1378 1378
1379 // Even though the layer has a touch handler region containing (101, 101), it 1379 // Even though the layer has a touch handler region containing (101, 101), it
1380 // should not be visible there since the root render surface would clamp it. 1380 // should not be visible there since the root render surface would clamp it.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 host_impl().active_tree()->PushPageScaleFromMainThread( 1445 host_impl().active_tree()->PushPageScaleFromMainThread(
1446 page_scale_factor, page_scale_factor, max_page_scale_factor); 1446 page_scale_factor, page_scale_factor, max_page_scale_factor);
1447 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1447 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1448 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1448 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1449 1449
1450 // Sanity check the scenario we just created. 1450 // Sanity check the scenario we just created.
1451 // The visible content rect for test_layer is actually 100x100, even though 1451 // The visible content rect for test_layer is actually 100x100, even though
1452 // its layout size is 50x50, positioned at 25x25. 1452 // its layout size is 50x50, positioned at 25x25.
1453 LayerImpl* test_layer = root->test_properties()->children[0]; 1453 LayerImpl* test_layer = root->test_properties()->children[0];
1454 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1454 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1455 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); 1455 ASSERT_EQ(1, GetRenderSurface(root)->num_contributors());
1456 1456
1457 // Check whether the child layer fits into the root after scaled. 1457 // Check whether the child layer fits into the root after scaled.
1458 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); 1458 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect());
1459 1459
1460 // Hit checking for a point outside the layer should return a null pointer 1460 // Hit checking for a point outside the layer should return a null pointer
1461 // (the root layer does not have a touch event handler, so it will not be 1461 // (the root layer does not have a touch event handler, so it will not be
1462 // tested either). 1462 // tested either).
1463 gfx::PointF test_point(76.f, 76.f); 1463 gfx::PointF test_point(76.f, 76.f);
1464 test_point = 1464 test_point =
1465 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); 1465 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 child->SetTouchEventHandlerRegion(touch_handler_region); 1572 child->SetTouchEventHandlerRegion(touch_handler_region);
1573 clipping_layer->test_properties()->AddChild(std::move(child)); 1573 clipping_layer->test_properties()->AddChild(std::move(child));
1574 root->test_properties()->AddChild(std::move(clipping_layer)); 1574 root->test_properties()->AddChild(std::move(clipping_layer));
1575 } 1575 }
1576 1576
1577 host_impl().SetViewportSize(root->bounds()); 1577 host_impl().SetViewportSize(root->bounds());
1578 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1578 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1579 1579
1580 // Sanity check the scenario we just created. 1580 // Sanity check the scenario we just created.
1581 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1581 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1582 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); 1582 ASSERT_EQ(1, GetRenderSurface(root)->num_contributors());
1583 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456); 1583 LayerImpl* child_layer = host_impl().active_tree()->LayerById(456);
1584 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface()); 1584 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface());
1585 1585
1586 // Hit checking for a point outside the layer should return a null pointer. 1586 // Hit checking for a point outside the layer should return a null pointer.
1587 // Despite the child layer being very large, it should be clipped to the root 1587 // Despite the child layer being very large, it should be clipped to the root
1588 // layer's bounds. 1588 // layer's bounds.
1589 gfx::PointF test_point(24.f, 24.f); 1589 gfx::PointF test_point(24.f, 24.f);
1590 LayerImpl* result_layer = 1590 LayerImpl* result_layer =
1591 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1591 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1592 test_point); 1592 test_point);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 notouch_layer->SetBounds(gfx::Size(50, 50)); 1726 notouch_layer->SetBounds(gfx::Size(50, 50));
1727 notouch_layer->SetDrawsContent(true); 1727 notouch_layer->SetDrawsContent(true);
1728 root->test_properties()->AddChild(std::move(notouch_layer)); 1728 root->test_properties()->AddChild(std::move(notouch_layer));
1729 } 1729 }
1730 1730
1731 host_impl().SetViewportSize(root->bounds()); 1731 host_impl().SetViewportSize(root->bounds());
1732 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1732 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1733 1733
1734 // Sanity check the scenario we just created. 1734 // Sanity check the scenario we just created.
1735 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1735 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1736 ASSERT_EQ(2, root->GetRenderSurface()->num_contributors()); 1736 ASSERT_EQ(2, GetRenderSurface(root)->num_contributors());
1737 LayerImpl* touch_layer = host_impl().active_tree()->LayerById(123); 1737 LayerImpl* touch_layer = host_impl().active_tree()->LayerById(123);
1738 LayerImpl* notouch_layer = host_impl().active_tree()->LayerById(1234); 1738 LayerImpl* notouch_layer = host_impl().active_tree()->LayerById(1234);
1739 EXPECT_TRUE(touch_layer->contributes_to_drawn_render_surface()); 1739 EXPECT_TRUE(touch_layer->contributes_to_drawn_render_surface());
1740 EXPECT_TRUE(notouch_layer->contributes_to_drawn_render_surface()); 1740 EXPECT_TRUE(notouch_layer->contributes_to_drawn_render_surface());
1741 1741
1742 gfx::PointF test_point(35.f, 35.f); 1742 gfx::PointF test_point(35.f, 35.f);
1743 LayerImpl* result_layer = 1743 LayerImpl* result_layer =
1744 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 1744 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
1745 test_point); 1745 test_point);
1746 1746
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { 1844 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) {
1845 LayerImpl* root = root_layer(); 1845 LayerImpl* root = root_layer();
1846 root->SetBounds(gfx::Size(100, 100)); 1846 root->SetBounds(gfx::Size(100, 100));
1847 root->SetDrawsContent(true); 1847 root->SetDrawsContent(true);
1848 1848
1849 host_impl().SetViewportSize(root->bounds()); 1849 host_impl().SetViewportSize(root->bounds());
1850 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1850 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1851 1851
1852 // Sanity check the scenario we just created. 1852 // Sanity check the scenario we just created.
1853 ASSERT_EQ(1u, GetRenderSurfaceList().size()); 1853 ASSERT_EQ(1u, GetRenderSurfaceList().size());
1854 ASSERT_EQ(1, root->GetRenderSurface()->num_contributors()); 1854 ASSERT_EQ(1, GetRenderSurface(root)->num_contributors());
1855 1855
1856 LayerSelection input; 1856 LayerSelection input;
1857 1857
1858 input.start.type = gfx::SelectionBound::LEFT; 1858 input.start.type = gfx::SelectionBound::LEFT;
1859 input.start.edge_top = gfx::Point(10, 10); 1859 input.start.edge_top = gfx::Point(10, 10);
1860 input.start.edge_bottom = gfx::Point(10, 20); 1860 input.start.edge_bottom = gfx::Point(10, 20);
1861 input.start.layer_id = root->id(); 1861 input.start.layer_id = root->id();
1862 1862
1863 input.end.type = gfx::SelectionBound::RIGHT; 1863 input.end.type = gfx::SelectionBound::RIGHT;
1864 input.end.edge_top = gfx::Point(50, 10); 1864 input.end.edge_top = gfx::Point(50, 10);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 auto weak_promise = promise->AsWeakPtr(); 2350 auto weak_promise = promise->AsWeakPtr();
2351 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); 2351 host_impl().active_tree()->QueueSwapPromise(std::move(promise));
2352 host_impl().active_tree()->BreakSwapPromises( 2352 host_impl().active_tree()->BreakSwapPromises(
2353 SwapPromise::DidNotSwapReason::SWAP_FAILS); 2353 SwapPromise::DidNotSwapReason::SWAP_FAILS);
2354 EXPECT_FALSE(weak_promise); 2354 EXPECT_FALSE(weak_promise);
2355 } 2355 }
2356 } 2356 }
2357 2357
2358 } // namespace 2358 } // namespace
2359 } // namespace cc 2359 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_video.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698