| 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 9726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9737 child->mask_layer()->ScreenSpaceTransform()); | 9737 child->mask_layer()->ScreenSpaceTransform()); |
| 9738 transform.Translate(10, 10); | 9738 transform.Translate(10, 10); |
| 9739 child->SetTransform(transform); | 9739 child->SetTransform(transform); |
| 9740 child->SetDrawsContent(true); | 9740 child->SetDrawsContent(true); |
| 9741 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9741 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9742 ExecuteCalculateDrawProperties(root); | 9742 ExecuteCalculateDrawProperties(root); |
| 9743 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9743 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 9744 child->mask_layer()->ScreenSpaceTransform()); | 9744 child->mask_layer()->ScreenSpaceTransform()); |
| 9745 } | 9745 } |
| 9746 | 9746 |
| 9747 TEST_F(LayerTreeHostCommonTest, |
| 9748 SublayerScaleWithTransformNodeBetweenTwoTargets) { |
| 9749 LayerImpl* root = root_layer(); |
| 9750 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9751 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); |
| 9752 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); |
| 9753 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); |
| 9754 const gfx::Transform identity_matrix; |
| 9755 test_layer->SetDrawsContent(true); |
| 9756 |
| 9757 gfx::Transform scale; |
| 9758 scale.Scale(2.f, 2.f); |
| 9759 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9760 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9761 true); |
| 9762 SetLayerPropertiesForTesting(render_surface1, scale, gfx::Point3F(), |
| 9763 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9764 true); |
| 9765 SetLayerPropertiesForTesting(between_targets, identity_matrix, gfx::Point3F(), |
| 9766 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9767 false); |
| 9768 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), |
| 9769 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9770 true); |
| 9771 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
| 9772 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9773 false); |
| 9774 // We want layer between the two targets to create a clip node and transform |
| 9775 // node but it shouldn't create a render surface. |
| 9776 between_targets->SetMasksToBounds(true); |
| 9777 between_targets->Set3dSortingContextId(2); |
| 9778 |
| 9779 ExecuteCalculateDrawProperties(root); |
| 9780 |
| 9781 TransformTree& tree = |
| 9782 root->layer_tree_impl()->property_trees()->transform_tree; |
| 9783 TransformNode* node = tree.Node(render_surface1->transform_tree_index()); |
| 9784 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9785 |
| 9786 node = tree.Node(between_targets->transform_tree_index()); |
| 9787 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
| 9788 |
| 9789 node = tree.Node(render_surface2->transform_tree_index()); |
| 9790 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9791 |
| 9792 EXPECT_EQ(gfx::Rect(15, 15), test_layer->visible_layer_rect()); |
| 9793 } |
| 9794 |
| 9747 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { | 9795 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { |
| 9748 LayerImpl* root = root_layer(); | 9796 LayerImpl* root = root_layer(); |
| 9749 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9797 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9750 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 9798 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| 9751 | 9799 |
| 9752 const gfx::Transform identity_matrix; | 9800 const gfx::Transform identity_matrix; |
| 9753 child->SetDrawsContent(true); | 9801 child->SetDrawsContent(true); |
| 9754 child->SetMasksToBounds(true); | 9802 child->SetMasksToBounds(true); |
| 9755 | 9803 |
| 9756 gfx::Transform large_transform; | 9804 gfx::Transform large_transform; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10018 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10066 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10019 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10067 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10020 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10068 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10021 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10069 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10022 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10070 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10023 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10071 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10024 } | 10072 } |
| 10025 | 10073 |
| 10026 } // namespace | 10074 } // namespace |
| 10027 } // namespace cc | 10075 } // namespace cc |
| OLD | NEW |