| 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 <set> | 10 #include <set> |
| (...skipping 9649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9660 child->mask_layer()->ScreenSpaceTransform()); | 9660 child->mask_layer()->ScreenSpaceTransform()); |
| 9661 transform.Translate(10, 10); | 9661 transform.Translate(10, 10); |
| 9662 child->SetTransform(transform); | 9662 child->SetTransform(transform); |
| 9663 child->SetDrawsContent(true); | 9663 child->SetDrawsContent(true); |
| 9664 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9664 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9665 ExecuteCalculateDrawProperties(root); | 9665 ExecuteCalculateDrawProperties(root); |
| 9666 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9666 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 9667 child->mask_layer()->ScreenSpaceTransform()); | 9667 child->mask_layer()->ScreenSpaceTransform()); |
| 9668 } | 9668 } |
| 9669 | 9669 |
| 9670 TEST_F(LayerTreeHostCommonTest, |
| 9671 SublayerScaleWithTransformNodeBetweenTwoTargets) { |
| 9672 LayerImpl* root = root_layer(); |
| 9673 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9674 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); |
| 9675 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); |
| 9676 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); |
| 9677 const gfx::Transform identity_matrix; |
| 9678 test_layer->SetDrawsContent(true); |
| 9679 |
| 9680 gfx::Transform scale; |
| 9681 scale.Scale(2.f, 2.f); |
| 9682 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9683 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9684 true); |
| 9685 SetLayerPropertiesForTesting(render_surface1, scale, gfx::Point3F(), |
| 9686 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9687 true); |
| 9688 SetLayerPropertiesForTesting(between_targets, identity_matrix, gfx::Point3F(), |
| 9689 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9690 false); |
| 9691 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), |
| 9692 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9693 true); |
| 9694 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
| 9695 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9696 false); |
| 9697 // We want layer between the two targets to create a clip node and transform |
| 9698 // node but it shouldn't create a render surface. |
| 9699 between_targets->SetMasksToBounds(true); |
| 9700 between_targets->Set3dSortingContextId(2); |
| 9701 |
| 9702 ExecuteCalculateDrawProperties(root); |
| 9703 |
| 9704 TransformTree& tree = |
| 9705 root->layer_tree_impl()->property_trees()->transform_tree; |
| 9706 TransformNode* node = tree.Node(render_surface1->transform_tree_index()); |
| 9707 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9708 |
| 9709 node = tree.Node(between_targets->transform_tree_index()); |
| 9710 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(1.f, 1.f)); |
| 9711 |
| 9712 node = tree.Node(render_surface2->transform_tree_index()); |
| 9713 EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9714 |
| 9715 EXPECT_EQ(gfx::Rect(15, 15), test_layer->visible_layer_rect()); |
| 9716 } |
| 9717 |
| 9670 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { | 9718 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { |
| 9671 LayerImpl* root = root_layer(); | 9719 LayerImpl* root = root_layer(); |
| 9672 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9720 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9673 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 9721 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| 9674 | 9722 |
| 9675 const gfx::Transform identity_matrix; | 9723 const gfx::Transform identity_matrix; |
| 9676 child->SetDrawsContent(true); | 9724 child->SetDrawsContent(true); |
| 9677 child->SetMasksToBounds(true); | 9725 child->SetMasksToBounds(true); |
| 9678 | 9726 |
| 9679 gfx::Transform large_transform; | 9727 gfx::Transform large_transform; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9941 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9989 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9942 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9990 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9943 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9991 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9944 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9992 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9945 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9993 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9946 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9994 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9947 } | 9995 } |
| 9948 | 9996 |
| 9949 } // namespace | 9997 } // namespace |
| 9950 } // namespace cc | 9998 } // namespace cc |
| OLD | NEW |