Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: cc/layers/layer_position_constraint_unittest.cc

Issue 1909283004: cc: Remove LayerImpl::children() calls after tree synchronization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
148 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 148 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&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 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2dF()); 153 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2dF());
154 SetScrollOffsetDelta(child_impl_, gfx::Vector2dF()); 154 SetScrollOffsetDelta(child_impl_, gfx::Vector2dF());
155 SetScrollOffsetDelta(grand_child_impl_, gfx::Vector2dF()); 155 SetScrollOffsetDelta(grand_child_impl_, 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 layer_tree_impl_ = root_impl_->layer_tree_impl();
159 scroll_layer_impl_ = inner_viewport_container_layer_impl_->children()[0]; 159 inner_viewport_container_layer_impl_ =
160 outer_viewport_container_layer_impl_ = scroll_layer_impl_->children()[0]; 160 layer_tree_impl_->LayerById(inner_viewport_container_layer_->id());
161 scroll_layer_impl_ = layer_tree_impl_->LayerById(scroll_layer_->id());
162 outer_viewport_container_layer_impl_ =
163 layer_tree_impl_->LayerById(outer_viewport_container_layer_->id());
161 child_transform_layer_impl_ = 164 child_transform_layer_impl_ =
162 outer_viewport_container_layer_impl_->children()[0]; 165 layer_tree_impl_->LayerById(child_transform_layer_->id());
163 child_impl_ = child_transform_layer_impl_->children()[0]; 166 child_impl_ = layer_tree_impl_->LayerById(child_->id());
164 grand_child_impl_ = child_impl_->children()[0]; 167 grand_child_impl_ = layer_tree_impl_->LayerById(grand_child_->id());
165 great_grand_child_impl_ = grand_child_impl_->children()[0]; 168 great_grand_child_impl_ =
169 layer_tree_impl_->LayerById(great_grand_child_->id());
166 } 170 }
167 171
168 protected: 172 protected:
169 FakeLayerTreeHostClient fake_client_; 173 FakeLayerTreeHostClient fake_client_;
170 TestTaskGraphRunner task_graph_runner_; 174 TestTaskGraphRunner task_graph_runner_;
171 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; 175 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_;
172 scoped_refptr<Layer> root_; 176 scoped_refptr<Layer> root_;
173 scoped_refptr<Layer> inner_viewport_container_layer_; 177 scoped_refptr<Layer> inner_viewport_container_layer_;
174 scoped_refptr<Layer> scroll_layer_; 178 scoped_refptr<Layer> scroll_layer_;
175 scoped_refptr<Layer> outer_viewport_container_layer_; 179 scoped_refptr<Layer> outer_viewport_container_layer_;
176 scoped_refptr<Layer> child_transform_layer_; 180 scoped_refptr<Layer> child_transform_layer_;
177 scoped_refptr<Layer> child_; 181 scoped_refptr<Layer> child_;
178 scoped_refptr<Layer> grand_child_; 182 scoped_refptr<Layer> grand_child_;
179 scoped_refptr<Layer> great_grand_child_; 183 scoped_refptr<Layer> great_grand_child_;
184 LayerTreeImpl* layer_tree_impl_;
180 LayerImpl* root_impl_; 185 LayerImpl* root_impl_;
181 LayerImpl* inner_viewport_container_layer_impl_; 186 LayerImpl* inner_viewport_container_layer_impl_;
182 LayerImpl* scroll_layer_impl_; 187 LayerImpl* scroll_layer_impl_;
183 LayerImpl* outer_viewport_container_layer_impl_; 188 LayerImpl* outer_viewport_container_layer_impl_;
184 LayerImpl* child_transform_layer_impl_; 189 LayerImpl* child_transform_layer_impl_;
185 LayerImpl* child_impl_; 190 LayerImpl* child_impl_;
186 LayerImpl* grand_child_impl_; 191 LayerImpl* grand_child_impl_;
187 LayerImpl* great_grand_child_impl_; 192 LayerImpl* great_grand_child_impl_;
188 193
189 LayerPositionConstraint fixed_to_top_left_; 194 LayerPositionConstraint fixed_to_top_left_;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // to verify that we have correct order-of-operations in the final scroll 573 // to verify that we have correct order-of-operations in the final scroll
569 // compensation. Note that rotating about the center of the layer ensures we 574 // compensation. Note that rotating about the center of the layer ensures we
570 // do not accidentally clip away layers that we want to test. 575 // do not accidentally clip away layers that we want to test.
571 gfx::Transform rotation_about_z; 576 gfx::Transform rotation_about_z;
572 rotation_about_z.Translate(50.0, 50.0); 577 rotation_about_z.Translate(50.0, 50.0);
573 rotation_about_z.RotateAboutZAxis(90.0); 578 rotation_about_z.RotateAboutZAxis(90.0);
574 rotation_about_z.Translate(-50.0, -50.0); 579 rotation_about_z.Translate(-50.0, -50.0);
575 fixed_position_child->SetTransform(rotation_about_z); 580 fixed_position_child->SetTransform(rotation_about_z);
576 581
577 CommitAndUpdateImplPointers(); 582 CommitAndUpdateImplPointers();
578 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; 583 LayerImpl* fixed_position_child_impl =
584 layer_tree_impl_->LayerById(fixed_position_child->id());
579 585
580 // Case 1: scroll delta of 0, 0 586 // Case 1: scroll delta of 0, 0
581 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 587 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
582 child_impl_->SetDrawsContent(true); 588 child_impl_->SetDrawsContent(true);
583 ExecuteCalculateDrawProperties(root_impl_); 589 ExecuteCalculateDrawProperties(root_impl_);
584 590
585 gfx::Transform expected_child_transform; 591 gfx::Transform expected_child_transform;
586 592
587 gfx::Transform expected_grand_child_surface_draw_transform; 593 gfx::Transform expected_grand_child_surface_draw_transform;
588 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); 594 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, 670 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform,
665 grand_child_impl_->DrawTransform()); 671 grand_child_impl_->DrawTransform());
666 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, 672 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform,
667 great_grand_child_impl_->DrawTransform()); 673 great_grand_child_impl_->DrawTransform());
668 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, 674 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform,
669 fixed_position_child_impl->DrawTransform()); 675 fixed_position_child_impl->DrawTransform());
670 676
671 // Case 4: Bottom-right fixed-position layer. 677 // Case 4: Bottom-right fixed-position layer.
672 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); 678 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_);
673 CommitAndUpdateImplPointers(); 679 CommitAndUpdateImplPointers();
674 fixed_position_child_impl = great_grand_child_impl_->children()[0]; 680 fixed_position_child_impl =
681 layer_tree_impl_->LayerById(fixed_position_child->id());
675 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); 682 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30));
676 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); 683 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20));
677 ExecuteCalculateDrawProperties(root_impl_); 684 ExecuteCalculateDrawProperties(root_impl_);
678 685
679 // Bottom-right fixed-position layer moves as container resizes. 686 // Bottom-right fixed-position layer moves as container resizes.
680 expected_fixed_position_child_transform.MakeIdentity(); 687 expected_fixed_position_child_transform.MakeIdentity();
681 // explicit canceling out the scroll delta that gets embedded in the fixed 688 // explicit canceling out the scroll delta that gets embedded in the fixed
682 // position layer's surface. 689 // position layer's surface.
683 expected_fixed_position_child_transform.Translate(10.0, 30.0); 690 expected_fixed_position_child_transform.Translate(10.0, 30.0);
684 // Also apply size delta in the child(container) layer space. 691 // Also apply size delta in the child(container) layer space.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 // compensation. Note that rotating about the center of the layer ensures we 732 // compensation. Note that rotating about the center of the layer ensures we
726 // do not accidentally clip away layers that we want to test. 733 // do not accidentally clip away layers that we want to test.
727 gfx::Transform rotation_about_z; 734 gfx::Transform rotation_about_z;
728 rotation_about_z.Translate(50.0, 50.0); 735 rotation_about_z.Translate(50.0, 50.0);
729 rotation_about_z.RotateAboutZAxis(30.0); 736 rotation_about_z.RotateAboutZAxis(30.0);
730 rotation_about_z.Translate(-50.0, -50.0); 737 rotation_about_z.Translate(-50.0, -50.0);
731 child_transform_layer_->SetTransform(rotation_about_z); 738 child_transform_layer_->SetTransform(rotation_about_z);
732 fixed_position_child->SetTransform(rotation_about_z); 739 fixed_position_child->SetTransform(rotation_about_z);
733 740
734 CommitAndUpdateImplPointers(); 741 CommitAndUpdateImplPointers();
735 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; 742 LayerImpl* fixed_position_child_impl =
743 layer_tree_impl_->LayerById(fixed_position_child->id());
736 744
737 // Case 1: scroll delta of 0, 0 745 // Case 1: scroll delta of 0, 0
738 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 746 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
739 child_impl_->SetDrawsContent(true); 747 child_impl_->SetDrawsContent(true);
740 ExecuteCalculateDrawProperties(root_impl_); 748 ExecuteCalculateDrawProperties(root_impl_);
741 749
742 gfx::Transform expected_child_transform; 750 gfx::Transform expected_child_transform;
743 expected_child_transform.PreconcatTransform(rotation_about_z); 751 expected_child_transform.PreconcatTransform(rotation_about_z);
744 752
745 gfx::Transform expected_grand_child_surface_draw_transform; 753 gfx::Transform expected_grand_child_surface_draw_transform;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 grand_child_->SetPositionConstraint(fixed_to_top_left_); 1052 grand_child_->SetPositionConstraint(fixed_to_top_left_);
1045 great_grand_child_->SetIsContainerForFixedPositionLayers(true); 1053 great_grand_child_->SetIsContainerForFixedPositionLayers(true);
1046 great_grand_child_->SetScrollClipLayerId(root_->id()); 1054 great_grand_child_->SetScrollClipLayerId(root_->id());
1047 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); 1055 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_);
1048 1056
1049 CommitAndUpdateImplPointers(); 1057 CommitAndUpdateImplPointers();
1050 1058
1051 LayerImpl* container1 = child_impl_; 1059 LayerImpl* container1 = child_impl_;
1052 LayerImpl* fixed_to_container1 = grand_child_impl_; 1060 LayerImpl* fixed_to_container1 = grand_child_impl_;
1053 LayerImpl* container2 = great_grand_child_impl_; 1061 LayerImpl* container2 = great_grand_child_impl_;
1054 LayerImpl* fixed_to_container2 = container2->children()[0]; 1062 LayerImpl* fixed_to_container2 =
1063 layer_tree_impl_->LayerById(great_great_grand_child->id());
1055 1064
1056 SetScrollOffsetDelta(container1, gfx::Vector2d(0, 15)); 1065 SetScrollOffsetDelta(container1, gfx::Vector2d(0, 15));
1057 container1->SetDrawsContent(true); 1066 container1->SetDrawsContent(true);
1058 SetScrollOffsetDelta(container2, gfx::Vector2d(30, 0)); 1067 SetScrollOffsetDelta(container2, gfx::Vector2d(30, 0));
1059 container2->SetDrawsContent(true); 1068 container2->SetDrawsContent(true);
1060 ExecuteCalculateDrawProperties(root_impl_); 1069 ExecuteCalculateDrawProperties(root_impl_);
1061 1070
1062 gfx::Transform expected_container1_transform; 1071 gfx::Transform expected_container1_transform;
1063 expected_container1_transform.Translate(0.0, -15.0); 1072 expected_container1_transform.Translate(0.0, -15.0);
1064 1073
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 VerifySerializeAndDeserializeProto(true, false, true); 1167 VerifySerializeAndDeserializeProto(true, false, true);
1159 VerifySerializeAndDeserializeProto(true, false, false); 1168 VerifySerializeAndDeserializeProto(true, false, false);
1160 VerifySerializeAndDeserializeProto(false, true, true); 1169 VerifySerializeAndDeserializeProto(false, true, true);
1161 VerifySerializeAndDeserializeProto(false, true, false); 1170 VerifySerializeAndDeserializeProto(false, true, false);
1162 VerifySerializeAndDeserializeProto(false, false, true); 1171 VerifySerializeAndDeserializeProto(false, false, true);
1163 VerifySerializeAndDeserializeProto(false, false, false); 1172 VerifySerializeAndDeserializeProto(false, false, false);
1164 } 1173 }
1165 1174
1166 } // namespace 1175 } // namespace
1167 } // namespace cc 1176 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698