| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/layer_position_constraint.h" | 5 #include "cc/layers/layer_position_constraint.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 LayerImpl::Create(host_impl_.active_tree(), 42); | 77 LayerImpl::Create(host_impl_.active_tree(), 42); |
| 78 scoped_ptr<LayerImpl> scroll_layer = | 78 scoped_ptr<LayerImpl> scroll_layer = |
| 79 LayerImpl::Create(host_impl_.active_tree(), 1); | 79 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 80 scoped_ptr<LayerImpl> child = | 80 scoped_ptr<LayerImpl> child = |
| 81 LayerImpl::Create(host_impl_.active_tree(), 2); | 81 LayerImpl::Create(host_impl_.active_tree(), 2); |
| 82 scoped_ptr<LayerImpl> grand_child = | 82 scoped_ptr<LayerImpl> grand_child = |
| 83 LayerImpl::Create(host_impl_.active_tree(), 3); | 83 LayerImpl::Create(host_impl_.active_tree(), 3); |
| 84 scoped_ptr<LayerImpl> great_grand_child = | 84 scoped_ptr<LayerImpl> great_grand_child = |
| 85 LayerImpl::Create(host_impl_.active_tree(), 4); | 85 LayerImpl::Create(host_impl_.active_tree(), 4); |
| 86 | 86 |
| 87 root->SetHasRenderSurface(true); |
| 87 gfx::Transform IdentityMatrix; | 88 gfx::Transform IdentityMatrix; |
| 88 gfx::Point3F transform_origin; | 89 gfx::Point3F transform_origin; |
| 89 gfx::PointF position; | 90 gfx::PointF position; |
| 90 gfx::Size bounds(200, 200); | 91 gfx::Size bounds(200, 200); |
| 91 gfx::Size clip_bounds(100, 100); | 92 gfx::Size clip_bounds(100, 100); |
| 92 SetLayerPropertiesForTesting(scroll_layer.get(), | 93 SetLayerPropertiesForTesting(scroll_layer.get(), |
| 93 IdentityMatrix, | 94 IdentityMatrix, |
| 94 transform_origin, | 95 transform_origin, |
| 95 position, | 96 position, |
| 96 bounds, | 97 bounds, |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 // This test checks for correct scroll compensation when the fixed-position | 593 // This test checks for correct scroll compensation when the fixed-position |
| 593 // container contributes to a different render surface than the fixed-position | 594 // container contributes to a different render surface than the fixed-position |
| 594 // layer. In this case, the surface draw transforms also have to be accounted | 595 // layer. In this case, the surface draw transforms also have to be accounted |
| 595 // for when checking the scroll delta. | 596 // for when checking the scroll delta. |
| 596 LayerImpl* child = scroll_->children()[0]; | 597 LayerImpl* child = scroll_->children()[0]; |
| 597 LayerImpl* grand_child = child->children()[0]; | 598 LayerImpl* grand_child = child->children()[0]; |
| 598 LayerImpl* great_grand_child = grand_child->children()[0]; | 599 LayerImpl* great_grand_child = grand_child->children()[0]; |
| 599 | 600 |
| 600 child->SetIsContainerForFixedPositionLayers(true); | 601 child->SetIsContainerForFixedPositionLayers(true); |
| 601 grand_child->SetPosition(gfx::PointF(8.f, 6.f)); | 602 grand_child->SetPosition(gfx::PointF(8.f, 6.f)); |
| 602 grand_child->SetForceRenderSurface(true); | 603 grand_child->SetHasRenderSurface(true); |
| 603 great_grand_child->SetPositionConstraint(fixed_to_top_left_); | 604 great_grand_child->SetPositionConstraint(fixed_to_top_left_); |
| 604 great_grand_child->SetDrawsContent(true); | 605 great_grand_child->SetDrawsContent(true); |
| 605 | 606 |
| 606 gfx::Transform rotation_about_z; | 607 gfx::Transform rotation_about_z; |
| 607 rotation_about_z.RotateAboutZAxis(90.0); | 608 rotation_about_z.RotateAboutZAxis(90.0); |
| 608 grand_child->SetTransform(rotation_about_z); | 609 grand_child->SetTransform(rotation_about_z); |
| 609 | 610 |
| 610 // Case 1: scroll delta of 0, 0 | 611 // Case 1: scroll delta of 0, 0 |
| 611 child->SetScrollDelta(gfx::Vector2d(0, 0)); | 612 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 612 ExecuteCalculateDrawProperties(root_.get()); | 613 ExecuteCalculateDrawProperties(root_.get()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 gfx::PointF(), | 733 gfx::PointF(), |
| 733 gfx::Size(100, 100), | 734 gfx::Size(100, 100), |
| 734 true); | 735 true); |
| 735 great_grand_child->AddChild(fixed_position_child.Pass()); | 736 great_grand_child->AddChild(fixed_position_child.Pass()); |
| 736 } | 737 } |
| 737 LayerImpl* fixed_position_child = great_grand_child->children()[0]; | 738 LayerImpl* fixed_position_child = great_grand_child->children()[0]; |
| 738 | 739 |
| 739 // Actually set up the scenario here. | 740 // Actually set up the scenario here. |
| 740 child->SetIsContainerForFixedPositionLayers(true); | 741 child->SetIsContainerForFixedPositionLayers(true); |
| 741 grand_child->SetPosition(gfx::PointF(8.f, 6.f)); | 742 grand_child->SetPosition(gfx::PointF(8.f, 6.f)); |
| 742 grand_child->SetForceRenderSurface(true); | 743 grand_child->SetHasRenderSurface(true); |
| 743 great_grand_child->SetPosition(gfx::PointF(40.f, 60.f)); | 744 great_grand_child->SetPosition(gfx::PointF(40.f, 60.f)); |
| 744 great_grand_child->SetForceRenderSurface(true); | 745 great_grand_child->SetHasRenderSurface(true); |
| 745 fixed_position_child->SetPositionConstraint(fixed_to_top_left_); | 746 fixed_position_child->SetPositionConstraint(fixed_to_top_left_); |
| 746 fixed_position_child->SetDrawsContent(true); | 747 fixed_position_child->SetDrawsContent(true); |
| 747 | 748 |
| 748 // The additional rotations, which are non-commutative with translations, help | 749 // The additional rotations, which are non-commutative with translations, help |
| 749 // to verify that we have correct order-of-operations in the final scroll | 750 // to verify that we have correct order-of-operations in the final scroll |
| 750 // compensation. Note that rotating about the center of the layer ensures we | 751 // compensation. Note that rotating about the center of the layer ensures we |
| 751 // do not accidentally clip away layers that we want to test. | 752 // do not accidentally clip away layers that we want to test. |
| 752 gfx::Transform rotation_about_z; | 753 gfx::Transform rotation_about_z; |
| 753 rotation_about_z.Translate(50.0, 50.0); | 754 rotation_about_z.Translate(50.0, 50.0); |
| 754 rotation_about_z.RotateAboutZAxis(90.0); | 755 rotation_about_z.RotateAboutZAxis(90.0); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) { | 901 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) { |
| 901 // This test checks for correct scroll compensation when the fixed-position | 902 // This test checks for correct scroll compensation when the fixed-position |
| 902 // container itself has a render surface. In this case, the container layer | 903 // container itself has a render surface. In this case, the container layer |
| 903 // should be treated like a layer that contributes to a render target, and | 904 // should be treated like a layer that contributes to a render target, and |
| 904 // that render target is completely irrelevant; it should not affect the | 905 // that render target is completely irrelevant; it should not affect the |
| 905 // scroll compensation. | 906 // scroll compensation. |
| 906 LayerImpl* child = scroll_->children()[0]; | 907 LayerImpl* child = scroll_->children()[0]; |
| 907 LayerImpl* grand_child = child->children()[0]; | 908 LayerImpl* grand_child = child->children()[0]; |
| 908 | 909 |
| 909 child->SetIsContainerForFixedPositionLayers(true); | 910 child->SetIsContainerForFixedPositionLayers(true); |
| 910 child->SetForceRenderSurface(true); | 911 child->SetHasRenderSurface(true); |
| 911 grand_child->SetPositionConstraint(fixed_to_top_left_); | 912 grand_child->SetPositionConstraint(fixed_to_top_left_); |
| 912 grand_child->SetDrawsContent(true); | 913 grand_child->SetDrawsContent(true); |
| 913 | 914 |
| 914 // Case 1: scroll delta of 0, 0 | 915 // Case 1: scroll delta of 0, 0 |
| 915 child->SetScrollDelta(gfx::Vector2d(0, 0)); | 916 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 916 ExecuteCalculateDrawProperties(root_.get()); | 917 ExecuteCalculateDrawProperties(root_.get()); |
| 917 | 918 |
| 918 gfx::Transform expected_surface_draw_transform; | 919 gfx::Transform expected_surface_draw_transform; |
| 919 expected_surface_draw_transform.Translate(0.0, 0.0); | 920 expected_surface_draw_transform.Translate(0.0, 0.0); |
| 920 gfx::Transform expected_child_transform; | 921 gfx::Transform expected_child_transform; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 fixed_to_container1->draw_transform()); | 1150 fixed_to_container1->draw_transform()); |
| 1150 | 1151 |
| 1151 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, | 1152 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, |
| 1152 container2->draw_transform()); | 1153 container2->draw_transform()); |
| 1153 | 1154 |
| 1154 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, | 1155 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, |
| 1155 fixed_to_container2->draw_transform()); | 1156 fixed_to_container2->draw_transform()); |
| 1156 } | 1157 } |
| 1157 } // namespace | 1158 } // namespace |
| 1158 } // namespace cc | 1159 } // namespace cc |
| OLD | NEW |