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

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

Issue 1801853002: Transfer LayerImpl ownership to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more asan. Created 4 years, 9 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 | « cc/layers/layer_lists.h ('k') | cc/layers/layer_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::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 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].get(); 158 inner_viewport_container_layer_impl_ = root_impl_->children()[0];
159 scroll_layer_impl_ = 159 scroll_layer_impl_ = inner_viewport_container_layer_impl_->children()[0];
160 inner_viewport_container_layer_impl_->children()[0].get(); 160 outer_viewport_container_layer_impl_ = scroll_layer_impl_->children()[0];
161 outer_viewport_container_layer_impl_ =
162 scroll_layer_impl_->children()[0].get();
163 child_transform_layer_impl_ = 161 child_transform_layer_impl_ =
164 outer_viewport_container_layer_impl_->children()[0].get(); 162 outer_viewport_container_layer_impl_->children()[0];
165 child_impl_ = child_transform_layer_impl_->children()[0].get(); 163 child_impl_ = child_transform_layer_impl_->children()[0];
166 grand_child_impl_ = child_impl_->children()[0].get(); 164 grand_child_impl_ = child_impl_->children()[0];
167 great_grand_child_impl_ = grand_child_impl_->children()[0].get(); 165 great_grand_child_impl_ = grand_child_impl_->children()[0];
168 } 166 }
169 167
170 protected: 168 protected:
171 FakeLayerTreeHostClient fake_client_; 169 FakeLayerTreeHostClient fake_client_;
172 TestTaskGraphRunner task_graph_runner_; 170 TestTaskGraphRunner task_graph_runner_;
173 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; 171 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
174 scoped_refptr<Layer> root_; 172 scoped_refptr<Layer> root_;
175 scoped_refptr<Layer> inner_viewport_container_layer_; 173 scoped_refptr<Layer> inner_viewport_container_layer_;
176 scoped_refptr<Layer> scroll_layer_; 174 scoped_refptr<Layer> scroll_layer_;
177 scoped_refptr<Layer> outer_viewport_container_layer_; 175 scoped_refptr<Layer> outer_viewport_container_layer_;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 // to verify that we have correct order-of-operations in the final scroll 568 // to verify that we have correct order-of-operations in the final scroll
571 // compensation. Note that rotating about the center of the layer ensures we 569 // compensation. Note that rotating about the center of the layer ensures we
572 // do not accidentally clip away layers that we want to test. 570 // do not accidentally clip away layers that we want to test.
573 gfx::Transform rotation_about_z; 571 gfx::Transform rotation_about_z;
574 rotation_about_z.Translate(50.0, 50.0); 572 rotation_about_z.Translate(50.0, 50.0);
575 rotation_about_z.RotateAboutZAxis(90.0); 573 rotation_about_z.RotateAboutZAxis(90.0);
576 rotation_about_z.Translate(-50.0, -50.0); 574 rotation_about_z.Translate(-50.0, -50.0);
577 fixed_position_child->SetTransform(rotation_about_z); 575 fixed_position_child->SetTransform(rotation_about_z);
578 576
579 CommitAndUpdateImplPointers(); 577 CommitAndUpdateImplPointers();
580 LayerImpl* fixed_position_child_impl = 578 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0];
581 great_grand_child_impl_->children()[0].get();
582 579
583 // Case 1: scroll delta of 0, 0 580 // Case 1: scroll delta of 0, 0
584 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 581 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
585 child_impl_->SetDrawsContent(true); 582 child_impl_->SetDrawsContent(true);
586 ExecuteCalculateDrawProperties(root_impl_); 583 ExecuteCalculateDrawProperties(root_impl_);
587 584
588 gfx::Transform expected_child_transform; 585 gfx::Transform expected_child_transform;
589 586
590 gfx::Transform expected_grand_child_surface_draw_transform; 587 gfx::Transform expected_grand_child_surface_draw_transform;
591 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); 588 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, 664 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform,
668 grand_child_impl_->DrawTransform()); 665 grand_child_impl_->DrawTransform());
669 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, 666 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform,
670 great_grand_child_impl_->DrawTransform()); 667 great_grand_child_impl_->DrawTransform());
671 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, 668 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform,
672 fixed_position_child_impl->DrawTransform()); 669 fixed_position_child_impl->DrawTransform());
673 670
674 // Case 4: Bottom-right fixed-position layer. 671 // Case 4: Bottom-right fixed-position layer.
675 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); 672 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_);
676 CommitAndUpdateImplPointers(); 673 CommitAndUpdateImplPointers();
677 fixed_position_child_impl = great_grand_child_impl_->children()[0].get(); 674 fixed_position_child_impl = great_grand_child_impl_->children()[0];
678 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); 675 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30));
679 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); 676 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20));
680 ExecuteCalculateDrawProperties(root_impl_); 677 ExecuteCalculateDrawProperties(root_impl_);
681 678
682 // Bottom-right fixed-position layer moves as container resizes. 679 // Bottom-right fixed-position layer moves as container resizes.
683 expected_fixed_position_child_transform.MakeIdentity(); 680 expected_fixed_position_child_transform.MakeIdentity();
684 // explicit canceling out the scroll delta that gets embedded in the fixed 681 // explicit canceling out the scroll delta that gets embedded in the fixed
685 // position layer's surface. 682 // position layer's surface.
686 expected_fixed_position_child_transform.Translate(10.0, 30.0); 683 expected_fixed_position_child_transform.Translate(10.0, 30.0);
687 // Also apply size delta in the child(container) layer space. 684 // Also apply size delta in the child(container) layer space.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 // compensation. Note that rotating about the center of the layer ensures we 725 // compensation. Note that rotating about the center of the layer ensures we
729 // do not accidentally clip away layers that we want to test. 726 // do not accidentally clip away layers that we want to test.
730 gfx::Transform rotation_about_z; 727 gfx::Transform rotation_about_z;
731 rotation_about_z.Translate(50.0, 50.0); 728 rotation_about_z.Translate(50.0, 50.0);
732 rotation_about_z.RotateAboutZAxis(30.0); 729 rotation_about_z.RotateAboutZAxis(30.0);
733 rotation_about_z.Translate(-50.0, -50.0); 730 rotation_about_z.Translate(-50.0, -50.0);
734 child_transform_layer_->SetTransform(rotation_about_z); 731 child_transform_layer_->SetTransform(rotation_about_z);
735 fixed_position_child->SetTransform(rotation_about_z); 732 fixed_position_child->SetTransform(rotation_about_z);
736 733
737 CommitAndUpdateImplPointers(); 734 CommitAndUpdateImplPointers();
738 LayerImpl* fixed_position_child_impl = 735 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0];
739 great_grand_child_impl_->children()[0].get();
740 736
741 // Case 1: scroll delta of 0, 0 737 // Case 1: scroll delta of 0, 0
742 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 738 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
743 child_impl_->SetDrawsContent(true); 739 child_impl_->SetDrawsContent(true);
744 ExecuteCalculateDrawProperties(root_impl_); 740 ExecuteCalculateDrawProperties(root_impl_);
745 741
746 gfx::Transform expected_child_transform; 742 gfx::Transform expected_child_transform;
747 expected_child_transform.PreconcatTransform(rotation_about_z); 743 expected_child_transform.PreconcatTransform(rotation_about_z);
748 744
749 gfx::Transform expected_grand_child_surface_draw_transform; 745 gfx::Transform expected_grand_child_surface_draw_transform;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 grand_child_->SetPositionConstraint(fixed_to_top_left_); 1044 grand_child_->SetPositionConstraint(fixed_to_top_left_);
1049 great_grand_child_->SetIsContainerForFixedPositionLayers(true); 1045 great_grand_child_->SetIsContainerForFixedPositionLayers(true);
1050 great_grand_child_->SetScrollClipLayerId(root_->id()); 1046 great_grand_child_->SetScrollClipLayerId(root_->id());
1051 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); 1047 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_);
1052 1048
1053 CommitAndUpdateImplPointers(); 1049 CommitAndUpdateImplPointers();
1054 1050
1055 LayerImpl* container1 = child_impl_; 1051 LayerImpl* container1 = child_impl_;
1056 LayerImpl* fixed_to_container1 = grand_child_impl_; 1052 LayerImpl* fixed_to_container1 = grand_child_impl_;
1057 LayerImpl* container2 = great_grand_child_impl_; 1053 LayerImpl* container2 = great_grand_child_impl_;
1058 LayerImpl* fixed_to_container2 = container2->children()[0].get(); 1054 LayerImpl* fixed_to_container2 = container2->children()[0];
1059 1055
1060 SetScrollOffsetDelta(container1, gfx::Vector2d(0, 15)); 1056 SetScrollOffsetDelta(container1, gfx::Vector2d(0, 15));
1061 container1->SetDrawsContent(true); 1057 container1->SetDrawsContent(true);
1062 SetScrollOffsetDelta(container2, gfx::Vector2d(30, 0)); 1058 SetScrollOffsetDelta(container2, gfx::Vector2d(30, 0));
1063 container2->SetDrawsContent(true); 1059 container2->SetDrawsContent(true);
1064 ExecuteCalculateDrawProperties(root_impl_); 1060 ExecuteCalculateDrawProperties(root_impl_);
1065 1061
1066 gfx::Transform expected_container1_transform; 1062 gfx::Transform expected_container1_transform;
1067 expected_container1_transform.Translate(0.0, -15.0); 1063 expected_container1_transform.Translate(0.0, -15.0);
1068 1064
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 VerifySerializeAndDeserializeProto(true, false, true); 1158 VerifySerializeAndDeserializeProto(true, false, true);
1163 VerifySerializeAndDeserializeProto(true, false, false); 1159 VerifySerializeAndDeserializeProto(true, false, false);
1164 VerifySerializeAndDeserializeProto(false, true, true); 1160 VerifySerializeAndDeserializeProto(false, true, true);
1165 VerifySerializeAndDeserializeProto(false, true, false); 1161 VerifySerializeAndDeserializeProto(false, true, false);
1166 VerifySerializeAndDeserializeProto(false, false, true); 1162 VerifySerializeAndDeserializeProto(false, false, true);
1167 VerifySerializeAndDeserializeProto(false, false, false); 1163 VerifySerializeAndDeserializeProto(false, false, false);
1168 } 1164 }
1169 1165
1170 } // namespace 1166 } // namespace
1171 } // namespace cc 1167 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_lists.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698