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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 gfx::Transform expected_child_transform; | 217 gfx::Transform expected_child_transform; |
218 gfx::Transform expected_grand_child_transform = expected_child_transform; | 218 gfx::Transform expected_grand_child_transform = expected_child_transform; |
219 | 219 |
220 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 220 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
221 child_impl_->draw_transform()); | 221 child_impl_->draw_transform()); |
222 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 222 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
223 grand_child_impl_->draw_transform()); | 223 grand_child_impl_->draw_transform()); |
224 | 224 |
225 // Case 2: scroll delta of 10, 10 | 225 // Case 2: scroll delta of 10, 10 |
226 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 226 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 227 child_impl_->SetDrawsContent(true); |
227 ExecuteCalculateDrawProperties(root_impl_); | 228 ExecuteCalculateDrawProperties(root_impl_); |
228 | 229 |
229 // Here the child is affected by scroll delta, but the fixed position | 230 // Here the child is affected by scroll delta, but the fixed position |
230 // grand_child should not be affected. | 231 // grand_child should not be affected. |
231 expected_child_transform.MakeIdentity(); | 232 expected_child_transform.MakeIdentity(); |
232 expected_child_transform.Translate(-10.0, -10.0); | 233 expected_child_transform.Translate(-10.0, -10.0); |
233 | 234 |
234 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 235 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
235 child_impl_->draw_transform()); | 236 child_impl_->draw_transform()); |
236 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 237 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 // This test checks for correct scroll compensation when the fixed-position | 271 // This test checks for correct scroll compensation when the fixed-position |
271 // container is NOT the direct parent of the fixed-position layer. | 272 // container is NOT the direct parent of the fixed-position layer. |
272 child_->SetIsContainerForFixedPositionLayers(true); | 273 child_->SetIsContainerForFixedPositionLayers(true); |
273 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); | 274 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); |
274 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); | 275 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); |
275 | 276 |
276 CommitAndUpdateImplPointers(); | 277 CommitAndUpdateImplPointers(); |
277 | 278 |
278 // Case 1: scroll delta of 0, 0 | 279 // Case 1: scroll delta of 0, 0 |
279 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 280 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 281 child_impl_->SetDrawsContent(true); |
280 ExecuteCalculateDrawProperties(root_impl_); | 282 ExecuteCalculateDrawProperties(root_impl_); |
281 | 283 |
282 gfx::Transform expected_child_transform; | 284 gfx::Transform expected_child_transform; |
283 gfx::Transform expected_grand_child_transform; | 285 gfx::Transform expected_grand_child_transform; |
284 expected_grand_child_transform.Translate(8.0, 6.0); | 286 expected_grand_child_transform.Translate(8.0, 6.0); |
285 | 287 |
286 gfx::Transform expected_great_grand_child_transform = | 288 gfx::Transform expected_great_grand_child_transform = |
287 expected_grand_child_transform; | 289 expected_grand_child_transform; |
288 | 290 |
289 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 291 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 356 |
355 child_transform_layer_->SetIsContainerForFixedPositionLayers(true); | 357 child_transform_layer_->SetIsContainerForFixedPositionLayers(true); |
356 child_transform_layer_->SetTransform(rotation_about_z); | 358 child_transform_layer_->SetTransform(rotation_about_z); |
357 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); | 359 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); |
358 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); | 360 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); |
359 | 361 |
360 CommitAndUpdateImplPointers(); | 362 CommitAndUpdateImplPointers(); |
361 | 363 |
362 // Case 1: scroll delta of 0, 0 | 364 // Case 1: scroll delta of 0, 0 |
363 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 365 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 366 child_impl_->SetDrawsContent(true); |
364 ExecuteCalculateDrawProperties(root_impl_); | 367 ExecuteCalculateDrawProperties(root_impl_); |
365 | 368 |
366 gfx::Transform expected_child_transform; | 369 gfx::Transform expected_child_transform; |
367 expected_child_transform.PreconcatTransform(rotation_about_z); | 370 expected_child_transform.PreconcatTransform(rotation_about_z); |
368 | 371 |
369 gfx::Transform expected_grand_child_transform; | 372 gfx::Transform expected_grand_child_transform; |
370 expected_grand_child_transform.PreconcatTransform( | 373 expected_grand_child_transform.PreconcatTransform( |
371 rotation_about_z); // child's local transform is inherited | 374 rotation_about_z); // child's local transform is inherited |
372 // translation because of position occurs before layer's local transform. | 375 // translation because of position occurs before layer's local transform. |
373 expected_grand_child_transform.Translate(8.0, 6.0); | 376 expected_grand_child_transform.Translate(8.0, 6.0); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 EXPECT_TRANSFORMATION_MATRIX_EQ( | 447 EXPECT_TRANSFORMATION_MATRIX_EQ( |
445 expected_surface_draw_transform, | 448 expected_surface_draw_transform, |
446 grand_child_impl_->render_surface()->draw_transform()); | 449 grand_child_impl_->render_surface()->draw_transform()); |
447 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 450 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
448 grand_child_impl_->draw_transform()); | 451 grand_child_impl_->draw_transform()); |
449 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 452 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
450 great_grand_child_impl_->draw_transform()); | 453 great_grand_child_impl_->draw_transform()); |
451 | 454 |
452 // Case 2: scroll delta of 10, 30 | 455 // Case 2: scroll delta of 10, 30 |
453 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 456 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 457 child_impl_->SetDrawsContent(true); |
454 ExecuteCalculateDrawProperties(root_impl_); | 458 ExecuteCalculateDrawProperties(root_impl_); |
455 | 459 |
456 // Here the grand_child remains unchanged, because it scrolls along with the | 460 // Here the grand_child remains unchanged, because it scrolls along with the |
457 // render surface, and the translation is actually in the render surface. But, | 461 // render surface, and the translation is actually in the render surface. But, |
458 // the fixed position great_grand_child is more awkward: its actually being | 462 // the fixed position great_grand_child is more awkward: its actually being |
459 // drawn with respect to the render surface, but it needs to remain fixed with | 463 // drawn with respect to the render surface, but it needs to remain fixed with |
460 // resepct to a container beyond that surface. So, the net result is that, | 464 // resepct to a container beyond that surface. So, the net result is that, |
461 // unlike previous tests where the fixed position layer's transform remains | 465 // unlike previous tests where the fixed position layer's transform remains |
462 // unchanged, here the fixed position layer's transform explicitly contains | 466 // unchanged, here the fixed position layer's transform explicitly contains |
463 // the translation that cancels out the scroll. | 467 // the translation that cancels out the scroll. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 rotation_about_z.Translate(50.0, 50.0); | 559 rotation_about_z.Translate(50.0, 50.0); |
556 rotation_about_z.RotateAboutZAxis(90.0); | 560 rotation_about_z.RotateAboutZAxis(90.0); |
557 rotation_about_z.Translate(-50.0, -50.0); | 561 rotation_about_z.Translate(-50.0, -50.0); |
558 fixed_position_child->SetTransform(rotation_about_z); | 562 fixed_position_child->SetTransform(rotation_about_z); |
559 | 563 |
560 CommitAndUpdateImplPointers(); | 564 CommitAndUpdateImplPointers(); |
561 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; | 565 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; |
562 | 566 |
563 // Case 1: scroll delta of 0, 0 | 567 // Case 1: scroll delta of 0, 0 |
564 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 568 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 569 child_impl_->SetDrawsContent(true); |
565 ExecuteCalculateDrawProperties(root_impl_); | 570 ExecuteCalculateDrawProperties(root_impl_); |
566 | 571 |
567 gfx::Transform expected_child_transform; | 572 gfx::Transform expected_child_transform; |
568 | 573 |
569 gfx::Transform expected_grand_child_surface_draw_transform; | 574 gfx::Transform expected_grand_child_surface_draw_transform; |
570 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 575 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
571 | 576 |
572 gfx::Transform expected_grand_child_transform; | 577 gfx::Transform expected_grand_child_transform; |
573 | 578 |
574 gfx::Transform expected_great_grand_child_surface_draw_transform; | 579 gfx::Transform expected_great_grand_child_surface_draw_transform; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 rotation_about_z.RotateAboutZAxis(90.0); | 716 rotation_about_z.RotateAboutZAxis(90.0); |
712 rotation_about_z.Translate(-50.0, -50.0); | 717 rotation_about_z.Translate(-50.0, -50.0); |
713 child_transform_layer_->SetTransform(rotation_about_z); | 718 child_transform_layer_->SetTransform(rotation_about_z); |
714 fixed_position_child->SetTransform(rotation_about_z); | 719 fixed_position_child->SetTransform(rotation_about_z); |
715 | 720 |
716 CommitAndUpdateImplPointers(); | 721 CommitAndUpdateImplPointers(); |
717 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; | 722 LayerImpl* fixed_position_child_impl = great_grand_child_impl_->children()[0]; |
718 | 723 |
719 // Case 1: scroll delta of 0, 0 | 724 // Case 1: scroll delta of 0, 0 |
720 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 725 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 726 child_impl_->SetDrawsContent(true); |
721 ExecuteCalculateDrawProperties(root_impl_); | 727 ExecuteCalculateDrawProperties(root_impl_); |
722 | 728 |
723 gfx::Transform expected_child_transform; | 729 gfx::Transform expected_child_transform; |
724 expected_child_transform.PreconcatTransform(rotation_about_z); | 730 expected_child_transform.PreconcatTransform(rotation_about_z); |
725 | 731 |
726 gfx::Transform expected_grand_child_surface_draw_transform; | 732 gfx::Transform expected_grand_child_surface_draw_transform; |
727 expected_grand_child_surface_draw_transform.PreconcatTransform( | 733 expected_grand_child_surface_draw_transform.PreconcatTransform( |
728 rotation_about_z); | 734 rotation_about_z); |
729 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 735 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
730 | 736 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 898 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
893 | 899 |
894 // This should not confuse the grand_child. If correct, the grand_child would | 900 // This should not confuse the grand_child. If correct, the grand_child would |
895 // still be considered fixed to its container (i.e. "child"). | 901 // still be considered fixed to its container (i.e. "child"). |
896 grand_child_->SetIsContainerForFixedPositionLayers(true); | 902 grand_child_->SetIsContainerForFixedPositionLayers(true); |
897 | 903 |
898 CommitAndUpdateImplPointers(); | 904 CommitAndUpdateImplPointers(); |
899 | 905 |
900 // Case 1: scroll delta of 0, 0 | 906 // Case 1: scroll delta of 0, 0 |
901 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 907 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 908 child_impl_->SetDrawsContent(true); |
902 ExecuteCalculateDrawProperties(root_impl_); | 909 ExecuteCalculateDrawProperties(root_impl_); |
903 | 910 |
904 gfx::Transform expected_child_transform; | 911 gfx::Transform expected_child_transform; |
905 gfx::Transform expected_grand_child_transform; | 912 gfx::Transform expected_grand_child_transform; |
906 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 913 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
907 child_impl_->draw_transform()); | 914 child_impl_->draw_transform()); |
908 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 915 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
909 grand_child_impl_->draw_transform()); | 916 grand_child_impl_->draw_transform()); |
910 | 917 |
911 // Case 2: scroll delta of 10, 10 | 918 // Case 2: scroll delta of 10, 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 969 |
963 // Note carefully - great_grand_child is fixed to bottom right, to test | 970 // Note carefully - great_grand_child is fixed to bottom right, to test |
964 // sizeDelta being applied correctly; the compensation skips the grand_child | 971 // sizeDelta being applied correctly; the compensation skips the grand_child |
965 // because it is fixed to top left. | 972 // because it is fixed to top left. |
966 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 973 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
967 | 974 |
968 CommitAndUpdateImplPointers(); | 975 CommitAndUpdateImplPointers(); |
969 | 976 |
970 // Case 1: scrollDelta | 977 // Case 1: scrollDelta |
971 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 978 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 979 child_impl_->SetDrawsContent(true); |
972 ExecuteCalculateDrawProperties(root_impl_); | 980 ExecuteCalculateDrawProperties(root_impl_); |
973 | 981 |
974 // Here the child is affected by scroll delta, but the fixed position | 982 // Here the child is affected by scroll delta, but the fixed position |
975 // grand_child should not be affected. | 983 // grand_child should not be affected. |
976 gfx::Transform expected_child_transform; | 984 gfx::Transform expected_child_transform; |
977 expected_child_transform.Translate(-10.0, -10.0); | 985 expected_child_transform.Translate(-10.0, -10.0); |
978 | 986 |
979 gfx::Transform expected_grand_child_transform; | 987 gfx::Transform expected_grand_child_transform; |
980 gfx::Transform expected_great_grand_child_transform; | 988 gfx::Transform expected_great_grand_child_transform; |
981 | 989 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); | 1034 great_great_grand_child->SetPositionConstraint(fixed_to_top_left_); |
1027 | 1035 |
1028 CommitAndUpdateImplPointers(); | 1036 CommitAndUpdateImplPointers(); |
1029 | 1037 |
1030 LayerImpl* container1 = child_impl_; | 1038 LayerImpl* container1 = child_impl_; |
1031 LayerImpl* fixed_to_container1 = grand_child_impl_; | 1039 LayerImpl* fixed_to_container1 = grand_child_impl_; |
1032 LayerImpl* container2 = great_grand_child_impl_; | 1040 LayerImpl* container2 = great_grand_child_impl_; |
1033 LayerImpl* fixed_to_container2 = container2->children()[0]; | 1041 LayerImpl* fixed_to_container2 = container2->children()[0]; |
1034 | 1042 |
1035 container1->SetScrollDelta(gfx::Vector2d(0, 15)); | 1043 container1->SetScrollDelta(gfx::Vector2d(0, 15)); |
| 1044 container1->SetDrawsContent(true); |
1036 container2->SetScrollDelta(gfx::Vector2d(30, 0)); | 1045 container2->SetScrollDelta(gfx::Vector2d(30, 0)); |
| 1046 container2->SetDrawsContent(true); |
1037 ExecuteCalculateDrawProperties(root_impl_); | 1047 ExecuteCalculateDrawProperties(root_impl_); |
1038 | 1048 |
1039 gfx::Transform expected_container1_transform; | 1049 gfx::Transform expected_container1_transform; |
1040 expected_container1_transform.Translate(0.0, -15.0); | 1050 expected_container1_transform.Translate(0.0, -15.0); |
1041 | 1051 |
1042 gfx::Transform expected_fixed_to_container1_transform; | 1052 gfx::Transform expected_fixed_to_container1_transform; |
1043 | 1053 |
1044 // Since the container is a descendant of the fixed layer above, | 1054 // Since the container is a descendant of the fixed layer above, |
1045 // the expected draw transform for container2 would not | 1055 // the expected draw transform for container2 would not |
1046 // include the scrollDelta that was applied to container1. | 1056 // include the scrollDelta that was applied to container1. |
(...skipping 25 matching lines...) Expand all Loading... |
1072 scroll_layer_->AddChild(fixed_child); | 1082 scroll_layer_->AddChild(fixed_child); |
1073 fixed_child->SetPositionConstraint(fixed_to_top_left_); | 1083 fixed_child->SetPositionConstraint(fixed_to_top_left_); |
1074 | 1084 |
1075 CommitAndUpdateImplPointers(); | 1085 CommitAndUpdateImplPointers(); |
1076 | 1086 |
1077 LayerImpl* fixed_child_impl = | 1087 LayerImpl* fixed_child_impl = |
1078 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1088 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
1079 | 1089 |
1080 // Case 1: fixed-container size delta of 20, 20 | 1090 // Case 1: fixed-container size delta of 20, 20 |
1081 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 1091 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 1092 scroll_layer_impl_->SetDrawsContent(true); |
1082 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1093 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); |
1083 gfx::Transform expected_scroll_layer_transform; | 1094 gfx::Transform expected_scroll_layer_transform; |
1084 expected_scroll_layer_transform.Translate(-10.0, -10.0); | 1095 expected_scroll_layer_transform.Translate(-10.0, -10.0); |
1085 gfx::Transform expected_fixed_child_transform; | 1096 gfx::Transform expected_fixed_child_transform; |
1086 | 1097 |
1087 ExecuteCalculateDrawProperties(root_impl_); | 1098 ExecuteCalculateDrawProperties(root_impl_); |
1088 | 1099 |
1089 // Top-left fixed-position layer should not be affected by container size. | 1100 // Top-left fixed-position layer should not be affected by container size. |
1090 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1101 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
1091 scroll_layer_impl_->draw_transform()); | 1102 scroll_layer_impl_->draw_transform()); |
(...skipping 16 matching lines...) Expand all Loading... |
1108 expected_fixed_child_transform.Translate(20.0, 20.0); | 1119 expected_fixed_child_transform.Translate(20.0, 20.0); |
1109 | 1120 |
1110 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1121 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
1111 scroll_layer_impl_->draw_transform()); | 1122 scroll_layer_impl_->draw_transform()); |
1112 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1123 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
1113 fixed_child_impl->draw_transform()); | 1124 fixed_child_impl->draw_transform()); |
1114 } | 1125 } |
1115 | 1126 |
1116 } // namespace | 1127 } // namespace |
1117 } // namespace cc | 1128 } // namespace cc |
OLD | NEW |