OLD | NEW |
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 "cc/layers/heads_up_display_layer_impl.h" | 7 #include "cc/layers/heads_up_display_layer_impl.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 gfx::Size bounds(100, 100); | 52 gfx::Size bounds(100, 100); |
53 SetLayerPropertiesForTesting(root.get(), | 53 SetLayerPropertiesForTesting(root.get(), |
54 identity_matrix, | 54 identity_matrix, |
55 transform_origin, | 55 transform_origin, |
56 position, | 56 position, |
57 bounds, | 57 bounds, |
58 true, | 58 true, |
59 false); | 59 false); |
60 root->SetDrawsContent(true); | 60 root->SetDrawsContent(true); |
61 | 61 |
62 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 62 host_impl().SetViewportSize(root->bounds()); |
63 host_impl().active_tree()->SetRootLayer(root.Pass()); | 63 host_impl().active_tree()->SetRootLayer(root.Pass()); |
64 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 64 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
65 | 65 |
66 // Sanity check the scenario we just created. | 66 // Sanity check the scenario we just created. |
67 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 67 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
68 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 68 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
69 | 69 |
70 // Hit testing for a point outside the layer should return a null pointer. | 70 // Hit testing for a point outside the layer should return a null pointer. |
71 gfx::Point test_point(101, 101); | 71 gfx::Point test_point(101, 101); |
72 LayerImpl* result_layer = | 72 LayerImpl* result_layer = |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 gfx::Size bounds(100, 100); | 176 gfx::Size bounds(100, 100); |
177 SetLayerPropertiesForTesting(root.get(), | 177 SetLayerPropertiesForTesting(root.get(), |
178 uninvertible_transform, | 178 uninvertible_transform, |
179 transform_origin, | 179 transform_origin, |
180 position, | 180 position, |
181 bounds, | 181 bounds, |
182 true, | 182 true, |
183 false); | 183 false); |
184 root->SetDrawsContent(true); | 184 root->SetDrawsContent(true); |
185 | 185 |
186 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 186 host_impl().SetViewportSize(root->bounds()); |
187 host_impl().active_tree()->SetRootLayer(root.Pass()); | 187 host_impl().active_tree()->SetRootLayer(root.Pass()); |
188 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 188 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
189 // Sanity check the scenario we just created. | 189 // Sanity check the scenario we just created. |
190 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 190 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
191 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 191 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
192 ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 192 ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); |
193 | 193 |
194 // Hit testing any point should not hit the layer. If the invertible matrix is | 194 // Hit testing any point should not hit the layer. If the invertible matrix is |
195 // accidentally ignored and treated like an identity, then the hit testing | 195 // accidentally ignored and treated like an identity, then the hit testing |
196 // will incorrectly hit the layer when it shouldn't. | 196 // will incorrectly hit the layer when it shouldn't. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 gfx::Size bounds(100, 100); | 242 gfx::Size bounds(100, 100); |
243 SetLayerPropertiesForTesting(root.get(), | 243 SetLayerPropertiesForTesting(root.get(), |
244 identity_matrix, | 244 identity_matrix, |
245 transform_origin, | 245 transform_origin, |
246 position, | 246 position, |
247 bounds, | 247 bounds, |
248 true, | 248 true, |
249 false); | 249 false); |
250 root->SetDrawsContent(true); | 250 root->SetDrawsContent(true); |
251 | 251 |
252 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 252 host_impl().SetViewportSize(root->bounds()); |
253 host_impl().active_tree()->SetRootLayer(root.Pass()); | 253 host_impl().active_tree()->SetRootLayer(root.Pass()); |
254 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 254 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
255 | 255 |
256 // Sanity check the scenario we just created. | 256 // Sanity check the scenario we just created. |
257 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 257 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
258 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 258 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
259 | 259 |
260 // Hit testing for a point outside the layer should return a null pointer. | 260 // Hit testing for a point outside the layer should return a null pointer. |
261 gfx::Point test_point(49, 49); | 261 gfx::Point test_point(49, 49); |
262 LayerImpl* result_layer = | 262 LayerImpl* result_layer = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 gfx::Size bounds(100, 100); | 298 gfx::Size bounds(100, 100); |
299 SetLayerPropertiesForTesting(root.get(), | 299 SetLayerPropertiesForTesting(root.get(), |
300 rotation45_degrees_about_center, | 300 rotation45_degrees_about_center, |
301 transform_origin, | 301 transform_origin, |
302 position, | 302 position, |
303 bounds, | 303 bounds, |
304 true, | 304 true, |
305 false); | 305 false); |
306 root->SetDrawsContent(true); | 306 root->SetDrawsContent(true); |
307 | 307 |
308 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 308 host_impl().SetViewportSize(root->bounds()); |
309 host_impl().active_tree()->SetRootLayer(root.Pass()); | 309 host_impl().active_tree()->SetRootLayer(root.Pass()); |
310 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 310 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
311 | 311 |
312 // Sanity check the scenario we just created. | 312 // Sanity check the scenario we just created. |
313 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 313 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
314 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 314 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
315 | 315 |
316 // Hit testing for points outside the layer. | 316 // Hit testing for points outside the layer. |
317 // These corners would have been inside the un-transformed layer, but they | 317 // These corners would have been inside the un-transformed layer, but they |
318 // should not hit the correctly transformed layer. | 318 // should not hit the correctly transformed layer. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 SetLayerPropertiesForTesting( | 367 SetLayerPropertiesForTesting( |
368 root.get(), | 368 root.get(), |
369 perspective_projection_about_center * translation_by_z, | 369 perspective_projection_about_center * translation_by_z, |
370 transform_origin, | 370 transform_origin, |
371 position, | 371 position, |
372 bounds, | 372 bounds, |
373 true, | 373 true, |
374 false); | 374 false); |
375 root->SetDrawsContent(true); | 375 root->SetDrawsContent(true); |
376 | 376 |
377 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 377 host_impl().SetViewportSize(root->bounds()); |
378 host_impl().active_tree()->SetRootLayer(root.Pass()); | 378 host_impl().active_tree()->SetRootLayer(root.Pass()); |
379 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 379 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
380 | 380 |
381 // Sanity check the scenario we just created. | 381 // Sanity check the scenario we just created. |
382 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 382 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
383 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 383 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
384 | 384 |
385 // Hit testing for points outside the layer. | 385 // Hit testing for points outside the layer. |
386 // These corners would have been inside the un-transformed layer, but they | 386 // These corners would have been inside the un-transformed layer, but they |
387 // should not hit the correctly transformed layer. | 387 // should not hit the correctly transformed layer. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 false); | 447 false); |
448 | 448 |
449 // override content bounds and contents scale | 449 // override content bounds and contents scale |
450 test_layer->SetContentBounds(gfx::Size(100, 100)); | 450 test_layer->SetContentBounds(gfx::Size(100, 100)); |
451 test_layer->SetContentsScale(2, 2); | 451 test_layer->SetContentsScale(2, 2); |
452 | 452 |
453 test_layer->SetDrawsContent(true); | 453 test_layer->SetDrawsContent(true); |
454 root->AddChild(test_layer.Pass()); | 454 root->AddChild(test_layer.Pass()); |
455 } | 455 } |
456 | 456 |
457 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 457 host_impl().SetViewportSize(root->bounds()); |
458 host_impl().active_tree()->SetRootLayer(root.Pass()); | 458 host_impl().active_tree()->SetRootLayer(root.Pass()); |
459 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 459 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
460 | 460 |
461 // Sanity check the scenario we just created. | 461 // Sanity check the scenario we just created. |
462 // The visible content rect for test_layer is actually 100x100, even though | 462 // The visible content rect for test_layer is actually 100x100, even though |
463 // its layout size is 50x50, positioned at 25x25. | 463 // its layout size is 50x50, positioned at 25x25. |
464 LayerImpl* test_layer = | 464 LayerImpl* test_layer = |
465 host_impl().active_tree()->root_layer()->children()[0]; | 465 host_impl().active_tree()->root_layer()->children()[0]; |
466 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); | 466 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); |
467 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 467 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 transform_origin, | 538 transform_origin, |
539 position, | 539 position, |
540 bounds, | 540 bounds, |
541 true, | 541 true, |
542 false); | 542 false); |
543 child->SetDrawsContent(true); | 543 child->SetDrawsContent(true); |
544 clipping_layer->AddChild(child.Pass()); | 544 clipping_layer->AddChild(child.Pass()); |
545 root->AddChild(clipping_layer.Pass()); | 545 root->AddChild(clipping_layer.Pass()); |
546 } | 546 } |
547 | 547 |
548 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 548 host_impl().SetViewportSize(root->bounds()); |
549 host_impl().active_tree()->SetRootLayer(root.Pass()); | 549 host_impl().active_tree()->SetRootLayer(root.Pass()); |
550 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 550 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
551 | 551 |
552 // Sanity check the scenario we just created. | 552 // Sanity check the scenario we just created. |
553 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 553 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
554 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 554 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
555 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 555 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); |
556 | 556 |
557 // Hit testing for a point outside the layer should return a null pointer. | 557 // Hit testing for a point outside the layer should return a null pointer. |
558 // Despite the child layer being very large, it should be clipped to the root | 558 // Despite the child layer being very large, it should be clipped to the root |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 bounds, | 663 bounds, |
664 true, | 664 true, |
665 false); | 665 false); |
666 rotated_leaf->SetDrawsContent(true); | 666 rotated_leaf->SetDrawsContent(true); |
667 | 667 |
668 grand_child->AddChild(rotated_leaf.Pass()); | 668 grand_child->AddChild(rotated_leaf.Pass()); |
669 child->AddChild(grand_child.Pass()); | 669 child->AddChild(grand_child.Pass()); |
670 root->AddChild(child.Pass()); | 670 root->AddChild(child.Pass()); |
671 } | 671 } |
672 | 672 |
673 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 673 host_impl().SetViewportSize(root->bounds()); |
674 host_impl().active_tree()->SetRootLayer(root.Pass()); | 674 host_impl().active_tree()->SetRootLayer(root.Pass()); |
675 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 675 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
676 | 676 |
677 // Sanity check the scenario we just created. | 677 // Sanity check the scenario we just created. |
678 // The grand_child is expected to create a render surface because it | 678 // The grand_child is expected to create a render surface because it |
679 // MasksToBounds and is not axis aligned. | 679 // MasksToBounds and is not axis aligned. |
680 ASSERT_EQ(2u, RenderSurfaceLayerList().size()); | 680 ASSERT_EQ(2u, RenderSurfaceLayerList().size()); |
681 ASSERT_EQ( | 681 ASSERT_EQ( |
682 1u, | 682 1u, |
683 RenderSurfaceLayerList().at(0)->render_surface()->layer_list().size()); | 683 RenderSurfaceLayerList().at(0)->render_surface()->layer_list().size()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 transform_origin, | 786 transform_origin, |
787 position, | 787 position, |
788 bounds, | 788 bounds, |
789 true, | 789 true, |
790 false); | 790 false); |
791 child->SetDrawsContent(true); | 791 child->SetDrawsContent(true); |
792 intermediate_layer->AddChild(child.Pass()); | 792 intermediate_layer->AddChild(child.Pass()); |
793 root->AddChild(intermediate_layer.Pass()); | 793 root->AddChild(intermediate_layer.Pass()); |
794 } | 794 } |
795 | 795 |
796 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 796 host_impl().SetViewportSize(root->bounds()); |
797 host_impl().active_tree()->SetRootLayer(root.Pass()); | 797 host_impl().active_tree()->SetRootLayer(root.Pass()); |
798 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 798 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
799 | 799 |
800 // Sanity check the scenario we just created. | 800 // Sanity check the scenario we just created. |
801 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 801 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
802 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 802 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
803 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 803 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); |
804 | 804 |
805 // Hit testing for a point outside the layer should return a null pointer. | 805 // Hit testing for a point outside the layer should return a null pointer. |
806 gfx::Point test_point(69, 69); | 806 gfx::Point test_point(69, 69); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 | 894 |
895 child1->AddChild(grand_child1.Pass()); | 895 child1->AddChild(grand_child1.Pass()); |
896 root->AddChild(child1.Pass()); | 896 root->AddChild(child1.Pass()); |
897 root->AddChild(child2.Pass()); | 897 root->AddChild(child2.Pass()); |
898 } | 898 } |
899 | 899 |
900 LayerImpl* child1 = root->children()[0]; | 900 LayerImpl* child1 = root->children()[0]; |
901 LayerImpl* child2 = root->children()[1]; | 901 LayerImpl* child2 = root->children()[1]; |
902 LayerImpl* grand_child1 = child1->children()[0]; | 902 LayerImpl* grand_child1 = child1->children()[0]; |
903 | 903 |
904 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 904 host_impl().SetViewportSize(root->bounds()); |
905 host_impl().active_tree()->SetRootLayer(root.Pass()); | 905 host_impl().active_tree()->SetRootLayer(root.Pass()); |
906 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 906 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
907 | 907 |
908 // Sanity check the scenario we just created. | 908 // Sanity check the scenario we just created. |
909 ASSERT_TRUE(child1); | 909 ASSERT_TRUE(child1); |
910 ASSERT_TRUE(child2); | 910 ASSERT_TRUE(child2); |
911 ASSERT_TRUE(grand_child1); | 911 ASSERT_TRUE(grand_child1); |
912 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 912 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
913 | 913 |
914 RenderSurfaceImpl* root_render_surface = root_layer()->render_surface(); | 914 RenderSurfaceImpl* root_render_surface = root_layer()->render_surface(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 | 1042 |
1043 child1->AddChild(grand_child1.Pass()); | 1043 child1->AddChild(grand_child1.Pass()); |
1044 root->AddChild(child1.Pass()); | 1044 root->AddChild(child1.Pass()); |
1045 root->AddChild(child2.Pass()); | 1045 root->AddChild(child2.Pass()); |
1046 } | 1046 } |
1047 | 1047 |
1048 LayerImpl* child1 = root->children()[0]; | 1048 LayerImpl* child1 = root->children()[0]; |
1049 LayerImpl* child2 = root->children()[1]; | 1049 LayerImpl* child2 = root->children()[1]; |
1050 LayerImpl* grand_child1 = child1->children()[0]; | 1050 LayerImpl* grand_child1 = child1->children()[0]; |
1051 | 1051 |
1052 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1052 host_impl().SetViewportSize(root->bounds()); |
1053 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1053 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1054 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1054 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1055 | 1055 |
1056 // Sanity check the scenario we just created. | 1056 // Sanity check the scenario we just created. |
1057 ASSERT_TRUE(child1); | 1057 ASSERT_TRUE(child1); |
1058 ASSERT_TRUE(child2); | 1058 ASSERT_TRUE(child2); |
1059 ASSERT_TRUE(grand_child1); | 1059 ASSERT_TRUE(grand_child1); |
1060 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1060 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1061 | 1061 |
1062 RenderSurfaceImpl* root_render_surface = | 1062 RenderSurfaceImpl* root_render_surface = |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 grand_child->SetDrawsContent(true); | 1160 grand_child->SetDrawsContent(true); |
1161 grand_child->SetForceRenderSurface(true); | 1161 grand_child->SetForceRenderSurface(true); |
1162 | 1162 |
1163 // This should let |grand_child| "escape" |child|'s clip. | 1163 // This should let |grand_child| "escape" |child|'s clip. |
1164 grand_child->SetClipParent(root.get()); | 1164 grand_child->SetClipParent(root.get()); |
1165 | 1165 |
1166 child->AddChild(grand_child.Pass()); | 1166 child->AddChild(grand_child.Pass()); |
1167 root->AddChild(child.Pass()); | 1167 root->AddChild(child.Pass()); |
1168 } | 1168 } |
1169 | 1169 |
1170 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1170 host_impl().SetViewportSize(root->bounds()); |
1171 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1171 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1172 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1172 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1173 | 1173 |
1174 gfx::Point test_point = gfx::Point(12, 52); | 1174 gfx::Point test_point = gfx::Point(12, 52); |
1175 LayerImpl* result_layer = | 1175 LayerImpl* result_layer = |
1176 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1176 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1177 ASSERT_TRUE(result_layer); | 1177 ASSERT_TRUE(result_layer); |
1178 EXPECT_EQ(4, result_layer->id()); | 1178 EXPECT_EQ(4, result_layer->id()); |
1179 } | 1179 } |
1180 | 1180 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 true, | 1235 true, |
1236 false); | 1236 false); |
1237 grand_child->SetDrawsContent(true); | 1237 grand_child->SetDrawsContent(true); |
1238 grand_child->SetForceRenderSurface(true); | 1238 grand_child->SetForceRenderSurface(true); |
1239 | 1239 |
1240 scroll_child->AddChild(grand_child.Pass()); | 1240 scroll_child->AddChild(grand_child.Pass()); |
1241 root->AddChild(scroll_child.Pass()); | 1241 root->AddChild(scroll_child.Pass()); |
1242 root->AddChild(child.Pass()); | 1242 root->AddChild(child.Pass()); |
1243 } | 1243 } |
1244 | 1244 |
1245 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1245 host_impl().SetViewportSize(root->bounds()); |
1246 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1246 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1247 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1247 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1248 | 1248 |
1249 gfx::Point test_point = gfx::Point(12, 52); | 1249 gfx::Point test_point = gfx::Point(12, 52); |
1250 LayerImpl* result_layer = | 1250 LayerImpl* result_layer = |
1251 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1251 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
1252 // The |test_point| should have been clipped away by |child|, the scroll | 1252 // The |test_point| should have been clipped away by |child|, the scroll |
1253 // parent, so the only thing that should be hit is |root|. | 1253 // parent, so the only thing that should be hit is |root|. |
1254 ASSERT_TRUE(result_layer); | 1254 ASSERT_TRUE(result_layer); |
1255 ASSERT_EQ(1, result_layer->id()); | 1255 ASSERT_EQ(1, result_layer->id()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 | 1328 |
1329 child1->AddChild(grand_child1.Pass()); | 1329 child1->AddChild(grand_child1.Pass()); |
1330 root->AddChild(child1.Pass()); | 1330 root->AddChild(child1.Pass()); |
1331 root->AddChild(child2.Pass()); | 1331 root->AddChild(child2.Pass()); |
1332 } | 1332 } |
1333 | 1333 |
1334 LayerImpl* child1 = root->children()[0]; | 1334 LayerImpl* child1 = root->children()[0]; |
1335 LayerImpl* child2 = root->children()[1]; | 1335 LayerImpl* child2 = root->children()[1]; |
1336 LayerImpl* grand_child1 = child1->children()[0]; | 1336 LayerImpl* grand_child1 = child1->children()[0]; |
1337 | 1337 |
1338 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1338 host_impl().SetViewportSize(root->bounds()); |
1339 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1339 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1340 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1340 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1341 | 1341 |
1342 // Sanity check the scenario we just created. | 1342 // Sanity check the scenario we just created. |
1343 ASSERT_TRUE(child1); | 1343 ASSERT_TRUE(child1); |
1344 ASSERT_TRUE(child2); | 1344 ASSERT_TRUE(child2); |
1345 ASSERT_TRUE(grand_child1); | 1345 ASSERT_TRUE(grand_child1); |
1346 ASSERT_TRUE(child1->render_surface()); | 1346 ASSERT_TRUE(child1->render_surface()); |
1347 ASSERT_TRUE(child2->render_surface()); | 1347 ASSERT_TRUE(child2->render_surface()); |
1348 ASSERT_TRUE(grand_child1->render_surface()); | 1348 ASSERT_TRUE(grand_child1->render_surface()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 gfx::Size bounds(100, 100); | 1418 gfx::Size bounds(100, 100); |
1419 SetLayerPropertiesForTesting(root.get(), | 1419 SetLayerPropertiesForTesting(root.get(), |
1420 identity_matrix, | 1420 identity_matrix, |
1421 transform_origin, | 1421 transform_origin, |
1422 position, | 1422 position, |
1423 bounds, | 1423 bounds, |
1424 true, | 1424 true, |
1425 false); | 1425 false); |
1426 root->SetDrawsContent(true); | 1426 root->SetDrawsContent(true); |
1427 | 1427 |
1428 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1428 host_impl().SetViewportSize(root->bounds()); |
1429 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1429 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1430 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1430 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1431 | 1431 |
1432 // Sanity check the scenario we just created. | 1432 // Sanity check the scenario we just created. |
1433 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1433 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1434 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1434 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1435 | 1435 |
1436 // Hit checking for any point should return a null pointer for a layer without | 1436 // Hit checking for any point should return a null pointer for a layer without |
1437 // any touch event handler regions. | 1437 // any touch event handler regions. |
1438 gfx::Point test_point(11, 11); | 1438 gfx::Point test_point(11, 11); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 SetLayerPropertiesForTesting(root.get(), | 1507 SetLayerPropertiesForTesting(root.get(), |
1508 uninvertible_transform, | 1508 uninvertible_transform, |
1509 transform_origin, | 1509 transform_origin, |
1510 position, | 1510 position, |
1511 bounds, | 1511 bounds, |
1512 true, | 1512 true, |
1513 false); | 1513 false); |
1514 root->SetDrawsContent(true); | 1514 root->SetDrawsContent(true); |
1515 root->SetTouchEventHandlerRegion(touch_handler_region); | 1515 root->SetTouchEventHandlerRegion(touch_handler_region); |
1516 | 1516 |
1517 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1517 host_impl().SetViewportSize(root->bounds()); |
1518 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1518 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1519 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1519 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1520 | 1520 |
1521 // Sanity check the scenario we just created. | 1521 // Sanity check the scenario we just created. |
1522 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1522 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1523 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1523 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1524 ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 1524 ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); |
1525 | 1525 |
1526 // Hit checking any point should not hit the touch handler region on the | 1526 // Hit checking any point should not hit the touch handler region on the |
1527 // layer. If the invertible matrix is accidentally ignored and treated like an | 1527 // layer. If the invertible matrix is accidentally ignored and treated like an |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 SetLayerPropertiesForTesting(root.get(), | 1585 SetLayerPropertiesForTesting(root.get(), |
1586 identity_matrix, | 1586 identity_matrix, |
1587 transform_origin, | 1587 transform_origin, |
1588 position, | 1588 position, |
1589 bounds, | 1589 bounds, |
1590 true, | 1590 true, |
1591 false); | 1591 false); |
1592 root->SetDrawsContent(true); | 1592 root->SetDrawsContent(true); |
1593 root->SetTouchEventHandlerRegion(touch_handler_region); | 1593 root->SetTouchEventHandlerRegion(touch_handler_region); |
1594 | 1594 |
1595 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1595 host_impl().SetViewportSize(root->bounds()); |
1596 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1596 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1597 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1597 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1598 | 1598 |
1599 // Sanity check the scenario we just created. | 1599 // Sanity check the scenario we just created. |
1600 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1600 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1601 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1601 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1602 | 1602 |
1603 // Hit checking for a point outside the layer should return a null pointer. | 1603 // Hit checking for a point outside the layer should return a null pointer. |
1604 gfx::Point test_point(49, 49); | 1604 gfx::Point test_point(49, 49); |
1605 LayerImpl* result_layer = | 1605 LayerImpl* result_layer = |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 | 1681 |
1682 // override content bounds and contents scale | 1682 // override content bounds and contents scale |
1683 test_layer->SetContentBounds(gfx::Size(100, 100)); | 1683 test_layer->SetContentBounds(gfx::Size(100, 100)); |
1684 test_layer->SetContentsScale(2, 2); | 1684 test_layer->SetContentsScale(2, 2); |
1685 | 1685 |
1686 test_layer->SetDrawsContent(true); | 1686 test_layer->SetDrawsContent(true); |
1687 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1687 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1688 root->AddChild(test_layer.Pass()); | 1688 root->AddChild(test_layer.Pass()); |
1689 } | 1689 } |
1690 | 1690 |
1691 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1691 host_impl().SetViewportSize(root->bounds()); |
1692 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1692 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1693 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1693 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1694 | 1694 |
1695 // Sanity check the scenario we just created. | 1695 // Sanity check the scenario we just created. |
1696 // The visible content rect for test_layer is actually 100x100, even though | 1696 // The visible content rect for test_layer is actually 100x100, even though |
1697 // its layout size is 50x50, positioned at 25x25. | 1697 // its layout size is 50x50, positioned at 25x25. |
1698 LayerImpl* test_layer = | 1698 LayerImpl* test_layer = |
1699 host_impl().active_tree()->root_layer()->children()[0]; | 1699 host_impl().active_tree()->root_layer()->children()[0]; |
1700 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); | 1700 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), test_layer->visible_content_rect()); |
1701 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1701 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 position, | 1920 position, |
1921 bounds, | 1921 bounds, |
1922 true, | 1922 true, |
1923 false); | 1923 false); |
1924 child->SetDrawsContent(true); | 1924 child->SetDrawsContent(true); |
1925 child->SetTouchEventHandlerRegion(touch_handler_region); | 1925 child->SetTouchEventHandlerRegion(touch_handler_region); |
1926 clipping_layer->AddChild(child.Pass()); | 1926 clipping_layer->AddChild(child.Pass()); |
1927 root->AddChild(clipping_layer.Pass()); | 1927 root->AddChild(clipping_layer.Pass()); |
1928 } | 1928 } |
1929 | 1929 |
1930 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 1930 host_impl().SetViewportSize(root->bounds()); |
1931 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1931 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1932 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1932 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1933 | 1933 |
1934 // Sanity check the scenario we just created. | 1934 // Sanity check the scenario we just created. |
1935 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1935 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1936 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1936 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1937 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 1937 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); |
1938 | 1938 |
1939 // Hit checking for a point outside the layer should return a null pointer. | 1939 // Hit checking for a point outside the layer should return a null pointer. |
1940 // Despite the child layer being very large, it should be clipped to the root | 1940 // Despite the child layer being very large, it should be clipped to the root |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 identity_matrix, | 2018 identity_matrix, |
2019 transform_origin, | 2019 transform_origin, |
2020 position, | 2020 position, |
2021 bounds, | 2021 bounds, |
2022 true, | 2022 true, |
2023 false); | 2023 false); |
2024 notouch_layer->SetDrawsContent(true); | 2024 notouch_layer->SetDrawsContent(true); |
2025 root->AddChild(notouch_layer.Pass()); | 2025 root->AddChild(notouch_layer.Pass()); |
2026 } | 2026 } |
2027 | 2027 |
2028 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 2028 host_impl().SetViewportSize(root->bounds()); |
2029 host_impl().active_tree()->SetRootLayer(root.Pass()); | 2029 host_impl().active_tree()->SetRootLayer(root.Pass()); |
2030 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2030 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2031 | 2031 |
2032 // Sanity check the scenario we just created. | 2032 // Sanity check the scenario we just created. |
2033 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2033 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
2034 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 2034 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); |
2035 ASSERT_EQ(123, root_layer()->render_surface()->layer_list().at(0)->id()); | 2035 ASSERT_EQ(123, root_layer()->render_surface()->layer_list().at(0)->id()); |
2036 ASSERT_EQ(1234, root_layer()->render_surface()->layer_list().at(1)->id()); | 2036 ASSERT_EQ(1234, root_layer()->render_surface()->layer_list().at(1)->id()); |
2037 | 2037 |
2038 gfx::Point test_point(35, 35); | 2038 gfx::Point test_point(35, 35); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 gfx::Size bounds(100, 100); | 2080 gfx::Size bounds(100, 100); |
2081 SetLayerPropertiesForTesting(root.get(), | 2081 SetLayerPropertiesForTesting(root.get(), |
2082 identity_matrix, | 2082 identity_matrix, |
2083 transform_origin, | 2083 transform_origin, |
2084 position, | 2084 position, |
2085 bounds, | 2085 bounds, |
2086 true, | 2086 true, |
2087 false); | 2087 false); |
2088 root->SetDrawsContent(true); | 2088 root->SetDrawsContent(true); |
2089 | 2089 |
2090 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 2090 host_impl().SetViewportSize(root->bounds()); |
2091 host_impl().active_tree()->SetRootLayer(root.Pass()); | 2091 host_impl().active_tree()->SetRootLayer(root.Pass()); |
2092 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2092 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2093 | 2093 |
2094 // Sanity check the scenario we just created. | 2094 // Sanity check the scenario we just created. |
2095 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2095 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
2096 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 2096 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
2097 | 2097 |
2098 LayerSelectionBound left_input; | 2098 LayerSelectionBound left_input; |
2099 left_input.type = SELECTION_BOUND_LEFT; | 2099 left_input.type = SELECTION_BOUND_LEFT; |
2100 left_input.edge_top = gfx::PointF(10, 10); | 2100 left_input.edge_top = gfx::PointF(10, 10); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 transform_origin, | 2187 transform_origin, |
2188 position, | 2188 position, |
2189 bounds, | 2189 bounds, |
2190 true, | 2190 true, |
2191 false); | 2191 false); |
2192 clipped_layer->SetDrawsContent(true); | 2192 clipped_layer->SetDrawsContent(true); |
2193 clipping_layer->AddChild(clipped_layer.Pass()); | 2193 clipping_layer->AddChild(clipped_layer.Pass()); |
2194 root->AddChild(clipping_layer.Pass()); | 2194 root->AddChild(clipping_layer.Pass()); |
2195 } | 2195 } |
2196 | 2196 |
2197 host_impl().SetViewportSize(gfx::ToCeiledSize(root->bounds())); | 2197 host_impl().SetViewportSize(root->bounds()); |
2198 host_impl().active_tree()->SetRootLayer(root.Pass()); | 2198 host_impl().active_tree()->SetRootLayer(root.Pass()); |
2199 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2199 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
2200 | 2200 |
2201 // Sanity check the scenario we just created. | 2201 // Sanity check the scenario we just created. |
2202 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2202 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
2203 | 2203 |
2204 LayerSelectionBound left_input; | 2204 LayerSelectionBound left_input; |
2205 left_input.type = SELECTION_BOUND_LEFT; | 2205 left_input.type = SELECTION_BOUND_LEFT; |
2206 left_input.edge_top = gfx::PointF(25, 10); | 2206 left_input.edge_top = gfx::PointF(25, 10); |
2207 left_input.edge_bottom = gfx::PointF(25, 30); | 2207 left_input.edge_bottom = gfx::PointF(25, 30); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2356 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
2357 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2357 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
2358 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2358 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
2359 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2359 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
2360 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2360 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
2361 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2361 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
2362 } | 2362 } |
2363 | 2363 |
2364 } // namespace | 2364 } // namespace |
2365 } // namespace cc | 2365 } // namespace cc |
OLD | NEW |