| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 gfx::PointF(), gfx::Size(10, 10), true, false, | 961 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 962 true); | 962 true); |
| 963 SetLayerPropertiesForTesting(grand_child, rotation_about_y_axis, | 963 SetLayerPropertiesForTesting(grand_child, rotation_about_y_axis, |
| 964 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | 964 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), |
| 965 true, false, false); | 965 true, false, false); |
| 966 SetLayerPropertiesForTesting(great_grand_child, identity_matrix, | 966 SetLayerPropertiesForTesting(great_grand_child, identity_matrix, |
| 967 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | 967 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), |
| 968 true, false, false); | 968 true, false, false); |
| 969 | 969 |
| 970 // No layers in this test should preserve 3d. | 970 // No layers in this test should preserve 3d. |
| 971 ASSERT_TRUE(root->should_flatten_transform()); | 971 ASSERT_TRUE(root->test_properties()->should_flatten_transform); |
| 972 ASSERT_TRUE(child->should_flatten_transform()); | 972 ASSERT_TRUE(child->test_properties()->should_flatten_transform); |
| 973 ASSERT_TRUE(grand_child->should_flatten_transform()); | 973 ASSERT_TRUE(grand_child->test_properties()->should_flatten_transform); |
| 974 ASSERT_TRUE(great_grand_child->should_flatten_transform()); | 974 ASSERT_TRUE(great_grand_child->test_properties()->should_flatten_transform); |
| 975 | 975 |
| 976 gfx::Transform expected_child_draw_transform = rotation_about_y_axis; | 976 gfx::Transform expected_child_draw_transform = rotation_about_y_axis; |
| 977 gfx::Transform expected_child_screen_space_transform = rotation_about_y_axis; | 977 gfx::Transform expected_child_screen_space_transform = rotation_about_y_axis; |
| 978 gfx::Transform expected_grand_child_draw_transform = | 978 gfx::Transform expected_grand_child_draw_transform = |
| 979 rotation_about_y_axis; // draws onto child's render surface | 979 rotation_about_y_axis; // draws onto child's render surface |
| 980 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; | 980 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; |
| 981 flattened_rotation_about_y.FlattenTo2d(); | 981 flattened_rotation_about_y.FlattenTo2d(); |
| 982 gfx::Transform expected_grand_child_screen_space_transform = | 982 gfx::Transform expected_grand_child_screen_space_transform = |
| 983 flattened_rotation_about_y * rotation_about_y_axis; | 983 flattened_rotation_about_y * rotation_about_y_axis; |
| 984 gfx::Transform expected_great_grand_child_draw_transform = | 984 gfx::Transform expected_great_grand_child_draw_transform = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 1025 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 1026 gfx::PointF(), gfx::Size(200, 200), true, false, | 1026 gfx::PointF(), gfx::Size(200, 200), true, false, |
| 1027 true); | 1027 true); |
| 1028 SetLayerPropertiesForTesting(child, child_transform, gfx::Point3F(), | 1028 SetLayerPropertiesForTesting(child, child_transform, gfx::Point3F(), |
| 1029 gfx::PointF(), gfx::Size(10, 10), true, false, | 1029 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1030 false); | 1030 false); |
| 1031 SetLayerPropertiesForTesting(grand_child, grand_child_transform, | 1031 SetLayerPropertiesForTesting(grand_child, grand_child_transform, |
| 1032 gfx::Point3F(), gfx::PointF(), | 1032 gfx::Point3F(), gfx::PointF(), |
| 1033 gfx::Size(100, 100), true, false, false); | 1033 gfx::Size(100, 100), true, false, false); |
| 1034 | 1034 |
| 1035 grand_child->SetShouldFlattenTransform(false); | 1035 grand_child->test_properties()->should_flatten_transform = false; |
| 1036 grand_child->SetDrawsContent(true); | 1036 grand_child->SetDrawsContent(true); |
| 1037 | 1037 |
| 1038 ExecuteCalculateDrawProperties(root); | 1038 ExecuteCalculateDrawProperties(root); |
| 1039 | 1039 |
| 1040 // Mapping grand_child's bounds to target space produces a non-empty rect | 1040 // Mapping grand_child's bounds to target space produces a non-empty rect |
| 1041 // that is fully contained within the target's bounds, so grand_child should | 1041 // that is fully contained within the target's bounds, so grand_child should |
| 1042 // be considered fully visible. | 1042 // be considered fully visible. |
| 1043 EXPECT_EQ(gfx::Rect(grand_child->bounds()), | 1043 EXPECT_EQ(gfx::Rect(grand_child->bounds()), |
| 1044 grand_child->visible_layer_rect()); | 1044 grand_child->visible_layer_rect()); |
| 1045 } | 1045 } |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 SetLayerPropertiesForTesting(parent, rotation_about_y_axis, gfx::Point3F(), | 1635 SetLayerPropertiesForTesting(parent, rotation_about_y_axis, gfx::Point3F(), |
| 1636 gfx::PointF(), gfx::Size(10, 10), true, false, | 1636 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1637 true); | 1637 true); |
| 1638 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 1638 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 1639 gfx::PointF(), gfx::Size(10, 10), true, false, | 1639 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1640 false); | 1640 false); |
| 1641 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 1641 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
| 1642 gfx::PointF(), gfx::Size(10, 10), true, false, | 1642 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1643 false); | 1643 false); |
| 1644 | 1644 |
| 1645 grand_child->SetShouldFlattenTransform(false); | 1645 grand_child->test_properties()->should_flatten_transform = false; |
| 1646 | 1646 |
| 1647 // Only grand_child should preserve 3d. | 1647 // Only grand_child should preserve 3d. |
| 1648 EXPECT_TRUE(root->should_flatten_transform()); | 1648 EXPECT_TRUE(root->test_properties()->should_flatten_transform); |
| 1649 EXPECT_TRUE(parent->should_flatten_transform()); | 1649 EXPECT_TRUE(parent->test_properties()->should_flatten_transform); |
| 1650 EXPECT_TRUE(child->should_flatten_transform()); | 1650 EXPECT_TRUE(child->test_properties()->should_flatten_transform); |
| 1651 EXPECT_FALSE(grand_child->should_flatten_transform()); | 1651 EXPECT_FALSE(grand_child->test_properties()->should_flatten_transform); |
| 1652 | 1652 |
| 1653 gfx::Transform expected_child_draw_transform = identity_matrix; | 1653 gfx::Transform expected_child_draw_transform = identity_matrix; |
| 1654 gfx::Transform expected_grand_child_draw_transform = identity_matrix; | 1654 gfx::Transform expected_grand_child_draw_transform = identity_matrix; |
| 1655 | 1655 |
| 1656 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; | 1656 gfx::Transform flattened_rotation_about_y = rotation_about_y_axis; |
| 1657 flattened_rotation_about_y.FlattenTo2d(); | 1657 flattened_rotation_about_y.FlattenTo2d(); |
| 1658 | 1658 |
| 1659 ExecuteCalculateDrawProperties(root); | 1659 ExecuteCalculateDrawProperties(root); |
| 1660 | 1660 |
| 1661 EXPECT_TRUE(parent->render_surface()); | 1661 EXPECT_TRUE(parent->render_surface()); |
| (...skipping 4792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6454 SetLayerPropertiesForTesting(render_surface2, identity_transform, | 6454 SetLayerPropertiesForTesting(render_surface2, identity_transform, |
| 6455 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 6455 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 6456 false, true, true); | 6456 false, true, true); |
| 6457 SetLayerPropertiesForTesting(child1, identity_transform, gfx::Point3F(), | 6457 SetLayerPropertiesForTesting(child1, identity_transform, gfx::Point3F(), |
| 6458 gfx::PointF(), gfx::Size(20, 20), true, false, | 6458 gfx::PointF(), gfx::Size(20, 20), true, false, |
| 6459 false); | 6459 false); |
| 6460 SetLayerPropertiesForTesting(child2, identity_transform, gfx::Point3F(), | 6460 SetLayerPropertiesForTesting(child2, identity_transform, gfx::Point3F(), |
| 6461 gfx::PointF(), gfx::Size(20, 20), true, false, | 6461 gfx::PointF(), gfx::Size(20, 20), true, false, |
| 6462 false); | 6462 false); |
| 6463 | 6463 |
| 6464 root->SetShouldFlattenTransform(false); | 6464 root->test_properties()->should_flatten_transform = false; |
| 6465 root->Set3dSortingContextId(1); | 6465 root->Set3dSortingContextId(1); |
| 6466 back_facing->Set3dSortingContextId(1); | 6466 back_facing->Set3dSortingContextId(1); |
| 6467 back_facing->SetShouldFlattenTransform(false); | 6467 back_facing->test_properties()->should_flatten_transform = false; |
| 6468 render_surface1->test_properties()->double_sided = false; | 6468 render_surface1->test_properties()->double_sided = false; |
| 6469 render_surface2->Set3dSortingContextId(2); | 6469 render_surface2->Set3dSortingContextId(2); |
| 6470 render_surface2->test_properties()->double_sided = false; | 6470 render_surface2->test_properties()->double_sided = false; |
| 6471 | 6471 |
| 6472 ExecuteCalculateDrawProperties(root); | 6472 ExecuteCalculateDrawProperties(root); |
| 6473 | 6473 |
| 6474 EXPECT_EQ(render_surface1->sorting_context_id(), root->sorting_context_id()); | 6474 EXPECT_EQ(render_surface1->sorting_context_id(), root->sorting_context_id()); |
| 6475 EXPECT_NE(render_surface2->sorting_context_id(), root->sorting_context_id()); | 6475 EXPECT_NE(render_surface2->sorting_context_id(), root->sorting_context_id()); |
| 6476 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); | 6476 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); |
| 6477 EXPECT_EQ(2u, render_surface_layer_list_impl() | 6477 EXPECT_EQ(2u, render_surface_layer_list_impl() |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6995 // | 6995 // |
| 6996 LayerImpl* root = root_layer(); | 6996 LayerImpl* root = root_layer(); |
| 6997 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 6997 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 6998 LayerImpl* fixed = AddChild<LayerImpl>(render_surface); | 6998 LayerImpl* fixed = AddChild<LayerImpl>(render_surface); |
| 6999 LayerImpl* child = AddChild<LayerImpl>(fixed); | 6999 LayerImpl* child = AddChild<LayerImpl>(fixed); |
| 7000 | 7000 |
| 7001 render_surface->SetDrawsContent(true); | 7001 render_surface->SetDrawsContent(true); |
| 7002 fixed->SetDrawsContent(true); | 7002 fixed->SetDrawsContent(true); |
| 7003 child->SetDrawsContent(true); | 7003 child->SetDrawsContent(true); |
| 7004 | 7004 |
| 7005 root->SetIsContainerForFixedPositionLayers(true); | |
| 7006 render_surface->test_properties()->force_render_surface = true; | 7005 render_surface->test_properties()->force_render_surface = true; |
| 7006 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 7007 | 7007 |
| 7008 LayerPositionConstraint constraint; | 7008 LayerPositionConstraint constraint; |
| 7009 constraint.set_is_fixed_position(true); | 7009 constraint.set_is_fixed_position(true); |
| 7010 fixed->SetPositionConstraint(constraint); | 7010 fixed->test_properties()->position_constraint = constraint; |
| 7011 | 7011 |
| 7012 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), | 7012 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), |
| 7013 gfx::PointF(), gfx::Size(50, 50), true, false); | 7013 gfx::PointF(), gfx::Size(50, 50), true, false); |
| 7014 SetLayerPropertiesForTesting(render_surface, gfx::Transform(), gfx::Point3F(), | 7014 SetLayerPropertiesForTesting(render_surface, gfx::Transform(), gfx::Point3F(), |
| 7015 gfx::PointF(7.f, 9.f), gfx::Size(50, 50), true, | 7015 gfx::PointF(7.f, 9.f), gfx::Size(50, 50), true, |
| 7016 false); | 7016 false); |
| 7017 SetLayerPropertiesForTesting(fixed, gfx::Transform(), gfx::Point3F(), | 7017 SetLayerPropertiesForTesting(fixed, gfx::Transform(), gfx::Point3F(), |
| 7018 gfx::PointF(10.f, 15.f), gfx::Size(50, 50), true, | 7018 gfx::PointF(10.f, 15.f), gfx::Size(50, 50), true, |
| 7019 false); | 7019 false); |
| 7020 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), | 7020 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7068 std::unique_ptr<LayerImpl> container = | 7068 std::unique_ptr<LayerImpl> container = |
| 7069 LayerImpl::Create(host_impl.active_tree(), 2); | 7069 LayerImpl::Create(host_impl.active_tree(), 2); |
| 7070 LayerImpl* container_layer = container.get(); | 7070 LayerImpl* container_layer = container.get(); |
| 7071 std::unique_ptr<LayerImpl> scroller = | 7071 std::unique_ptr<LayerImpl> scroller = |
| 7072 LayerImpl::Create(host_impl.active_tree(), 3); | 7072 LayerImpl::Create(host_impl.active_tree(), 3); |
| 7073 LayerImpl* scroll_layer = scroller.get(); | 7073 LayerImpl* scroll_layer = scroller.get(); |
| 7074 std::unique_ptr<LayerImpl> fixed = | 7074 std::unique_ptr<LayerImpl> fixed = |
| 7075 LayerImpl::Create(host_impl.active_tree(), 4); | 7075 LayerImpl::Create(host_impl.active_tree(), 4); |
| 7076 LayerImpl* fixed_layer = fixed.get(); | 7076 LayerImpl* fixed_layer = fixed.get(); |
| 7077 | 7077 |
| 7078 container->SetIsContainerForFixedPositionLayers(true); | 7078 container->test_properties()->is_container_for_fixed_position_layers = true; |
| 7079 | 7079 |
| 7080 LayerPositionConstraint constraint; | 7080 LayerPositionConstraint constraint; |
| 7081 constraint.set_is_fixed_position(true); | 7081 constraint.set_is_fixed_position(true); |
| 7082 fixed->SetPositionConstraint(constraint); | 7082 fixed->test_properties()->position_constraint = constraint; |
| 7083 | 7083 |
| 7084 scroller->SetScrollClipLayer(container->id()); | 7084 scroller->SetScrollClipLayer(container->id()); |
| 7085 | 7085 |
| 7086 gfx::Transform identity_transform; | 7086 gfx::Transform identity_transform; |
| 7087 gfx::Transform container_transform; | 7087 gfx::Transform container_transform; |
| 7088 container_transform.Translate3d(10.0, 20.0, 0.0); | 7088 container_transform.Translate3d(10.0, 20.0, 0.0); |
| 7089 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 7089 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
| 7090 | 7090 |
| 7091 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 7091 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
| 7092 gfx::PointF(), gfx::Size(50, 50), true, false, | 7092 gfx::PointF(), gfx::Size(50, 50), true, false, |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8409 gfx::PointF(), gfx::Size(50, 50), true, false, | 8409 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 8410 true); | 8410 true); |
| 8411 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8411 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
| 8412 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, | 8412 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, |
| 8413 false, false); | 8413 false, false); |
| 8414 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8414 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
| 8415 gfx::PointF(-1000, -1000), gfx::Size(50, 50), | 8415 gfx::PointF(-1000, -1000), gfx::Size(50, 50), |
| 8416 true, false, false); | 8416 true, false, false); |
| 8417 | 8417 |
| 8418 root->SetMasksToBounds(true); | 8418 root->SetMasksToBounds(true); |
| 8419 root->SetIsContainerForFixedPositionLayers(true); | 8419 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8420 LayerPositionConstraint constraint; | 8420 LayerPositionConstraint constraint; |
| 8421 constraint.set_is_fixed_position(true); | 8421 constraint.set_is_fixed_position(true); |
| 8422 grandchild->SetPositionConstraint(constraint); | 8422 grandchild->test_properties()->position_constraint = constraint; |
| 8423 grandchild->SetDrawsContent(true); | 8423 grandchild->SetDrawsContent(true); |
| 8424 | 8424 |
| 8425 root->SetIsContainerForFixedPositionLayers(true); | 8425 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8426 | 8426 |
| 8427 ExecuteCalculateDrawProperties(root); | 8427 ExecuteCalculateDrawProperties(root); |
| 8428 | 8428 |
| 8429 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); | 8429 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); |
| 8430 } | 8430 } |
| 8431 | 8431 |
| 8432 // Ensures that the property tree code accounts for offsets between fixed | 8432 // Ensures that the property tree code accounts for offsets between fixed |
| 8433 // position containers and their transform tree parents, when a fixed position | 8433 // position containers and their transform tree parents, when a fixed position |
| 8434 // layer's container is its layer tree parent, but this parent doesn't have its | 8434 // layer's container is its layer tree parent, but this parent doesn't have its |
| 8435 // own transform tree node. | 8435 // own transform tree node. |
| 8436 TEST_F(LayerTreeHostCommonTest, | 8436 TEST_F(LayerTreeHostCommonTest, |
| 8437 PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) { | 8437 PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) { |
| 8438 LayerImpl* root = root_layer(); | 8438 LayerImpl* root = root_layer(); |
| 8439 LayerImpl* child = AddChild<LayerImpl>(root); | 8439 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8440 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 8440 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8441 | 8441 |
| 8442 gfx::Transform identity_transform; | 8442 gfx::Transform identity_transform; |
| 8443 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 8443 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
| 8444 gfx::PointF(), gfx::Size(50, 50), true, false, | 8444 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 8445 true); | 8445 true); |
| 8446 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 8446 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), |
| 8447 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, | 8447 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, |
| 8448 false, false); | 8448 false, false); |
| 8449 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 8449 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), |
| 8450 gfx::PointF(-1000, -1000), gfx::Size(50, 50), | 8450 gfx::PointF(-1000, -1000), gfx::Size(50, 50), |
| 8451 true, false, false); | 8451 true, false, false); |
| 8452 | 8452 |
| 8453 root->SetMasksToBounds(true); | 8453 root->SetMasksToBounds(true); |
| 8454 child->SetIsContainerForFixedPositionLayers(true); | 8454 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 8455 LayerPositionConstraint constraint; | 8455 LayerPositionConstraint constraint; |
| 8456 constraint.set_is_fixed_position(true); | 8456 constraint.set_is_fixed_position(true); |
| 8457 grandchild->SetPositionConstraint(constraint); | 8457 grandchild->test_properties()->position_constraint = constraint; |
| 8458 grandchild->SetDrawsContent(true); | 8458 grandchild->SetDrawsContent(true); |
| 8459 | 8459 |
| 8460 root->SetIsContainerForFixedPositionLayers(true); | 8460 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8461 | 8461 |
| 8462 ExecuteCalculateDrawProperties(root); | 8462 ExecuteCalculateDrawProperties(root); |
| 8463 | 8463 |
| 8464 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); | 8464 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); |
| 8465 } | 8465 } |
| 8466 | 8466 |
| 8467 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { | 8467 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { |
| 8468 // In the following layer tree, the layer |box|'s render target is |surface|. | 8468 // In the following layer tree, the layer |box|'s render target is |surface|. |
| 8469 // |surface| also creates a transform node. We want to combine clips for |box| | 8469 // |surface| also creates a transform node. We want to combine clips for |box| |
| 8470 // in the space of its target (i.e., |surface|), not its target's target. This | 8470 // in the space of its target (i.e., |surface|), not its target's target. This |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8520 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) { | 8520 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) { |
| 8521 LayerImpl* root = root_layer(); | 8521 LayerImpl* root = root_layer(); |
| 8522 LayerImpl* frame_clip = AddChild<LayerImpl>(root); | 8522 LayerImpl* frame_clip = AddChild<LayerImpl>(root); |
| 8523 LayerImpl* fixed = AddChild<LayerImpl>(frame_clip); | 8523 LayerImpl* fixed = AddChild<LayerImpl>(frame_clip); |
| 8524 gfx::Transform identity; | 8524 gfx::Transform identity; |
| 8525 gfx::Transform translate_z; | 8525 gfx::Transform translate_z; |
| 8526 translate_z.Translate3d(0, 0, 10); | 8526 translate_z.Translate3d(0, 0, 10); |
| 8527 | 8527 |
| 8528 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8528 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
| 8529 gfx::Size(800, 800), true, false, true); | 8529 gfx::Size(800, 800), true, false, true); |
| 8530 root->SetIsContainerForFixedPositionLayers(true); | 8530 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8531 | 8531 |
| 8532 SetLayerPropertiesForTesting(frame_clip, translate_z, gfx::Point3F(), | 8532 SetLayerPropertiesForTesting(frame_clip, translate_z, gfx::Point3F(), |
| 8533 gfx::PointF(500, 100), gfx::Size(100, 100), true, | 8533 gfx::PointF(500, 100), gfx::Size(100, 100), true, |
| 8534 false, false); | 8534 false, false); |
| 8535 frame_clip->SetMasksToBounds(true); | 8535 frame_clip->SetMasksToBounds(true); |
| 8536 | 8536 |
| 8537 SetLayerPropertiesForTesting(fixed, identity, gfx::Point3F(), gfx::PointF(), | 8537 SetLayerPropertiesForTesting(fixed, identity, gfx::Point3F(), gfx::PointF(), |
| 8538 gfx::Size(1000, 1000), true, false, false); | 8538 gfx::Size(1000, 1000), true, false, false); |
| 8539 | 8539 |
| 8540 LayerPositionConstraint constraint; | 8540 LayerPositionConstraint constraint; |
| 8541 constraint.set_is_fixed_position(true); | 8541 constraint.set_is_fixed_position(true); |
| 8542 fixed->SetPositionConstraint(constraint); | 8542 fixed->test_properties()->position_constraint = constraint; |
| 8543 fixed->SetDrawsContent(true); | 8543 fixed->SetDrawsContent(true); |
| 8544 | 8544 |
| 8545 ExecuteCalculateDrawProperties(root); | 8545 ExecuteCalculateDrawProperties(root); |
| 8546 | 8546 |
| 8547 gfx::Rect expected(0, 0, 100, 100); | 8547 gfx::Rect expected(0, 0, 100, 100); |
| 8548 EXPECT_EQ(expected, fixed->visible_layer_rect()); | 8548 EXPECT_EQ(expected, fixed->visible_layer_rect()); |
| 8549 } | 8549 } |
| 8550 | 8550 |
| 8551 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) { | 8551 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) { |
| 8552 LayerImpl* root = root_layer(); | 8552 LayerImpl* root = root_layer(); |
| 8553 LayerImpl* frame_clip = AddChild<LayerImpl>(root); | 8553 LayerImpl* frame_clip = AddChild<LayerImpl>(root); |
| 8554 LayerImpl* scroller = AddChild<LayerImpl>(frame_clip); | 8554 LayerImpl* scroller = AddChild<LayerImpl>(frame_clip); |
| 8555 LayerImpl* fixed = AddChild<LayerImpl>(scroller); | 8555 LayerImpl* fixed = AddChild<LayerImpl>(scroller); |
| 8556 | 8556 |
| 8557 gfx::Transform identity; | 8557 gfx::Transform identity; |
| 8558 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8558 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
| 8559 gfx::Size(800, 800), true, false, true); | 8559 gfx::Size(800, 800), true, false, true); |
| 8560 SetLayerPropertiesForTesting(frame_clip, identity, gfx::Point3F(), | 8560 SetLayerPropertiesForTesting(frame_clip, identity, gfx::Point3F(), |
| 8561 gfx::PointF(500, 100), gfx::Size(100, 100), true, | 8561 gfx::PointF(500, 100), gfx::Size(100, 100), true, |
| 8562 false, false); | 8562 false, false); |
| 8563 SetLayerPropertiesForTesting(scroller, identity, gfx::Point3F(), | 8563 SetLayerPropertiesForTesting(scroller, identity, gfx::Point3F(), |
| 8564 gfx::PointF(), gfx::Size(1000, 1000), true, | 8564 gfx::PointF(), gfx::Size(1000, 1000), true, |
| 8565 false, false); | 8565 false, false); |
| 8566 SetLayerPropertiesForTesting(fixed, identity, gfx::Point3F(), | 8566 SetLayerPropertiesForTesting(fixed, identity, gfx::Point3F(), |
| 8567 gfx::PointF(100, 100), gfx::Size(50, 50), true, | 8567 gfx::PointF(100, 100), gfx::Size(50, 50), true, |
| 8568 false, true); | 8568 false, true); |
| 8569 | 8569 |
| 8570 root->SetIsContainerForFixedPositionLayers(true); | 8570 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8571 root->SetDrawsContent(true); | 8571 root->SetDrawsContent(true); |
| 8572 | 8572 |
| 8573 frame_clip->SetMasksToBounds(true); | 8573 frame_clip->SetMasksToBounds(true); |
| 8574 frame_clip->SetDrawsContent(true); | 8574 frame_clip->SetDrawsContent(true); |
| 8575 | 8575 |
| 8576 scroller->SetCurrentScrollOffset(gfx::ScrollOffset(100, 100)); | 8576 scroller->SetCurrentScrollOffset(gfx::ScrollOffset(100, 100)); |
| 8577 scroller->SetScrollClipLayer(frame_clip->id()); | 8577 scroller->SetScrollClipLayer(frame_clip->id()); |
| 8578 scroller->SetDrawsContent(true); | 8578 scroller->SetDrawsContent(true); |
| 8579 | 8579 |
| 8580 LayerPositionConstraint constraint; | 8580 LayerPositionConstraint constraint; |
| 8581 constraint.set_is_fixed_position(true); | 8581 constraint.set_is_fixed_position(true); |
| 8582 fixed->SetPositionConstraint(constraint); | 8582 fixed->test_properties()->position_constraint = constraint; |
| 8583 fixed->SetMasksToBounds(true); | 8583 fixed->SetMasksToBounds(true); |
| 8584 fixed->SetDrawsContent(true); | 8584 fixed->SetDrawsContent(true); |
| 8585 | 8585 |
| 8586 ExecuteCalculateDrawProperties(root); | 8586 ExecuteCalculateDrawProperties(root); |
| 8587 | 8587 |
| 8588 gfx::Rect expected(0, 0, 50, 50); | 8588 gfx::Rect expected(0, 0, 50, 50); |
| 8589 EXPECT_EQ(expected, fixed->visible_layer_rect()); | 8589 EXPECT_EQ(expected, fixed->visible_layer_rect()); |
| 8590 } | 8590 } |
| 8591 | 8591 |
| 8592 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { | 8592 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { |
| (...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10126 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10126 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10127 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10127 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10128 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10128 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10129 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10129 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10130 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10130 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10131 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10131 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10132 } | 10132 } |
| 10133 | 10133 |
| 10134 } // namespace | 10134 } // namespace |
| 10135 } // namespace cc | 10135 } // namespace cc |
| OLD | NEW |