| 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.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 148 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 149 | 149 |
| 150 // Since scroll deltas aren't sent back to the main thread in this test | 150 // Since scroll deltas aren't sent back to the main thread in this test |
| 151 // setup, clear them to maintain consistent state. | 151 // setup, clear them to maintain consistent state. |
| 152 if (root_impl_) { | 152 if (root_impl_) { |
| 153 scroll_layer_impl_->SetScrollDelta(gfx::Vector2dF()); | 153 scroll_layer_impl_->SetScrollDelta(gfx::Vector2dF()); |
| 154 child_impl_->SetScrollDelta(gfx::Vector2dF()); | 154 child_impl_->SetScrollDelta(gfx::Vector2dF()); |
| 155 grand_child_impl_->SetScrollDelta(gfx::Vector2dF()); | 155 grand_child_impl_->SetScrollDelta(gfx::Vector2dF()); |
| 156 } | 156 } |
| 157 root_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree(); | 157 root_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree(); |
| 158 inner_viewport_container_layer_impl_ = root_impl_->children()[0]; | 158 inner_viewport_container_layer_impl_ = root_impl_->children()[0].get(); |
| 159 scroll_layer_impl_ = inner_viewport_container_layer_impl_->children()[0]; | 159 scroll_layer_impl_ = |
| 160 outer_viewport_container_layer_impl_ = scroll_layer_impl_->children()[0]; | 160 inner_viewport_container_layer_impl_->children()[0].get(); |
| 161 outer_viewport_container_layer_impl_ = |
| 162 scroll_layer_impl_->children()[0].get(); |
| 161 child_transform_layer_impl_ = | 163 child_transform_layer_impl_ = |
| 162 outer_viewport_container_layer_impl_->children()[0]; | 164 outer_viewport_container_layer_impl_->children()[0].get(); |
| 163 child_impl_ = child_transform_layer_impl_->children()[0]; | 165 child_impl_ = child_transform_layer_impl_->children()[0].get(); |
| 164 grand_child_impl_ = child_impl_->children()[0]; | 166 grand_child_impl_ = child_impl_->children()[0].get(); |
| 165 great_grand_child_impl_ = grand_child_impl_->children()[0]; | 167 great_grand_child_impl_ = grand_child_impl_->children()[0].get(); |
| 166 } | 168 } |
| 167 | 169 |
| 168 protected: | 170 protected: |
| 169 FakeLayerTreeHostClient fake_client_; | 171 FakeLayerTreeHostClient fake_client_; |
| 170 TestTaskGraphRunner task_graph_runner_; | 172 TestTaskGraphRunner task_graph_runner_; |
| 171 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; | 173 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; |
| 172 LayerSettings layer_settings_; | 174 LayerSettings layer_settings_; |
| 173 scoped_refptr<Layer> root_; | 175 scoped_refptr<Layer> root_; |
| 174 scoped_refptr<Layer> inner_viewport_container_layer_; | 176 scoped_refptr<Layer> inner_viewport_container_layer_; |
| 175 scoped_refptr<Layer> scroll_layer_; | 177 scoped_refptr<Layer> scroll_layer_; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 // to verify that we have correct order-of-operations in the final scroll | 559 // to verify that we have correct order-of-operations in the final scroll |
| 558 // compensation. Note that rotating about the center of the layer ensures we | 560 // compensation. Note that rotating about the center of the layer ensures we |
| 559 // do not accidentally clip away layers that we want to test. | 561 // do not accidentally clip away layers that we want to test. |
| 560 gfx::Transform rotation_about_z; | 562 gfx::Transform rotation_about_z; |
| 561 rotation_about_z.Translate(50.0, 50.0); | 563 rotation_about_z.Translate(50.0, 50.0); |
| 562 rotation_about_z.RotateAboutZAxis(90.0); | 564 rotation_about_z.RotateAboutZAxis(90.0); |
| 563 rotation_about_z.Translate(-50.0, -50.0); | 565 rotation_about_z.Translate(-50.0, -50.0); |
| 564 fixed_position_child->SetTransform(rotation_about_z); | 566 fixed_position_child->SetTransform(rotation_about_z); |
| 565 | 567 |
| 566 CommitAndUpdateImplPointers(); | 568 CommitAndUpdateImplPointers(); |
| 567 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; | 569 LayerImpl* fixed_position_child_impl = |
| 570 great_grand_child_impl_->children()[0].get(); |
| 568 | 571 |
| 569 // Case 1: scroll delta of 0, 0 | 572 // Case 1: scroll delta of 0, 0 |
| 570 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 573 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 571 child_impl_->SetDrawsContent(true); | 574 child_impl_->SetDrawsContent(true); |
| 572 ExecuteCalculateDrawProperties(root_impl_); | 575 ExecuteCalculateDrawProperties(root_impl_); |
| 573 | 576 |
| 574 gfx::Transform expected_child_transform; | 577 gfx::Transform expected_child_transform; |
| 575 | 578 |
| 576 gfx::Transform expected_grand_child_surface_draw_transform; | 579 gfx::Transform expected_grand_child_surface_draw_transform; |
| 577 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 580 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 656 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 654 grand_child_impl_->draw_transform()); | 657 grand_child_impl_->draw_transform()); |
| 655 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 658 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 656 great_grand_child_impl_->draw_transform()); | 659 great_grand_child_impl_->draw_transform()); |
| 657 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 660 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 658 fixed_position_child_impl->draw_transform()); | 661 fixed_position_child_impl->draw_transform()); |
| 659 | 662 |
| 660 // Case 4: Bottom-right fixed-position layer. | 663 // Case 4: Bottom-right fixed-position layer. |
| 661 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); | 664 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); |
| 662 CommitAndUpdateImplPointers(); | 665 CommitAndUpdateImplPointers(); |
| 663 fixed_position_child_impl = great_grand_child_impl_->children()[0]; | 666 fixed_position_child_impl = great_grand_child_impl_->children()[0].get(); |
| 664 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 667 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 665 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 668 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 666 ExecuteCalculateDrawProperties(root_impl_); | 669 ExecuteCalculateDrawProperties(root_impl_); |
| 667 | 670 |
| 668 // Bottom-right fixed-position layer moves as container resizes. | 671 // Bottom-right fixed-position layer moves as container resizes. |
| 669 expected_fixed_position_child_transform.MakeIdentity(); | 672 expected_fixed_position_child_transform.MakeIdentity(); |
| 670 // explicit canceling out the scroll delta that gets embedded in the fixed | 673 // explicit canceling out the scroll delta that gets embedded in the fixed |
| 671 // position layer's surface. | 674 // position layer's surface. |
| 672 expected_fixed_position_child_transform.Translate(10.0, 30.0); | 675 expected_fixed_position_child_transform.Translate(10.0, 30.0); |
| 673 // Also apply size delta in the child(container) layer space. | 676 // Also apply size delta in the child(container) layer space. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 // compensation. Note that rotating about the center of the layer ensures we | 717 // compensation. Note that rotating about the center of the layer ensures we |
| 715 // do not accidentally clip away layers that we want to test. | 718 // do not accidentally clip away layers that we want to test. |
| 716 gfx::Transform rotation_about_z; | 719 gfx::Transform rotation_about_z; |
| 717 rotation_about_z.Translate(50.0, 50.0); | 720 rotation_about_z.Translate(50.0, 50.0); |
| 718 rotation_about_z.RotateAboutZAxis(30.0); | 721 rotation_about_z.RotateAboutZAxis(30.0); |
| 719 rotation_about_z.Translate(-50.0, -50.0); | 722 rotation_about_z.Translate(-50.0, -50.0); |
| 720 child_transform_layer_->SetTransform(rotation_about_z); | 723 child_transform_layer_->SetTransform(rotation_about_z); |
| 721 fixed_position_child->SetTransform(rotation_about_z); | 724 fixed_position_child->SetTransform(rotation_about_z); |
| 722 | 725 |
| 723 CommitAndUpdateImplPointers(); | 726 CommitAndUpdateImplPointers(); |
| 724 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; | 727 LayerImpl* fixed_position_child_impl = |
| 728 great_grand_child_impl_->children()[0].get(); |
| 725 | 729 |
| 726 // Case 1: scroll delta of 0, 0 | 730 // Case 1: scroll delta of 0, 0 |
| 727 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 731 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 728 child_impl_->SetDrawsContent(true); | 732 child_impl_->SetDrawsContent(true); |
| 729 ExecuteCalculateDrawProperties(root_impl_); | 733 ExecuteCalculateDrawProperties(root_impl_); |
| 730 | 734 |
| 731 gfx::Transform expected_child_transform; | 735 gfx::Transform expected_child_transform; |
| 732 expected_child_transform.PreconcatTransform(rotation_about_z); | 736 expected_child_transform.PreconcatTransform(rotation_about_z); |
| 733 | 737 |
| 734 gfx::Transform expected_grand_child_surface_draw_transform; | 738 gfx::Transform expected_grand_child_surface_draw_transform; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 1037 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
| 1034 great_grand_child_->SetIsContainerForFixedPositionLayers(true); | 1038 great_grand_child_->SetIsContainerForFixedPositionLayers(true); |
| 1035 great_grand_child_->SetScrollClipLayerId(root_->id()); | 1039 great_grand_child_->SetScrollClipLayerId(root_->id()); |
| 1036 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); | 1040 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); |
| 1037 | 1041 |
| 1038 CommitAndUpdateImplPointers(); | 1042 CommitAndUpdateImplPointers(); |
| 1039 | 1043 |
| 1040 LayerImpl* container1 = child_impl_; | 1044 LayerImpl* container1 = child_impl_; |
| 1041 LayerImpl* fixed_to_container1 = grand_child_impl_; | 1045 LayerImpl* fixed_to_container1 = grand_child_impl_; |
| 1042 LayerImpl* container2 = great_grand_child_impl_; | 1046 LayerImpl* container2 = great_grand_child_impl_; |
| 1043 LayerImpl* fixed_to_container2 = container2->children()[0]; | 1047 LayerImpl* fixed_to_container2 = container2->children()[0].get(); |
| 1044 | 1048 |
| 1045 container1->SetScrollDelta(gfx::Vector2d(0, 15)); | 1049 container1->SetScrollDelta(gfx::Vector2d(0, 15)); |
| 1046 container1->SetDrawsContent(true); | 1050 container1->SetDrawsContent(true); |
| 1047 container2->SetScrollDelta(gfx::Vector2d(30, 0)); | 1051 container2->SetScrollDelta(gfx::Vector2d(30, 0)); |
| 1048 container2->SetDrawsContent(true); | 1052 container2->SetDrawsContent(true); |
| 1049 ExecuteCalculateDrawProperties(root_impl_); | 1053 ExecuteCalculateDrawProperties(root_impl_); |
| 1050 | 1054 |
| 1051 gfx::Transform expected_container1_transform; | 1055 gfx::Transform expected_container1_transform; |
| 1052 expected_container1_transform.Translate(0.0, -15.0); | 1056 expected_container1_transform.Translate(0.0, -15.0); |
| 1053 | 1057 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 expected_fixed_child_transform.Translate(20.0, 20.0); | 1125 expected_fixed_child_transform.Translate(20.0, 20.0); |
| 1122 | 1126 |
| 1123 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1127 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
| 1124 scroll_layer_impl_->draw_transform()); | 1128 scroll_layer_impl_->draw_transform()); |
| 1125 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1129 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
| 1126 fixed_child_impl->draw_transform()); | 1130 fixed_child_impl->draw_transform()); |
| 1127 } | 1131 } |
| 1128 | 1132 |
| 1129 } // namespace | 1133 } // namespace |
| 1130 } // namespace cc | 1134 } // namespace cc |
| OLD | NEW |