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

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

Issue 1801853002: Transfer LayerImpl ownership to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more asan. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/tree_synchronizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 false, false); 876 false, false);
877 grand_child1->SetDrawsContent(true); 877 grand_child1->SetDrawsContent(true);
878 878
879 child1->AddChild(std::move(grand_child1)); 879 child1->AddChild(std::move(grand_child1));
880 root->AddChild(std::move(child1)); 880 root->AddChild(std::move(child1));
881 root->AddChild(std::move(child2)); 881 root->AddChild(std::move(child2));
882 882
883 ExecuteCalculateDrawProperties(root.get()); 883 ExecuteCalculateDrawProperties(root.get());
884 } 884 }
885 885
886 LayerImpl* child1 = root->children()[0].get(); 886 LayerImpl* child1 = root->children()[0];
887 LayerImpl* child2 = root->children()[1].get(); 887 LayerImpl* child2 = root->children()[1];
888 LayerImpl* grand_child1 = child1->children()[0].get(); 888 LayerImpl* grand_child1 = child1->children()[0];
889 889
890 host_impl().SetViewportSize(root->bounds()); 890 host_impl().SetViewportSize(root->bounds());
891 host_impl().active_tree()->SetRootLayer(std::move(root)); 891 host_impl().active_tree()->SetRootLayer(std::move(root));
892 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 892 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
893 893
894 // Sanity check the scenario we just created. 894 // Sanity check the scenario we just created.
895 ASSERT_TRUE(child1); 895 ASSERT_TRUE(child1);
896 ASSERT_TRUE(child2); 896 ASSERT_TRUE(child2);
897 ASSERT_TRUE(grand_child1); 897 ASSERT_TRUE(grand_child1);
898 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 898 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 transform_origin, position, bounds, true, 1104 transform_origin, position, bounds, true,
1105 false, false); 1105 false, false);
1106 grand_child1->SetDrawsContent(true); 1106 grand_child1->SetDrawsContent(true);
1107 grand_child1->SetShouldFlattenTransform(false); 1107 grand_child1->SetShouldFlattenTransform(false);
1108 1108
1109 child1->AddChild(std::move(grand_child1)); 1109 child1->AddChild(std::move(grand_child1));
1110 root->AddChild(std::move(child1)); 1110 root->AddChild(std::move(child1));
1111 root->AddChild(std::move(child2)); 1111 root->AddChild(std::move(child2));
1112 } 1112 }
1113 1113
1114 LayerImpl* child1 = root->children()[0].get(); 1114 LayerImpl* child1 = root->children()[0];
1115 LayerImpl* child2 = root->children()[1].get(); 1115 LayerImpl* child2 = root->children()[1];
1116 LayerImpl* grand_child1 = child1->children()[0].get(); 1116 LayerImpl* grand_child1 = child1->children()[0];
1117 1117
1118 host_impl().SetViewportSize(root->bounds()); 1118 host_impl().SetViewportSize(root->bounds());
1119 host_impl().active_tree()->SetRootLayer(std::move(root)); 1119 host_impl().active_tree()->SetRootLayer(std::move(root));
1120 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1120 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1121 1121
1122 // Sanity check the scenario we just created. 1122 // Sanity check the scenario we just created.
1123 ASSERT_TRUE(child1); 1123 ASSERT_TRUE(child1);
1124 ASSERT_TRUE(child2); 1124 ASSERT_TRUE(child2);
1125 ASSERT_TRUE(grand_child1); 1125 ASSERT_TRUE(grand_child1);
1126 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1126 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 grand_child1->SetDrawsContent(true); 1341 grand_child1->SetDrawsContent(true);
1342 grand_child1->SetForceRenderSurface(true); 1342 grand_child1->SetForceRenderSurface(true);
1343 1343
1344 child1->AddChild(std::move(grand_child1)); 1344 child1->AddChild(std::move(grand_child1));
1345 root->AddChild(std::move(child1)); 1345 root->AddChild(std::move(child1));
1346 root->AddChild(std::move(child2)); 1346 root->AddChild(std::move(child2));
1347 1347
1348 ExecuteCalculateDrawProperties(root.get()); 1348 ExecuteCalculateDrawProperties(root.get());
1349 } 1349 }
1350 1350
1351 LayerImpl* child1 = root->children()[0].get(); 1351 LayerImpl* child1 = root->children()[0];
1352 LayerImpl* child2 = root->children()[1].get(); 1352 LayerImpl* child2 = root->children()[1];
1353 LayerImpl* grand_child1 = child1->children()[0].get(); 1353 LayerImpl* grand_child1 = child1->children()[0];
1354 1354
1355 host_impl().SetViewportSize(root->bounds()); 1355 host_impl().SetViewportSize(root->bounds());
1356 host_impl().active_tree()->SetRootLayer(std::move(root)); 1356 host_impl().active_tree()->SetRootLayer(std::move(root));
1357 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1357 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1358 1358
1359 // Sanity check the scenario we just created. 1359 // Sanity check the scenario we just created.
1360 ASSERT_TRUE(child1); 1360 ASSERT_TRUE(child1);
1361 ASSERT_TRUE(child2); 1361 ASSERT_TRUE(child2);
1362 ASSERT_TRUE(grand_child1); 1362 ASSERT_TRUE(grand_child1);
1363 ASSERT_TRUE(child1->render_surface()); 1363 ASSERT_TRUE(child1->render_surface());
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 host_impl().active_tree()->BuildPropertyTreesForTesting(); 1685 host_impl().active_tree()->BuildPropertyTreesForTesting();
1686 host_impl().active_tree()->PushPageScaleFromMainThread( 1686 host_impl().active_tree()->PushPageScaleFromMainThread(
1687 page_scale_factor, page_scale_factor, max_page_scale_factor); 1687 page_scale_factor, page_scale_factor, max_page_scale_factor);
1688 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1688 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1689 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1689 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1690 1690
1691 // Sanity check the scenario we just created. 1691 // Sanity check the scenario we just created.
1692 // The visible content rect for test_layer is actually 100x100, even though 1692 // The visible content rect for test_layer is actually 100x100, even though
1693 // its layout size is 50x50, positioned at 25x25. 1693 // its layout size is 50x50, positioned at 25x25.
1694 LayerImpl* test_layer = 1694 LayerImpl* test_layer =
1695 host_impl().active_tree()->root_layer()->children()[0].get(); 1695 host_impl().active_tree()->root_layer()->children()[0];
1696 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1696 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
1697 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 1697 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
1698 1698
1699 // Check whether the child layer fits into the root after scaled. 1699 // Check whether the child layer fits into the root after scaled.
1700 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect()); 1700 EXPECT_EQ(gfx::Rect(test_layer->bounds()), test_layer->visible_layer_rect());
1701 1701
1702 // Hit checking for a point outside the layer should return a null pointer 1702 // Hit checking for a point outside the layer should return a null pointer
1703 // (the root layer does not have a touch event handler, so it will not be 1703 // (the root layer does not have a touch event handler, so it will not be
1704 // tested either). 1704 // tested either).
1705 gfx::PointF test_point(76.f, 76.f); 1705 gfx::PointF test_point(76.f, 76.f);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 1977
1978 test_layer->SetDrawsContent(false); 1978 test_layer->SetDrawsContent(false);
1979 test_layer->SetTouchEventHandlerRegion(touch_handler_region); 1979 test_layer->SetTouchEventHandlerRegion(touch_handler_region);
1980 root->AddChild(std::move(test_layer)); 1980 root->AddChild(std::move(test_layer));
1981 } 1981 }
1982 host_impl().SetViewportSize(root->bounds()); 1982 host_impl().SetViewportSize(root->bounds());
1983 host_impl().active_tree()->SetRootLayer(std::move(root)); 1983 host_impl().active_tree()->SetRootLayer(std::move(root));
1984 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1984 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
1985 1985
1986 LayerImpl* test_layer = 1986 LayerImpl* test_layer =
1987 host_impl().active_tree()->root_layer()->children()[0].get(); 1987 host_impl().active_tree()->root_layer()->children()[0];
1988 // As test_layer doesn't draw content, the layer list of root's render surface 1988 // As test_layer doesn't draw content, the layer list of root's render surface
1989 // should contain only the root layer. 1989 // should contain only the root layer.
1990 ASSERT_EQ(1u, RenderSurfaceLayerList().size()); 1990 ASSERT_EQ(1u, RenderSurfaceLayerList().size());
1991 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); 1991 ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
1992 1992
1993 // Hit testing for a point outside the test layer should return null pointer. 1993 // Hit testing for a point outside the test layer should return null pointer.
1994 // We also implicitly check that the updated screen space transform of a layer 1994 // We also implicitly check that the updated screen space transform of a layer
1995 // that is not in drawn render surface layer list (test_layer) is used during 1995 // that is not in drawn render surface layer list (test_layer) is used during
1996 // hit testing (becuase the point is inside test_layer with respect to the old 1996 // hit testing (becuase the point is inside test_layer with respect to the old
1997 // screen space transform). 1997 // screen space transform).
(...skipping 10 matching lines...) Expand all
2008 EXPECT_FALSE(result_layer); 2008 EXPECT_FALSE(result_layer);
2009 EXPECT_FALSE(test_layer->IsDrawnRenderSurfaceLayerListMember()); 2009 EXPECT_FALSE(test_layer->IsDrawnRenderSurfaceLayerListMember());
2010 EXPECT_TRANSFORMATION_MATRIX_EQ( 2010 EXPECT_TRANSFORMATION_MATRIX_EQ(
2011 expected_screen_space_transform, 2011 expected_screen_space_transform,
2012 draw_property_utils::ScreenSpaceTransform( 2012 draw_property_utils::ScreenSpaceTransform(
2013 test_layer, 2013 test_layer,
2014 host_impl().active_tree()->property_trees()->transform_tree)); 2014 host_impl().active_tree()->property_trees()->transform_tree));
2015 2015
2016 // We change the position of the test layer such that the test point is now 2016 // We change the position of the test layer such that the test point is now
2017 // inside the test_layer. 2017 // inside the test_layer.
2018 test_layer = host_impl().active_tree()->root_layer()->children()[0].get(); 2018 test_layer = host_impl().active_tree()->root_layer()->children()[0];
2019 test_layer->SetPosition(gfx::PointF(10.f, 10.f)); 2019 test_layer->SetPosition(gfx::PointF(10.f, 10.f));
2020 test_layer->NoteLayerPropertyChanged(); 2020 test_layer->NoteLayerPropertyChanged();
2021 expected_screen_space_transform.MakeIdentity(); 2021 expected_screen_space_transform.MakeIdentity();
2022 expected_screen_space_transform.Translate(10.f, 10.f); 2022 expected_screen_space_transform.Translate(10.f, 10.f);
2023 2023
2024 host_impl().active_tree()->property_trees()->needs_rebuild = true; 2024 host_impl().active_tree()->property_trees()->needs_rebuild = true;
2025 host_impl().active_tree()->BuildPropertyTreesForTesting(); 2025 host_impl().active_tree()->BuildPropertyTreesForTesting();
2026 result_layer = 2026 result_layer =
2027 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( 2027 host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion(
2028 test_point); 2028 test_point);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { 2377 TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) {
2378 host_impl().active_tree()->SetDeviceScaleFactor(1.f); 2378 host_impl().active_tree()->SetDeviceScaleFactor(1.f);
2379 host_impl().active_tree()->UpdateDrawProperties(false); 2379 host_impl().active_tree()->UpdateDrawProperties(false);
2380 EXPECT_FALSE(host_impl().active_tree()->needs_update_draw_properties()); 2380 EXPECT_FALSE(host_impl().active_tree()->needs_update_draw_properties());
2381 host_impl().active_tree()->SetDeviceScaleFactor(2.f); 2381 host_impl().active_tree()->SetDeviceScaleFactor(2.f);
2382 EXPECT_TRUE(host_impl().active_tree()->needs_update_draw_properties()); 2382 EXPECT_TRUE(host_impl().active_tree()->needs_update_draw_properties());
2383 } 2383 }
2384 2384
2385 } // namespace 2385 } // namespace
2386 } // namespace cc 2386 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/tree_synchronizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698