| 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 "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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 gfx::Size bounds(100, 100); | 129 gfx::Size bounds(100, 100); |
| 130 LayerImpl* root = root_layer(); | 130 LayerImpl* root = root_layer(); |
| 131 root->SetBounds(bounds); | 131 root->SetBounds(bounds); |
| 132 root->SetDrawsContent(true); | 132 root->SetDrawsContent(true); |
| 133 | 133 |
| 134 host_impl().SetViewportSize(root->bounds()); | 134 host_impl().SetViewportSize(root->bounds()); |
| 135 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 135 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 136 | 136 |
| 137 // Sanity check the scenario we just created. | 137 // Sanity check the scenario we just created. |
| 138 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 138 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 139 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 139 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 140 | 140 |
| 141 // Hit testing for a point outside the layer should return a null pointer. | 141 // Hit testing for a point outside the layer should return a null pointer. |
| 142 gfx::PointF test_point(101.f, 101.f); | 142 gfx::PointF test_point(101.f, 101.f); |
| 143 LayerImpl* result_layer = | 143 LayerImpl* result_layer = |
| 144 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 144 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 145 EXPECT_FALSE(result_layer); | 145 EXPECT_FALSE(result_layer); |
| 146 | 146 |
| 147 test_point = gfx::PointF(-1.f, -1.f); | 147 test_point = gfx::PointF(-1.f, -1.f); |
| 148 result_layer = | 148 result_layer = |
| 149 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 149 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 hud->SetBounds(gfx::Size(200, 200)); | 198 hud->SetBounds(gfx::Size(200, 200)); |
| 199 hud->SetDrawsContent(true); | 199 hud->SetDrawsContent(true); |
| 200 | 200 |
| 201 host_impl().SetViewportSize(hud->bounds()); | 201 host_impl().SetViewportSize(hud->bounds()); |
| 202 host_impl().active_tree()->set_hud_layer(hud.get()); | 202 host_impl().active_tree()->set_hud_layer(hud.get()); |
| 203 root->test_properties()->AddChild(std::move(hud)); | 203 root->test_properties()->AddChild(std::move(hud)); |
| 204 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 204 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 205 | 205 |
| 206 // Sanity check the scenario we just created. | 206 // Sanity check the scenario we just created. |
| 207 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 207 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 208 ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 208 ASSERT_EQ(2u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 209 | 209 |
| 210 // Hit testing for a point inside HUD, but outside root should return null | 210 // Hit testing for a point inside HUD, but outside root should return null |
| 211 gfx::PointF test_point(101.f, 101.f); | 211 gfx::PointF test_point(101.f, 101.f); |
| 212 LayerImpl* result_layer = | 212 LayerImpl* result_layer = |
| 213 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 213 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 214 EXPECT_FALSE(result_layer); | 214 EXPECT_FALSE(result_layer); |
| 215 | 215 |
| 216 test_point = gfx::PointF(-1.f, -1.f); | 216 test_point = gfx::PointF(-1.f, -1.f); |
| 217 result_layer = | 217 result_layer = |
| 218 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 218 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // While computing visible rects by combining clips in screen space, we set | 250 // While computing visible rects by combining clips in screen space, we set |
| 251 // the entire layer as visible if the screen space transform is singular. This | 251 // the entire layer as visible if the screen space transform is singular. This |
| 252 // is not always true when we combine clips in target space because if the | 252 // is not always true when we combine clips in target space because if the |
| 253 // intersection of combined_clip in taret space with layer_rect projected to | 253 // intersection of combined_clip in taret space with layer_rect projected to |
| 254 // target space is empty, we set it to an empty rect. | 254 // target space is empty, we set it to an empty rect. |
| 255 bool skip_verify_visible_rect_calculations = true; | 255 bool skip_verify_visible_rect_calculations = true; |
| 256 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( | 256 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( |
| 257 skip_verify_visible_rect_calculations); | 257 skip_verify_visible_rect_calculations); |
| 258 // Sanity check the scenario we just created. | 258 // Sanity check the scenario we just created. |
| 259 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 259 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 260 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 260 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 261 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); | 261 ASSERT_FALSE(root_layer()->ScreenSpaceTransform().IsInvertible()); |
| 262 | 262 |
| 263 // Hit testing any point should not hit the layer. If the invertible matrix is | 263 // Hit testing any point should not hit the layer. If the invertible matrix is |
| 264 // accidentally ignored and treated like an identity, then the hit testing | 264 // accidentally ignored and treated like an identity, then the hit testing |
| 265 // will incorrectly hit the layer when it shouldn't. | 265 // will incorrectly hit the layer when it shouldn't. |
| 266 gfx::PointF test_point(1.f, 1.f); | 266 gfx::PointF test_point(1.f, 1.f); |
| 267 LayerImpl* result_layer = | 267 LayerImpl* result_layer = |
| 268 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 268 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 269 EXPECT_FALSE(result_layer); | 269 EXPECT_FALSE(result_layer); |
| 270 | 270 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 LayerImpl* root = root_layer(); | 305 LayerImpl* root = root_layer(); |
| 306 root->SetPosition(gfx::PointF(50.f, 50.f)); | 306 root->SetPosition(gfx::PointF(50.f, 50.f)); |
| 307 root->SetBounds(gfx::Size(100, 100)); | 307 root->SetBounds(gfx::Size(100, 100)); |
| 308 root->SetDrawsContent(true); | 308 root->SetDrawsContent(true); |
| 309 | 309 |
| 310 host_impl().SetViewportSize(root->bounds()); | 310 host_impl().SetViewportSize(root->bounds()); |
| 311 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 311 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 312 | 312 |
| 313 // Sanity check the scenario we just created. | 313 // Sanity check the scenario we just created. |
| 314 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 314 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 315 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 315 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 316 | 316 |
| 317 // Hit testing for a point outside the layer should return a null pointer. | 317 // Hit testing for a point outside the layer should return a null pointer. |
| 318 gfx::PointF test_point(49.f, 49.f); | 318 gfx::PointF test_point(49.f, 49.f); |
| 319 LayerImpl* result_layer = | 319 LayerImpl* result_layer = |
| 320 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 320 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 321 EXPECT_FALSE(result_layer); | 321 EXPECT_FALSE(result_layer); |
| 322 | 322 |
| 323 // Even though the layer exists at (101, 101), it should not be visible there | 323 // Even though the layer exists at (101, 101), it should not be visible there |
| 324 // since the root render surface would clamp it. | 324 // since the root render surface would clamp it. |
| 325 test_point = gfx::PointF(101.f, 101.f); | 325 test_point = gfx::PointF(101.f, 101.f); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 350 LayerImpl* root = root_layer(); | 350 LayerImpl* root = root_layer(); |
| 351 root->test_properties()->transform = rotation45_degrees_about_center; | 351 root->test_properties()->transform = rotation45_degrees_about_center; |
| 352 root->SetBounds(gfx::Size(100, 100)); | 352 root->SetBounds(gfx::Size(100, 100)); |
| 353 root->SetDrawsContent(true); | 353 root->SetDrawsContent(true); |
| 354 | 354 |
| 355 host_impl().SetViewportSize(root->bounds()); | 355 host_impl().SetViewportSize(root->bounds()); |
| 356 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 356 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 357 | 357 |
| 358 // Sanity check the scenario we just created. | 358 // Sanity check the scenario we just created. |
| 359 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 359 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 360 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 360 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 361 | 361 |
| 362 // Hit testing for points outside the layer. | 362 // Hit testing for points outside the layer. |
| 363 // These corners would have been inside the un-transformed layer, but they | 363 // These corners would have been inside the un-transformed layer, but they |
| 364 // should not hit the correctly transformed layer. | 364 // should not hit the correctly transformed layer. |
| 365 gfx::PointF test_point(99.f, 99.f); | 365 gfx::PointF test_point(99.f, 99.f); |
| 366 LayerImpl* result_layer = | 366 LayerImpl* result_layer = |
| 367 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 367 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 368 EXPECT_FALSE(result_layer); | 368 EXPECT_FALSE(result_layer); |
| 369 | 369 |
| 370 test_point = gfx::PointF(1.f, 1.f); | 370 test_point = gfx::PointF(1.f, 1.f); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 root->test_properties()->transform = | 522 root->test_properties()->transform = |
| 523 (perspective_projection_about_center * translation_by_z); | 523 (perspective_projection_about_center * translation_by_z); |
| 524 root->SetBounds(gfx::Size(100, 100)); | 524 root->SetBounds(gfx::Size(100, 100)); |
| 525 root->SetDrawsContent(true); | 525 root->SetDrawsContent(true); |
| 526 | 526 |
| 527 host_impl().SetViewportSize(root->bounds()); | 527 host_impl().SetViewportSize(root->bounds()); |
| 528 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 528 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 529 | 529 |
| 530 // Sanity check the scenario we just created. | 530 // Sanity check the scenario we just created. |
| 531 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 531 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 532 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 532 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 533 | 533 |
| 534 // Hit testing for points outside the layer. | 534 // Hit testing for points outside the layer. |
| 535 // These corners would have been inside the un-transformed layer, but they | 535 // These corners would have been inside the un-transformed layer, but they |
| 536 // should not hit the correctly transformed layer. | 536 // should not hit the correctly transformed layer. |
| 537 gfx::PointF test_point(24.f, 24.f); | 537 gfx::PointF test_point(24.f, 24.f); |
| 538 LayerImpl* result_layer = | 538 LayerImpl* result_layer = |
| 539 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 539 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 540 EXPECT_FALSE(result_layer); | 540 EXPECT_FALSE(result_layer); |
| 541 | 541 |
| 542 test_point = gfx::PointF(76.f, 76.f); | 542 test_point = gfx::PointF(76.f, 76.f); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 child->SetDrawsContent(true); | 580 child->SetDrawsContent(true); |
| 581 clipping_layer->test_properties()->AddChild(std::move(child)); | 581 clipping_layer->test_properties()->AddChild(std::move(child)); |
| 582 root->test_properties()->AddChild(std::move(clipping_layer)); | 582 root->test_properties()->AddChild(std::move(clipping_layer)); |
| 583 } | 583 } |
| 584 | 584 |
| 585 host_impl().SetViewportSize(root->bounds()); | 585 host_impl().SetViewportSize(root->bounds()); |
| 586 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 586 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 587 | 587 |
| 588 // Sanity check the scenario we just created. | 588 // Sanity check the scenario we just created. |
| 589 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 589 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 590 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 590 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 591 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 591 ASSERT_EQ(456, root_layer()->GetRenderSurface()->layer_list().at(0)->id()); |
| 592 | 592 |
| 593 // Hit testing for a point outside the layer should return a null pointer. | 593 // Hit testing for a point outside the layer should return a null pointer. |
| 594 // Despite the child layer being very large, it should be clipped to the root | 594 // Despite the child layer being very large, it should be clipped to the root |
| 595 // layer's bounds. | 595 // layer's bounds. |
| 596 gfx::PointF test_point(24.f, 24.f); | 596 gfx::PointF test_point(24.f, 24.f); |
| 597 LayerImpl* result_layer = | 597 LayerImpl* result_layer = |
| 598 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 598 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 599 EXPECT_FALSE(result_layer); | 599 EXPECT_FALSE(result_layer); |
| 600 | 600 |
| 601 // Even though the layer exists at (101, 101), it should not be visible there | 601 // Even though the layer exists at (101, 101), it should not be visible there |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 child->SetDrawsContent(true); | 759 child->SetDrawsContent(true); |
| 760 intermediate_layer->test_properties()->AddChild(std::move(child)); | 760 intermediate_layer->test_properties()->AddChild(std::move(child)); |
| 761 root->test_properties()->AddChild(std::move(intermediate_layer)); | 761 root->test_properties()->AddChild(std::move(intermediate_layer)); |
| 762 } | 762 } |
| 763 | 763 |
| 764 host_impl().SetViewportSize(root->bounds()); | 764 host_impl().SetViewportSize(root->bounds()); |
| 765 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 765 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 766 | 766 |
| 767 // Sanity check the scenario we just created. | 767 // Sanity check the scenario we just created. |
| 768 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 768 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 769 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 769 ASSERT_EQ(1u, root_layer()->GetRenderSurface()->layer_list().size()); |
| 770 ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 770 ASSERT_EQ(456, root_layer()->GetRenderSurface()->layer_list().at(0)->id()); |
| 771 | 771 |
| 772 // Hit testing for a point outside the layer should return a null pointer. | 772 // Hit testing for a point outside the layer should return a null pointer. |
| 773 gfx::PointF test_point(69.f, 69.f); | 773 gfx::PointF test_point(69.f, 69.f); |
| 774 LayerImpl* result_layer = | 774 LayerImpl* result_layer = |
| 775 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 775 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 776 EXPECT_FALSE(result_layer); | 776 EXPECT_FALSE(result_layer); |
| 777 | 777 |
| 778 test_point = gfx::PointF(91.f, 91.f); | 778 test_point = gfx::PointF(91.f, 91.f); |
| 779 result_layer = | 779 result_layer = |
| 780 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 780 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 | 840 |
| 841 host_impl().SetViewportSize(root->bounds()); | 841 host_impl().SetViewportSize(root->bounds()); |
| 842 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 842 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 843 | 843 |
| 844 // Sanity check the scenario we just created. | 844 // Sanity check the scenario we just created. |
| 845 ASSERT_TRUE(child1); | 845 ASSERT_TRUE(child1); |
| 846 ASSERT_TRUE(child2); | 846 ASSERT_TRUE(child2); |
| 847 ASSERT_TRUE(grand_child1); | 847 ASSERT_TRUE(grand_child1); |
| 848 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 848 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 849 | 849 |
| 850 RenderSurfaceImpl* root_render_surface = root->render_surface(); | 850 RenderSurfaceImpl* root_render_surface = root->GetRenderSurface(); |
| 851 ASSERT_EQ(4u, root_render_surface->layer_list().size()); | 851 ASSERT_EQ(4u, root_render_surface->layer_list().size()); |
| 852 ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id()); // root layer | 852 ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id()); // root layer |
| 853 ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id()); // child1 | 853 ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id()); // child1 |
| 854 ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id()); // grand_child1 | 854 ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id()); // grand_child1 |
| 855 ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id()); // child2 | 855 ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id()); // child2 |
| 856 | 856 |
| 857 // Nothing overlaps the root at (1, 1), so hit testing there should find | 857 // Nothing overlaps the root at (1, 1), so hit testing there should find |
| 858 // the root layer. | 858 // the root layer. |
| 859 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 859 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
| 860 LayerImpl* result_layer = | 860 LayerImpl* result_layer = |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 LayerImpl* child2 = root->test_properties()->children[1]; | 1187 LayerImpl* child2 = root->test_properties()->children[1]; |
| 1188 LayerImpl* grand_child1 = child1->test_properties()->children[0]; | 1188 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 1189 | 1189 |
| 1190 host_impl().SetViewportSize(root->bounds()); | 1190 host_impl().SetViewportSize(root->bounds()); |
| 1191 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1191 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1192 | 1192 |
| 1193 // Sanity check the scenario we just created. | 1193 // Sanity check the scenario we just created. |
| 1194 ASSERT_TRUE(child1); | 1194 ASSERT_TRUE(child1); |
| 1195 ASSERT_TRUE(child2); | 1195 ASSERT_TRUE(child2); |
| 1196 ASSERT_TRUE(grand_child1); | 1196 ASSERT_TRUE(grand_child1); |
| 1197 ASSERT_TRUE(child1->render_surface()); | 1197 ASSERT_TRUE(child1->GetRenderSurface()); |
| 1198 ASSERT_TRUE(child2->render_surface()); | 1198 ASSERT_TRUE(child2->GetRenderSurface()); |
| 1199 ASSERT_TRUE(grand_child1->render_surface()); | 1199 ASSERT_TRUE(grand_child1->GetRenderSurface()); |
| 1200 ASSERT_EQ(4u, RenderSurfaceLayerList().size()); | 1200 ASSERT_EQ(4u, RenderSurfaceLayerList().size()); |
| 1201 // The root surface has the root layer, and child1's and child2's render | 1201 // The root surface has the root layer, and child1's and child2's render |
| 1202 // surfaces. | 1202 // surfaces. |
| 1203 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); | 1203 ASSERT_EQ(3u, root->GetRenderSurface()->layer_list().size()); |
| 1204 // The child1 surface has the child1 layer and grand_child1's render surface. | 1204 // The child1 surface has the child1 layer and grand_child1's render surface. |
| 1205 ASSERT_EQ(2u, child1->render_surface()->layer_list().size()); | 1205 ASSERT_EQ(2u, child1->GetRenderSurface()->layer_list().size()); |
| 1206 ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); | 1206 ASSERT_EQ(1u, child2->GetRenderSurface()->layer_list().size()); |
| 1207 ASSERT_EQ(1u, grand_child1->render_surface()->layer_list().size()); | 1207 ASSERT_EQ(1u, grand_child1->GetRenderSurface()->layer_list().size()); |
| 1208 ASSERT_EQ(1, RenderSurfaceLayerList().at(0)->id()); // root layer | 1208 ASSERT_EQ(1, RenderSurfaceLayerList().at(0)->id()); // root layer |
| 1209 ASSERT_EQ(2, RenderSurfaceLayerList()[1]->id()); // child1 | 1209 ASSERT_EQ(2, RenderSurfaceLayerList()[1]->id()); // child1 |
| 1210 ASSERT_EQ(4, RenderSurfaceLayerList().at(2)->id()); // grand_child1 | 1210 ASSERT_EQ(4, RenderSurfaceLayerList().at(2)->id()); // grand_child1 |
| 1211 ASSERT_EQ(3, RenderSurfaceLayerList()[3]->id()); // child2 | 1211 ASSERT_EQ(3, RenderSurfaceLayerList()[3]->id()); // child2 |
| 1212 | 1212 |
| 1213 // Nothing overlaps the root at (1, 1), so hit testing there should find | 1213 // Nothing overlaps the root at (1, 1), so hit testing there should find |
| 1214 // the root layer. | 1214 // the root layer. |
| 1215 gfx::PointF test_point(1.f, 1.f); | 1215 gfx::PointF test_point(1.f, 1.f); |
| 1216 LayerImpl* result_layer = | 1216 LayerImpl* result_layer = |
| 1217 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1217 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 | 1263 |
| 1264 LayerImpl* root = root_layer(); | 1264 LayerImpl* root = root_layer(); |
| 1265 root->SetBounds(gfx::Size(100, 100)); | 1265 root->SetBounds(gfx::Size(100, 100)); |
| 1266 root->SetDrawsContent(true); | 1266 root->SetDrawsContent(true); |
| 1267 | 1267 |
| 1268 host_impl().SetViewportSize(root->bounds()); | 1268 host_impl().SetViewportSize(root->bounds()); |
| 1269 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1269 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1270 | 1270 |
| 1271 // Sanity check the scenario we just created. | 1271 // Sanity check the scenario we just created. |
| 1272 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1272 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1273 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1273 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1274 | 1274 |
| 1275 // Hit checking for any point should return a null pointer for a layer without | 1275 // Hit checking for any point should return a null pointer for a layer without |
| 1276 // any touch event handler regions. | 1276 // any touch event handler regions. |
| 1277 gfx::PointF test_point(11.f, 11.f); | 1277 gfx::PointF test_point(11.f, 11.f); |
| 1278 LayerImpl* result_layer = | 1278 LayerImpl* result_layer = |
| 1279 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1279 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1280 test_point); | 1280 test_point); |
| 1281 EXPECT_FALSE(result_layer); | 1281 EXPECT_FALSE(result_layer); |
| 1282 | 1282 |
| 1283 root->SetTouchEventHandlerRegion(touch_handler_region); | 1283 root->SetTouchEventHandlerRegion(touch_handler_region); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 // the entire layer as visible if the screen space transform is singular. This | 1347 // the entire layer as visible if the screen space transform is singular. This |
| 1348 // is not always true when we combine clips in target space because if the | 1348 // is not always true when we combine clips in target space because if the |
| 1349 // intersection of combined_clip in taret space with layer_rect projected to | 1349 // intersection of combined_clip in taret space with layer_rect projected to |
| 1350 // target space is empty, we set it to an empty rect. | 1350 // target space is empty, we set it to an empty rect. |
| 1351 bool skip_verify_visible_rect_calculations = true; | 1351 bool skip_verify_visible_rect_calculations = true; |
| 1352 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( | 1352 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree( |
| 1353 skip_verify_visible_rect_calculations); | 1353 skip_verify_visible_rect_calculations); |
| 1354 | 1354 |
| 1355 // Sanity check the scenario we just created. | 1355 // Sanity check the scenario we just created. |
| 1356 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1356 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1357 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1357 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1358 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); | 1358 ASSERT_FALSE(root->ScreenSpaceTransform().IsInvertible()); |
| 1359 | 1359 |
| 1360 // Hit checking any point should not hit the touch handler region on the | 1360 // Hit checking any point should not hit the touch handler region on the |
| 1361 // layer. If the invertible matrix is accidentally ignored and treated like an | 1361 // layer. If the invertible matrix is accidentally ignored and treated like an |
| 1362 // identity, then the hit testing will incorrectly hit the layer when it | 1362 // identity, then the hit testing will incorrectly hit the layer when it |
| 1363 // shouldn't. | 1363 // shouldn't. |
| 1364 gfx::PointF test_point(1.f, 1.f); | 1364 gfx::PointF test_point(1.f, 1.f); |
| 1365 LayerImpl* result_layer = | 1365 LayerImpl* result_layer = |
| 1366 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1366 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1367 test_point); | 1367 test_point); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 root->SetPosition(gfx::PointF(50.f, 50.f)); | 1414 root->SetPosition(gfx::PointF(50.f, 50.f)); |
| 1415 root->SetBounds(gfx::Size(100, 100)); | 1415 root->SetBounds(gfx::Size(100, 100)); |
| 1416 root->SetDrawsContent(true); | 1416 root->SetDrawsContent(true); |
| 1417 root->SetTouchEventHandlerRegion(touch_handler_region); | 1417 root->SetTouchEventHandlerRegion(touch_handler_region); |
| 1418 | 1418 |
| 1419 host_impl().SetViewportSize(root->bounds()); | 1419 host_impl().SetViewportSize(root->bounds()); |
| 1420 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1420 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1421 | 1421 |
| 1422 // Sanity check the scenario we just created. | 1422 // Sanity check the scenario we just created. |
| 1423 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1423 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1424 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1424 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1425 | 1425 |
| 1426 // Hit checking for a point outside the layer should return a null pointer. | 1426 // Hit checking for a point outside the layer should return a null pointer. |
| 1427 gfx::PointF test_point(49.f, 49.f); | 1427 gfx::PointF test_point(49.f, 49.f); |
| 1428 LayerImpl* result_layer = | 1428 LayerImpl* result_layer = |
| 1429 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1429 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1430 test_point); | 1430 test_point); |
| 1431 EXPECT_FALSE(result_layer); | 1431 EXPECT_FALSE(result_layer); |
| 1432 | 1432 |
| 1433 // Even though the layer has a touch handler region containing (101, 101), it | 1433 // Even though the layer has a touch handler region containing (101, 101), it |
| 1434 // should not be visible there since the root render surface would clamp it. | 1434 // 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 Loading... |
| 1499 host_impl().active_tree()->PushPageScaleFromMainThread( | 1499 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 1500 page_scale_factor, page_scale_factor, max_page_scale_factor); | 1500 page_scale_factor, page_scale_factor, max_page_scale_factor); |
| 1501 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1501 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1502 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1502 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1503 | 1503 |
| 1504 // Sanity check the scenario we just created. | 1504 // Sanity check the scenario we just created. |
| 1505 // The visible content rect for test_layer is actually 100x100, even though | 1505 // The visible content rect for test_layer is actually 100x100, even though |
| 1506 // its layout size is 50x50, positioned at 25x25. | 1506 // its layout size is 50x50, positioned at 25x25. |
| 1507 LayerImpl* test_layer = root->test_properties()->children[0]; | 1507 LayerImpl* test_layer = root->test_properties()->children[0]; |
| 1508 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1508 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1509 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1509 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1510 | 1510 |
| 1511 // Check whether the child layer fits into the root after scaled. | 1511 // Check whether the child layer fits into the root after scaled. |
| 1512 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); | 1512 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); |
| 1513 | 1513 |
| 1514 // Hit checking for a point outside the layer should return a null pointer | 1514 // Hit checking for a point outside the layer should return a null pointer |
| 1515 // (the root layer does not have a touch event handler, so it will not be | 1515 // (the root layer does not have a touch event handler, so it will not be |
| 1516 // tested either). | 1516 // tested either). |
| 1517 gfx::PointF test_point(76.f, 76.f); | 1517 gfx::PointF test_point(76.f, 76.f); |
| 1518 test_point = | 1518 test_point = |
| 1519 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1519 gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 child->SetTouchEventHandlerRegion(touch_handler_region); | 1626 child->SetTouchEventHandlerRegion(touch_handler_region); |
| 1627 clipping_layer->test_properties()->AddChild(std::move(child)); | 1627 clipping_layer->test_properties()->AddChild(std::move(child)); |
| 1628 root->test_properties()->AddChild(std::move(clipping_layer)); | 1628 root->test_properties()->AddChild(std::move(clipping_layer)); |
| 1629 } | 1629 } |
| 1630 | 1630 |
| 1631 host_impl().SetViewportSize(root->bounds()); | 1631 host_impl().SetViewportSize(root->bounds()); |
| 1632 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1632 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1633 | 1633 |
| 1634 // Sanity check the scenario we just created. | 1634 // Sanity check the scenario we just created. |
| 1635 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1635 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1636 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1636 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1637 ASSERT_EQ(456, root->render_surface()->layer_list().at(0)->id()); | 1637 ASSERT_EQ(456, root->GetRenderSurface()->layer_list().at(0)->id()); |
| 1638 | 1638 |
| 1639 // Hit checking for a point outside the layer should return a null pointer. | 1639 // Hit checking for a point outside the layer should return a null pointer. |
| 1640 // Despite the child layer being very large, it should be clipped to the root | 1640 // Despite the child layer being very large, it should be clipped to the root |
| 1641 // layer's bounds. | 1641 // layer's bounds. |
| 1642 gfx::PointF test_point(24.f, 24.f); | 1642 gfx::PointF test_point(24.f, 24.f); |
| 1643 LayerImpl* result_layer = | 1643 LayerImpl* result_layer = |
| 1644 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1644 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1645 test_point); | 1645 test_point); |
| 1646 EXPECT_FALSE(result_layer); | 1646 EXPECT_FALSE(result_layer); |
| 1647 | 1647 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 notouch_layer->SetBounds(gfx::Size(50, 50)); | 1779 notouch_layer->SetBounds(gfx::Size(50, 50)); |
| 1780 notouch_layer->SetDrawsContent(true); | 1780 notouch_layer->SetDrawsContent(true); |
| 1781 root->test_properties()->AddChild(std::move(notouch_layer)); | 1781 root->test_properties()->AddChild(std::move(notouch_layer)); |
| 1782 } | 1782 } |
| 1783 | 1783 |
| 1784 host_impl().SetViewportSize(root->bounds()); | 1784 host_impl().SetViewportSize(root->bounds()); |
| 1785 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1785 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1786 | 1786 |
| 1787 // Sanity check the scenario we just created. | 1787 // Sanity check the scenario we just created. |
| 1788 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1788 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1789 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 1789 ASSERT_EQ(2u, root->GetRenderSurface()->layer_list().size()); |
| 1790 ASSERT_EQ(123, root->render_surface()->layer_list().at(0)->id()); | 1790 ASSERT_EQ(123, root->GetRenderSurface()->layer_list().at(0)->id()); |
| 1791 ASSERT_EQ(1234, root->render_surface()->layer_list().at(1)->id()); | 1791 ASSERT_EQ(1234, root->GetRenderSurface()->layer_list().at(1)->id()); |
| 1792 | 1792 |
| 1793 gfx::PointF test_point(35.f, 35.f); | 1793 gfx::PointF test_point(35.f, 35.f); |
| 1794 LayerImpl* result_layer = | 1794 LayerImpl* result_layer = |
| 1795 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1795 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1796 test_point); | 1796 test_point); |
| 1797 | 1797 |
| 1798 // We should have passed through the no-touch layer and found the layer | 1798 // We should have passed through the no-touch layer and found the layer |
| 1799 // behind it. | 1799 // behind it. |
| 1800 EXPECT_TRUE(result_layer); | 1800 EXPECT_TRUE(result_layer); |
| 1801 | 1801 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1837 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
| 1838 root->test_properties()->AddChild(std::move(test_layer)); | 1838 root->test_properties()->AddChild(std::move(test_layer)); |
| 1839 } | 1839 } |
| 1840 host_impl().SetViewportSize(root->bounds()); | 1840 host_impl().SetViewportSize(root->bounds()); |
| 1841 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1841 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1842 | 1842 |
| 1843 LayerImpl* test_layer = root->test_properties()->children[0]; | 1843 LayerImpl* test_layer = root->test_properties()->children[0]; |
| 1844 // As test_layer doesn't draw content, the layer list of root's render surface | 1844 // As test_layer doesn't draw content, the layer list of root's render surface |
| 1845 // should contain only the root layer. | 1845 // should contain only the root layer. |
| 1846 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1846 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1847 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1847 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1848 | 1848 |
| 1849 // Hit testing for a point outside the test layer should return null pointer. | 1849 // Hit testing for a point outside the test layer should return null pointer. |
| 1850 // We also implicitly check that the updated screen space transform of a layer | 1850 // We also implicitly check that the updated screen space transform of a layer |
| 1851 // that is not in drawn render surface layer list (test_layer) is used during | 1851 // that is not in drawn render surface layer list (test_layer) is used during |
| 1852 // hit testing (becuase the point is inside test_layer with respect to the old | 1852 // hit testing (becuase the point is inside test_layer with respect to the old |
| 1853 // screen space transform). | 1853 // screen space transform). |
| 1854 gfx::PointF test_point(24.f, 24.f); | 1854 gfx::PointF test_point(24.f, 24.f); |
| 1855 test_layer->SetPosition(gfx::PointF(25.f, 25.f)); | 1855 test_layer->SetPosition(gfx::PointF(25.f, 25.f)); |
| 1856 gfx::Transform expected_screen_space_transform; | 1856 gfx::Transform expected_screen_space_transform; |
| 1857 expected_screen_space_transform.Translate(25.f, 25.f); | 1857 expected_screen_space_transform.Translate(25.f, 25.f); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { | 1895 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { |
| 1896 LayerImpl* root = root_layer(); | 1896 LayerImpl* root = root_layer(); |
| 1897 root->SetBounds(gfx::Size(100, 100)); | 1897 root->SetBounds(gfx::Size(100, 100)); |
| 1898 root->SetDrawsContent(true); | 1898 root->SetDrawsContent(true); |
| 1899 | 1899 |
| 1900 host_impl().SetViewportSize(root->bounds()); | 1900 host_impl().SetViewportSize(root->bounds()); |
| 1901 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1901 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1902 | 1902 |
| 1903 // Sanity check the scenario we just created. | 1903 // Sanity check the scenario we just created. |
| 1904 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1904 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1905 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); | 1905 ASSERT_EQ(1u, root->GetRenderSurface()->layer_list().size()); |
| 1906 | 1906 |
| 1907 LayerSelection input; | 1907 LayerSelection input; |
| 1908 | 1908 |
| 1909 input.start.type = gfx::SelectionBound::LEFT; | 1909 input.start.type = gfx::SelectionBound::LEFT; |
| 1910 input.start.edge_top = gfx::Point(10, 10); | 1910 input.start.edge_top = gfx::Point(10, 10); |
| 1911 input.start.edge_bottom = gfx::Point(10, 20); | 1911 input.start.edge_bottom = gfx::Point(10, 20); |
| 1912 input.start.layer_id = root->id(); | 1912 input.start.layer_id = root->id(); |
| 1913 | 1913 |
| 1914 input.end.type = gfx::SelectionBound::RIGHT; | 1914 input.end.type = gfx::SelectionBound::RIGHT; |
| 1915 input.end.edge_top = gfx::Point(50, 10); | 1915 input.end.edge_top = gfx::Point(50, 10); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 auto weak_promise = promise->AsWeakPtr(); | 2401 auto weak_promise = promise->AsWeakPtr(); |
| 2402 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); | 2402 host_impl().active_tree()->QueueSwapPromise(std::move(promise)); |
| 2403 host_impl().active_tree()->BreakSwapPromises( | 2403 host_impl().active_tree()->BreakSwapPromises( |
| 2404 SwapPromise::DidNotSwapReason::SWAP_FAILS); | 2404 SwapPromise::DidNotSwapReason::SWAP_FAILS); |
| 2405 EXPECT_FALSE(weak_promise); | 2405 EXPECT_FALSE(weak_promise); |
| 2406 } | 2406 } |
| 2407 } | 2407 } |
| 2408 | 2408 |
| 2409 } // namespace | 2409 } // namespace |
| 2410 } // namespace cc | 2410 } // namespace cc |
| OLD | NEW |