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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, | 748 SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, |
749 transform_origin, position, bounds, true, | 749 transform_origin, position, bounds, true, |
750 false, false); | 750 false, false); |
751 grand_child1->SetDrawsContent(true); | 751 grand_child1->SetDrawsContent(true); |
752 | 752 |
753 child1->AddChild(grand_child1.Pass()); | 753 child1->AddChild(grand_child1.Pass()); |
754 root->AddChild(child1.Pass()); | 754 root->AddChild(child1.Pass()); |
755 root->AddChild(child2.Pass()); | 755 root->AddChild(child2.Pass()); |
756 } | 756 } |
757 | 757 |
758 LayerImpl* child1 = root->children()[0]; | 758 LayerImpl* child1 = root->children()[0].get(); |
759 LayerImpl* child2 = root->children()[1]; | 759 LayerImpl* child2 = root->children()[1].get(); |
760 LayerImpl* grand_child1 = child1->children()[0]; | 760 LayerImpl* grand_child1 = child1->children()[0].get(); |
761 | 761 |
762 host_impl().SetViewportSize(root->bounds()); | 762 host_impl().SetViewportSize(root->bounds()); |
763 host_impl().active_tree()->SetRootLayer(root.Pass()); | 763 host_impl().active_tree()->SetRootLayer(root.Pass()); |
764 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 764 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
765 | 765 |
766 // Sanity check the scenario we just created. | 766 // Sanity check the scenario we just created. |
767 ASSERT_TRUE(child1); | 767 ASSERT_TRUE(child1); |
768 ASSERT_TRUE(child2); | 768 ASSERT_TRUE(child2); |
769 ASSERT_TRUE(grand_child1); | 769 ASSERT_TRUE(grand_child1); |
770 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 770 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 transform_origin, position, bounds, true, | 976 transform_origin, position, bounds, true, |
977 false, false); | 977 false, false); |
978 grand_child1->SetDrawsContent(true); | 978 grand_child1->SetDrawsContent(true); |
979 grand_child1->SetShouldFlattenTransform(false); | 979 grand_child1->SetShouldFlattenTransform(false); |
980 | 980 |
981 child1->AddChild(grand_child1.Pass()); | 981 child1->AddChild(grand_child1.Pass()); |
982 root->AddChild(child1.Pass()); | 982 root->AddChild(child1.Pass()); |
983 root->AddChild(child2.Pass()); | 983 root->AddChild(child2.Pass()); |
984 } | 984 } |
985 | 985 |
986 LayerImpl* child1 = root->children()[0]; | 986 LayerImpl* child1 = root->children()[0].get(); |
987 LayerImpl* child2 = root->children()[1]; | 987 LayerImpl* child2 = root->children()[1].get(); |
988 LayerImpl* grand_child1 = child1->children()[0]; | 988 LayerImpl* grand_child1 = child1->children()[0].get(); |
989 | 989 |
990 host_impl().SetViewportSize(root->bounds()); | 990 host_impl().SetViewportSize(root->bounds()); |
991 host_impl().active_tree()->SetRootLayer(root.Pass()); | 991 host_impl().active_tree()->SetRootLayer(root.Pass()); |
992 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 992 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
993 | 993 |
994 // Sanity check the scenario we just created. | 994 // Sanity check the scenario we just created. |
995 ASSERT_TRUE(child1); | 995 ASSERT_TRUE(child1); |
996 ASSERT_TRUE(child2); | 996 ASSERT_TRUE(child2); |
997 ASSERT_TRUE(grand_child1); | 997 ASSERT_TRUE(grand_child1); |
998 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 998 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 transform_origin, position, bounds, true, | 1208 transform_origin, position, bounds, true, |
1209 false, false); | 1209 false, false); |
1210 grand_child1->SetDrawsContent(true); | 1210 grand_child1->SetDrawsContent(true); |
1211 grand_child1->SetHasRenderSurface(true); | 1211 grand_child1->SetHasRenderSurface(true); |
1212 | 1212 |
1213 child1->AddChild(grand_child1.Pass()); | 1213 child1->AddChild(grand_child1.Pass()); |
1214 root->AddChild(child1.Pass()); | 1214 root->AddChild(child1.Pass()); |
1215 root->AddChild(child2.Pass()); | 1215 root->AddChild(child2.Pass()); |
1216 } | 1216 } |
1217 | 1217 |
1218 LayerImpl* child1 = root->children()[0]; | 1218 LayerImpl* child1 = root->children()[0].get(); |
1219 LayerImpl* child2 = root->children()[1]; | 1219 LayerImpl* child2 = root->children()[1].get(); |
1220 LayerImpl* grand_child1 = child1->children()[0]; | 1220 LayerImpl* grand_child1 = child1->children()[0].get(); |
1221 | 1221 |
1222 host_impl().SetViewportSize(root->bounds()); | 1222 host_impl().SetViewportSize(root->bounds()); |
1223 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1223 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1224 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1224 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1225 | 1225 |
1226 // Sanity check the scenario we just created. | 1226 // Sanity check the scenario we just created. |
1227 ASSERT_TRUE(child1); | 1227 ASSERT_TRUE(child1); |
1228 ASSERT_TRUE(child2); | 1228 ASSERT_TRUE(child2); |
1229 ASSERT_TRUE(grand_child1); | 1229 ASSERT_TRUE(grand_child1); |
1230 ASSERT_TRUE(child1->render_surface()); | 1230 ASSERT_TRUE(child1->render_surface()); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1551 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
1552 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1552 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1553 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1553 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
1554 Layer::INVALID_ID); | 1554 Layer::INVALID_ID); |
1555 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1555 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1556 | 1556 |
1557 // Sanity check the scenario we just created. | 1557 // Sanity check the scenario we just created. |
1558 // The visible content rect for test_layer is actually 100x100, even though | 1558 // The visible content rect for test_layer is actually 100x100, even though |
1559 // its layout size is 50x50, positioned at 25x25. | 1559 // its layout size is 50x50, positioned at 25x25. |
1560 LayerImpl* test_layer = | 1560 LayerImpl* test_layer = |
1561 host_impl().active_tree()->root_layer()->children()[0]; | 1561 host_impl().active_tree()->root_layer()->children()[0].get(); |
1562 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1562 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1563 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1563 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1564 | 1564 |
1565 // Check whether the child layer fits into the root after scaled. | 1565 // Check whether the child layer fits into the root after scaled. |
1566 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); | 1566 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); |
1567 | 1567 |
1568 // Hit checking for a point outside the layer should return a null pointer | 1568 // Hit checking for a point outside the layer should return a null pointer |
1569 // (the root layer does not have a touch event handler, so it will not be | 1569 // (the root layer does not have a touch event handler, so it will not be |
1570 // tested either). | 1570 // tested either). |
1571 gfx::PointF test_point(76.f, 76.f); | 1571 gfx::PointF test_point(76.f, 76.f); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 | 1843 |
1844 test_layer->SetDrawsContent(false); | 1844 test_layer->SetDrawsContent(false); |
1845 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1845 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
1846 root->AddChild(test_layer.Pass()); | 1846 root->AddChild(test_layer.Pass()); |
1847 } | 1847 } |
1848 host_impl().SetViewportSize(root->bounds()); | 1848 host_impl().SetViewportSize(root->bounds()); |
1849 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1849 host_impl().active_tree()->SetRootLayer(root.Pass()); |
1850 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1850 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
1851 | 1851 |
1852 LayerImpl* test_layer = | 1852 LayerImpl* test_layer = |
1853 host_impl().active_tree()->root_layer()->children()[0]; | 1853 host_impl().active_tree()->root_layer()->children()[0].get(); |
1854 // As test_layer doesn't draw content, the layer list of root's render surface | 1854 // As test_layer doesn't draw content, the layer list of root's render surface |
1855 // should contain only the root layer. | 1855 // should contain only the root layer. |
1856 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1856 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); |
1857 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1857 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); |
1858 | 1858 |
1859 // Hit testing for a point outside the test layer should return null pointer. | 1859 // Hit testing for a point outside the test layer should return null pointer. |
1860 // We also implicitly check that the updated screen space transform of a layer | 1860 // We also implicitly check that the updated screen space transform of a layer |
1861 // that is not in drawn render surface layer list (test_layer) is used during | 1861 // that is not in drawn render surface layer list (test_layer) is used during |
1862 // hit testing (becuase the point is inside test_layer with respect to the old | 1862 // hit testing (becuase the point is inside test_layer with respect to the old |
1863 // screen space transform). | 1863 // screen space transform). |
(...skipping 10 matching lines...) Expand all Loading... |
1874 EXPECT_FALSE(result_layer); | 1874 EXPECT_FALSE(result_layer); |
1875 EXPECT_FALSE(test_layer->IsDrawnRenderSurfaceLayerListMember()); | 1875 EXPECT_FALSE(test_layer->IsDrawnRenderSurfaceLayerListMember()); |
1876 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1876 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1877 expected_screen_space_transform, | 1877 expected_screen_space_transform, |
1878 ScreenSpaceTransformFromPropertyTrees( | 1878 ScreenSpaceTransformFromPropertyTrees( |
1879 test_layer, | 1879 test_layer, |
1880 host_impl().active_tree()->property_trees()->transform_tree)); | 1880 host_impl().active_tree()->property_trees()->transform_tree)); |
1881 | 1881 |
1882 // We change the position of the test layer such that the test point is now | 1882 // We change the position of the test layer such that the test point is now |
1883 // inside the test_layer. | 1883 // inside the test_layer. |
1884 test_layer = host_impl().active_tree()->root_layer()->children()[0]; | 1884 test_layer = host_impl().active_tree()->root_layer()->children()[0].get(); |
1885 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); | 1885 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
1886 expected_screen_space_transform.MakeIdentity(); | 1886 expected_screen_space_transform.MakeIdentity(); |
1887 expected_screen_space_transform.Translate(10.f, 10.f); | 1887 expected_screen_space_transform.Translate(10.f, 10.f); |
1888 | 1888 |
1889 host_impl().active_tree()->property_trees()->needs_rebuild = true; | 1889 host_impl().active_tree()->property_trees()->needs_rebuild = true; |
1890 host_impl().active_tree()->BuildPropertyTreesForTesting(); | 1890 host_impl().active_tree()->BuildPropertyTreesForTesting(); |
1891 result_layer = | 1891 result_layer = |
1892 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1892 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( |
1893 test_point); | 1893 test_point); |
1894 ASSERT_TRUE(result_layer); | 1894 ASSERT_TRUE(result_layer); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2232 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
2233 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2233 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
2234 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2234 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
2235 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2235 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
2236 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2236 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
2237 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2237 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
2238 } | 2238 } |
2239 | 2239 |
2240 } // namespace | 2240 } // namespace |
2241 } // namespace cc | 2241 } // namespace cc |
OLD | NEW |