| 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/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 grand_child1->SetDrawsContent(true); | 890 grand_child1->SetDrawsContent(true); |
| 891 | 891 |
| 892 child1->AddChild(std::move(grand_child1)); | 892 child1->AddChild(std::move(grand_child1)); |
| 893 root->AddChild(std::move(child1)); | 893 root->AddChild(std::move(child1)); |
| 894 root->AddChild(std::move(child2)); | 894 root->AddChild(std::move(child2)); |
| 895 host_impl().active_tree()->SetRootLayer(std::move(root)); | 895 host_impl().active_tree()->SetRootLayer(std::move(root)); |
| 896 | 896 |
| 897 ExecuteCalculateDrawProperties(root_layer); | 897 ExecuteCalculateDrawProperties(root_layer); |
| 898 } | 898 } |
| 899 | 899 |
| 900 LayerImpl* child1 = root_layer->children()[0]; | 900 LayerImpl* child1 = root_layer->test_properties()->children[0]; |
| 901 LayerImpl* child2 = root_layer->children()[1]; | 901 LayerImpl* child2 = root_layer->test_properties()->children[1]; |
| 902 LayerImpl* grand_child1 = child1->children()[0]; | 902 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 903 | 903 |
| 904 host_impl().SetViewportSize(root_layer->bounds()); | 904 host_impl().SetViewportSize(root_layer->bounds()); |
| 905 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 905 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 906 | 906 |
| 907 // Sanity check the scenario we just created. | 907 // Sanity check the scenario we just created. |
| 908 ASSERT_TRUE(child1); | 908 ASSERT_TRUE(child1); |
| 909 ASSERT_TRUE(child2); | 909 ASSERT_TRUE(child2); |
| 910 ASSERT_TRUE(grand_child1); | 910 ASSERT_TRUE(grand_child1); |
| 911 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 911 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 912 | 912 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 transform_origin, position, bounds, true, | 1118 transform_origin, position, bounds, true, |
| 1119 false, false); | 1119 false, false); |
| 1120 grand_child1->SetDrawsContent(true); | 1120 grand_child1->SetDrawsContent(true); |
| 1121 grand_child1->test_properties()->should_flatten_transform = false; | 1121 grand_child1->test_properties()->should_flatten_transform = false; |
| 1122 | 1122 |
| 1123 child1->AddChild(std::move(grand_child1)); | 1123 child1->AddChild(std::move(grand_child1)); |
| 1124 root->AddChild(std::move(child1)); | 1124 root->AddChild(std::move(child1)); |
| 1125 root->AddChild(std::move(child2)); | 1125 root->AddChild(std::move(child2)); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 LayerImpl* child1 = root->children()[0]; | 1128 LayerImpl* child1 = root->test_properties()->children[0]; |
| 1129 LayerImpl* child2 = root->children()[1]; | 1129 LayerImpl* child2 = root->test_properties()->children[1]; |
| 1130 LayerImpl* grand_child1 = child1->children()[0]; | 1130 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 1131 | 1131 |
| 1132 host_impl().SetViewportSize(root->bounds()); | 1132 host_impl().SetViewportSize(root->bounds()); |
| 1133 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1133 host_impl().active_tree()->SetRootLayer(std::move(root)); |
| 1134 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1134 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1135 | 1135 |
| 1136 // Sanity check the scenario we just created. | 1136 // Sanity check the scenario we just created. |
| 1137 ASSERT_TRUE(child1); | 1137 ASSERT_TRUE(child1); |
| 1138 ASSERT_TRUE(child2); | 1138 ASSERT_TRUE(child2); |
| 1139 ASSERT_TRUE(grand_child1); | 1139 ASSERT_TRUE(grand_child1); |
| 1140 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1140 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 grand_child1->test_properties()->force_render_surface = true; | 1362 grand_child1->test_properties()->force_render_surface = true; |
| 1363 | 1363 |
| 1364 child1->AddChild(std::move(grand_child1)); | 1364 child1->AddChild(std::move(grand_child1)); |
| 1365 root->AddChild(std::move(child1)); | 1365 root->AddChild(std::move(child1)); |
| 1366 root->AddChild(std::move(child2)); | 1366 root->AddChild(std::move(child2)); |
| 1367 host_impl().active_tree()->SetRootLayer(std::move(root)); | 1367 host_impl().active_tree()->SetRootLayer(std::move(root)); |
| 1368 | 1368 |
| 1369 ExecuteCalculateDrawProperties(root_layer); | 1369 ExecuteCalculateDrawProperties(root_layer); |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 LayerImpl* child1 = root_layer->children()[0]; | 1372 LayerImpl* child1 = root_layer->test_properties()->children[0]; |
| 1373 LayerImpl* child2 = root_layer->children()[1]; | 1373 LayerImpl* child2 = root_layer->test_properties()->children[1]; |
| 1374 LayerImpl* grand_child1 = child1->children()[0]; | 1374 LayerImpl* grand_child1 = child1->test_properties()->children[0]; |
| 1375 | 1375 |
| 1376 host_impl().SetViewportSize(root_layer->bounds()); | 1376 host_impl().SetViewportSize(root_layer->bounds()); |
| 1377 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1377 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1378 | 1378 |
| 1379 // Sanity check the scenario we just created. | 1379 // Sanity check the scenario we just created. |
| 1380 ASSERT_TRUE(child1); | 1380 ASSERT_TRUE(child1); |
| 1381 ASSERT_TRUE(child2); | 1381 ASSERT_TRUE(child2); |
| 1382 ASSERT_TRUE(grand_child1); | 1382 ASSERT_TRUE(grand_child1); |
| 1383 ASSERT_TRUE(child1->render_surface()); | 1383 ASSERT_TRUE(child1->render_surface()); |
| 1384 ASSERT_TRUE(child2->render_surface()); | 1384 ASSERT_TRUE(child2->render_surface()); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 1706 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 1707 host_impl().active_tree()->PushPageScaleFromMainThread( | 1707 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 1708 page_scale_factor, page_scale_factor, max_page_scale_factor); | 1708 page_scale_factor, page_scale_factor, max_page_scale_factor); |
| 1709 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1709 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1710 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1710 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 1711 | 1711 |
| 1712 // Sanity check the scenario we just created. | 1712 // Sanity check the scenario we just created. |
| 1713 // The visible content rect for test_layer is actually 100x100, even though | 1713 // The visible content rect for test_layer is actually 100x100, even though |
| 1714 // its layout size is 50x50, positioned at 25x25. | 1714 // its layout size is 50x50, positioned at 25x25. |
| 1715 LayerImpl* test_layer = | 1715 LayerImpl* test_layer = |
| 1716 host_impl().active_tree()->root_layer()->children()[0]; | 1716 host_impl().active_tree()->root_layer()->test_properties()->children[0]; |
| 1717 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1717 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 1718 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1718 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 1719 | 1719 |
| 1720 // Check whether the child layer fits into the root after scaled. | 1720 // Check whether the child layer fits into the root after scaled. |
| 1721 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); | 1721 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); |
| 1722 | 1722 |
| 1723 // Hit checking for a point outside the layer should return a null pointer | 1723 // Hit checking for a point outside the layer should return a null pointer |
| 1724 // (the root layer does not have a touch event handler, so it will not be | 1724 // (the root layer does not have a touch event handler, so it will not be |
| 1725 // tested either). | 1725 // tested either). |
| 1726 gfx::PointF test_point(76.f, 76.f); | 1726 gfx::PointF test_point(76.f, 76.f); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 | 2089 |
| 2090 test_layer->SetDrawsContent(false); | 2090 test_layer->SetDrawsContent(false); |
| 2091 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 2091 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
| 2092 root->AddChild(std::move(test_layer)); | 2092 root->AddChild(std::move(test_layer)); |
| 2093 } | 2093 } |
| 2094 host_impl().SetViewportSize(root->bounds()); | 2094 host_impl().SetViewportSize(root->bounds()); |
| 2095 host_impl().active_tree()->SetRootLayer(std::move(root)); | 2095 host_impl().active_tree()->SetRootLayer(std::move(root)); |
| 2096 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2096 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 2097 | 2097 |
| 2098 LayerImpl* test_layer = | 2098 LayerImpl* test_layer = |
| 2099 host_impl().active_tree()->root_layer()->children()[0]; | 2099 host_impl().active_tree()->root_layer()->test_properties()->children[0]; |
| 2100 // As test_layer doesn't draw content, the layer list of root's render surface | 2100 // As test_layer doesn't draw content, the layer list of root's render surface |
| 2101 // should contain only the root layer. | 2101 // should contain only the root layer. |
| 2102 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 2102 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
| 2103 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 2103 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
| 2104 | 2104 |
| 2105 // Hit testing for a point outside the test layer should return null pointer. | 2105 // Hit testing for a point outside the test layer should return null pointer. |
| 2106 // We also implicitly check that the updated screen space transform of a layer | 2106 // We also implicitly check that the updated screen space transform of a layer |
| 2107 // that is not in drawn render surface layer list (test_layer) is used during | 2107 // that is not in drawn render surface layer list (test_layer) is used during |
| 2108 // hit testing (becuase the point is inside test_layer with respect to the old | 2108 // hit testing (becuase the point is inside test_layer with respect to the old |
| 2109 // screen space transform). | 2109 // screen space transform). |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2120 EXPECT_FALSE(result_layer); | 2120 EXPECT_FALSE(result_layer); |
| 2121 EXPECT_FALSE(test_layer->is_drawn_render_surface_layer_list_member()); | 2121 EXPECT_FALSE(test_layer->is_drawn_render_surface_layer_list_member()); |
| 2122 EXPECT_TRANSFORMATION_MATRIX_EQ( | 2122 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 2123 expected_screen_space_transform, | 2123 expected_screen_space_transform, |
| 2124 draw_property_utils::ScreenSpaceTransform( | 2124 draw_property_utils::ScreenSpaceTransform( |
| 2125 test_layer, | 2125 test_layer, |
| 2126 host_impl().active_tree()->property_trees()->transform_tree)); | 2126 host_impl().active_tree()->property_trees()->transform_tree)); |
| 2127 | 2127 |
| 2128 // We change the position of the test layer such that the test point is now | 2128 // We change the position of the test layer such that the test point is now |
| 2129 // inside the test_layer. | 2129 // inside the test_layer. |
| 2130 test_layer = host_impl().active_tree()->root_layer()->children()[0]; | 2130 test_layer = |
| 2131 host_impl().active_tree()->root_layer()->test_properties()->children[0]; |
| 2131 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 2132 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
| 2132 test_layer->NoteLayerPropertyChanged(); | 2133 test_layer->NoteLayerPropertyChanged(); |
| 2133 expected_screen_space_transform.MakeIdentity(); | 2134 expected_screen_space_transform.MakeIdentity(); |
| 2134 expected_screen_space_transform.Translate(10.f, 10.f); | 2135 expected_screen_space_transform.Translate(10.f, 10.f); |
| 2135 | 2136 |
| 2136 host_impl().active_tree()->property_trees()->needs_rebuild = true; | 2137 host_impl().active_tree()->property_trees()->needs_rebuild = true; |
| 2137 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 2138 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 2138 result_layer = | 2139 result_layer = |
| 2139 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 2140 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 2140 test_point); | 2141 test_point); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2478 LayerImpl::Create(host_impl().active_tree(), 1); | 2479 LayerImpl::Create(host_impl().active_tree(), 1); |
| 2479 EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); | 2480 EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); |
| 2480 } | 2481 } |
| 2481 | 2482 |
| 2482 TEST_F(LayerTreeImplTest, NumLayersSmallTree) { | 2483 TEST_F(LayerTreeImplTest, NumLayersSmallTree) { |
| 2483 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2484 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
| 2484 std::unique_ptr<LayerImpl> root = | 2485 std::unique_ptr<LayerImpl> root = |
| 2485 LayerImpl::Create(host_impl().active_tree(), 1); | 2486 LayerImpl::Create(host_impl().active_tree(), 1); |
| 2486 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2487 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
| 2487 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2488 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
| 2488 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2489 root->test_properties()->children[1]->AddChild( |
| 2490 LayerImpl::Create(host_impl().active_tree(), 4)); |
| 2489 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2491 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
| 2490 } | 2492 } |
| 2491 | 2493 |
| 2492 TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { | 2494 TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { |
| 2493 host_impl().active_tree()->SetDeviceScaleFactor(1.f); | 2495 host_impl().active_tree()->SetDeviceScaleFactor(1.f); |
| 2494 host_impl().active_tree()->UpdateDrawProperties(false); | 2496 host_impl().active_tree()->UpdateDrawProperties(false); |
| 2495 EXPECT_FALSE(host_impl().active_tree()->needs_update_draw_properties()); | 2497 EXPECT_FALSE(host_impl().active_tree()->needs_update_draw_properties()); |
| 2496 host_impl().active_tree()->SetDeviceScaleFactor(2.f); | 2498 host_impl().active_tree()->SetDeviceScaleFactor(2.f); |
| 2497 EXPECT_TRUE(host_impl().active_tree()->needs_update_draw_properties()); | 2499 EXPECT_TRUE(host_impl().active_tree()->needs_update_draw_properties()); |
| 2498 } | 2500 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2544 gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 2546 gfx::PointF test_point = gfx::PointF(1.f, 1.f); |
| 2545 LayerImpl* result_layer = | 2547 LayerImpl* result_layer = |
| 2546 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 2548 host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 2547 | 2549 |
| 2548 CHECK(result_layer); | 2550 CHECK(result_layer); |
| 2549 EXPECT_EQ(2, result_layer->id()); | 2551 EXPECT_EQ(2, result_layer->id()); |
| 2550 } | 2552 } |
| 2551 | 2553 |
| 2552 } // namespace | 2554 } // namespace |
| 2553 } // namespace cc | 2555 } // namespace cc |
| OLD | NEW |