| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 root->SetDrawsContent(true); | 334 root->SetDrawsContent(true); |
| 335 target->SetDrawsContent(true); | 335 target->SetDrawsContent(true); |
| 336 target->SetMasksToBounds(true); | 336 target->SetMasksToBounds(true); |
| 337 drawing_layer->SetDrawsContent(true); | 337 drawing_layer->SetDrawsContent(true); |
| 338 | 338 |
| 339 root->SetBounds(gfx::Size(500, 500)); | 339 root->SetBounds(gfx::Size(500, 500)); |
| 340 root->test_properties()->force_render_surface = true; | 340 root->test_properties()->force_render_surface = true; |
| 341 target->SetPosition(gfx::PointF(target_rect.origin())); | 341 target->SetPosition(gfx::PointF(target_rect.origin())); |
| 342 target->SetBounds(target_rect.size()); | 342 target->SetBounds(target_rect.size()); |
| 343 target->test_properties()->force_render_surface = true; | 343 target->test_properties()->force_render_surface = true; |
| 344 drawing_layer->SetTransform(layer_transform); | 344 drawing_layer->test_properties()->transform = layer_transform; |
| 345 drawing_layer->SetPosition(gfx::PointF(layer_rect.origin())); | 345 drawing_layer->SetPosition(gfx::PointF(layer_rect.origin())); |
| 346 drawing_layer->SetBounds(layer_rect.size()); | 346 drawing_layer->SetBounds(layer_rect.size()); |
| 347 drawing_layer->test_properties()->should_flatten_transform = false; | 347 drawing_layer->test_properties()->should_flatten_transform = false; |
| 348 | 348 |
| 349 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 349 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 350 ExecuteCalculateDrawProperties(root); | 350 ExecuteCalculateDrawProperties(root); |
| 351 | 351 |
| 352 return drawing_layer; | 352 return drawing_layer; |
| 353 } | 353 } |
| 354 }; | 354 }; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); | 444 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); |
| 445 EXPECT_TRANSFORMATION_MATRIX_EQ( | 445 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 446 position_transform, | 446 position_transform, |
| 447 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); | 447 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); |
| 448 | 448 |
| 449 // Case 4: In the correct sequence of transforms, the layer transform should | 449 // Case 4: In the correct sequence of transforms, the layer transform should |
| 450 // pre-multiply the translation-to-center. This is easily tested by using a | 450 // pre-multiply the translation-to-center. This is easily tested by using a |
| 451 // scale transform, because scale and translation are not commutative. | 451 // scale transform, because scale and translation are not commutative. |
| 452 gfx::Transform layer_transform; | 452 gfx::Transform layer_transform; |
| 453 layer_transform.Scale3d(2.0, 2.0, 1.0); | 453 layer_transform.Scale3d(2.0, 2.0, 1.0); |
| 454 layer->SetTransform(layer_transform); | 454 layer->test_properties()->transform = layer_transform; |
| 455 layer->test_properties()->transform_origin = gfx::Point3F(); | 455 layer->test_properties()->transform_origin = gfx::Point3F(); |
| 456 layer->SetPosition(gfx::PointF()); | 456 layer->SetPosition(gfx::PointF()); |
| 457 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 457 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 458 ExecuteCalculateDrawProperties(root); | 458 ExecuteCalculateDrawProperties(root); |
| 459 EXPECT_TRANSFORMATION_MATRIX_EQ( | 459 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 460 layer_transform, | 460 layer_transform, |
| 461 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); | 461 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); |
| 462 EXPECT_TRANSFORMATION_MATRIX_EQ( | 462 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 463 layer_transform, | 463 layer_transform, |
| 464 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); | 464 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 page_scale * kDeviceScale); | 558 page_scale * kDeviceScale); |
| 559 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 559 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
| 560 sublayer->DrawTransform()); | 560 sublayer->DrawTransform()); |
| 561 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 561 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
| 562 sublayer->ScreenSpaceTransform()); | 562 sublayer->ScreenSpaceTransform()); |
| 563 | 563 |
| 564 gfx::Transform arbitrary_translate; | 564 gfx::Transform arbitrary_translate; |
| 565 const float kTranslateX = 10.6f; | 565 const float kTranslateX = 10.6f; |
| 566 const float kTranslateY = 20.6f; | 566 const float kTranslateY = 20.6f; |
| 567 arbitrary_translate.Translate(kTranslateX, kTranslateY); | 567 arbitrary_translate.Translate(kTranslateX, kTranslateY); |
| 568 scroll_layer->SetTransform(arbitrary_translate); | 568 scroll_layer->test_properties()->transform = arbitrary_translate; |
| 569 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 569 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 570 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, | 570 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, |
| 571 scroll_layer->test_properties()->parent); | 571 scroll_layer->test_properties()->parent); |
| 572 expected_transform.MakeIdentity(); | 572 expected_transform.MakeIdentity(); |
| 573 expected_transform.Translate( | 573 expected_transform.Translate( |
| 574 MathUtil::Round(kTranslateX * page_scale * kDeviceScale + | 574 MathUtil::Round(kTranslateX * page_scale * kDeviceScale + |
| 575 sub_layer_screen_position.x() * page_scale * | 575 sub_layer_screen_position.x() * page_scale * |
| 576 kDeviceScale), | 576 kDeviceScale), |
| 577 MathUtil::Round(kTranslateY * page_scale * kDeviceScale + | 577 MathUtil::Round(kTranslateY * page_scale * kDeviceScale + |
| 578 sub_layer_screen_position.y() * page_scale * | 578 sub_layer_screen_position.y() * page_scale * |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree)); | 660 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree)); |
| 661 | 661 |
| 662 // Case 3: parent's local transform affects child and grandchild | 662 // Case 3: parent's local transform affects child and grandchild |
| 663 gfx::Transform parent_layer_transform; | 663 gfx::Transform parent_layer_transform; |
| 664 parent_layer_transform.Scale3d(2.0, 2.0, 1.0); | 664 parent_layer_transform.Scale3d(2.0, 2.0, 1.0); |
| 665 gfx::Transform parent_translation_to_anchor; | 665 gfx::Transform parent_translation_to_anchor; |
| 666 parent_translation_to_anchor.Translate(2.5, 3.0); | 666 parent_translation_to_anchor.Translate(2.5, 3.0); |
| 667 gfx::Transform parent_composite_transform = | 667 gfx::Transform parent_composite_transform = |
| 668 parent_translation_to_anchor * parent_layer_transform * | 668 parent_translation_to_anchor * parent_layer_transform * |
| 669 Inverse(parent_translation_to_anchor); | 669 Inverse(parent_translation_to_anchor); |
| 670 parent->SetTransform(parent_layer_transform); | 670 parent->test_properties()->transform = parent_layer_transform; |
| 671 parent->SetPosition(gfx::PointF()); | 671 parent->SetPosition(gfx::PointF()); |
| 672 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 672 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 673 ExecuteCalculateDrawProperties(root); | 673 ExecuteCalculateDrawProperties(root); |
| 674 EXPECT_TRANSFORMATION_MATRIX_EQ( | 674 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 675 parent_composite_transform, | 675 parent_composite_transform, |
| 676 draw_property_utils::DrawTransform(child, transform_tree, effect_tree)); | 676 draw_property_utils::DrawTransform(child, transform_tree, effect_tree)); |
| 677 EXPECT_TRANSFORMATION_MATRIX_EQ( | 677 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 678 parent_composite_transform, | 678 parent_composite_transform, |
| 679 draw_property_utils::ScreenSpaceTransform(child, transform_tree)); | 679 draw_property_utils::ScreenSpaceTransform(child, transform_tree)); |
| 680 EXPECT_TRANSFORMATION_MATRIX_EQ( | 680 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 703 gfx::Vector2dF parent_composite_scale = | 703 gfx::Vector2dF parent_composite_scale = |
| 704 MathUtil::ComputeTransform2dScaleComponents(parent_composite_transform, | 704 MathUtil::ComputeTransform2dScaleComponents(parent_composite_transform, |
| 705 1.f); | 705 1.f); |
| 706 gfx::Transform surface_sublayer_transform; | 706 gfx::Transform surface_sublayer_transform; |
| 707 surface_sublayer_transform.Scale(parent_composite_scale.x(), | 707 surface_sublayer_transform.Scale(parent_composite_scale.x(), |
| 708 parent_composite_scale.y()); | 708 parent_composite_scale.y()); |
| 709 gfx::Transform surface_sublayer_composite_transform = | 709 gfx::Transform surface_sublayer_composite_transform = |
| 710 parent_composite_transform * Inverse(surface_sublayer_transform); | 710 parent_composite_transform * Inverse(surface_sublayer_transform); |
| 711 | 711 |
| 712 root->SetBounds(gfx::Size(1, 2)); | 712 root->SetBounds(gfx::Size(1, 2)); |
| 713 parent->SetTransform(parent_layer_transform); | 713 parent->test_properties()->transform = parent_layer_transform; |
| 714 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 30.f, 0.f); | 714 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 30.f, 0.f); |
| 715 parent->SetBounds(gfx::Size(100, 120)); | 715 parent->SetBounds(gfx::Size(100, 120)); |
| 716 child->SetBounds(gfx::Size(16, 18)); | 716 child->SetBounds(gfx::Size(16, 18)); |
| 717 child->test_properties()->force_render_surface = true; | 717 child->test_properties()->force_render_surface = true; |
| 718 grand_child->SetBounds(gfx::Size(8, 10)); | 718 grand_child->SetBounds(gfx::Size(8, 10)); |
| 719 grand_child->SetDrawsContent(true); | 719 grand_child->SetDrawsContent(true); |
| 720 ExecuteCalculateDrawProperties(root); | 720 ExecuteCalculateDrawProperties(root); |
| 721 | 721 |
| 722 // Render surface should have been created now. | 722 // Render surface should have been created now. |
| 723 ASSERT_TRUE(child->render_surface()); | 723 ASSERT_TRUE(child->render_surface()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 749 LayerImpl* child = AddChild<LayerImpl>(parent); | 749 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 750 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 750 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 751 | 751 |
| 752 gfx::Transform parent_transform; | 752 gfx::Transform parent_transform; |
| 753 parent_transform.Translate(10.0, 10.0); | 753 parent_transform.Translate(10.0, 10.0); |
| 754 | 754 |
| 755 gfx::Transform child_transform; | 755 gfx::Transform child_transform; |
| 756 child_transform.Rotate(45.0); | 756 child_transform.Rotate(45.0); |
| 757 | 757 |
| 758 root->SetBounds(gfx::Size(100, 100)); | 758 root->SetBounds(gfx::Size(100, 100)); |
| 759 parent->SetTransform(parent_transform); | 759 parent->test_properties()->transform = parent_transform; |
| 760 parent->SetBounds(gfx::Size(10, 10)); | 760 parent->SetBounds(gfx::Size(10, 10)); |
| 761 child->SetTransform(child_transform); | 761 child->test_properties()->transform = child_transform; |
| 762 child->SetBounds(gfx::Size(10, 10)); | 762 child->SetBounds(gfx::Size(10, 10)); |
| 763 child->test_properties()->force_render_surface = true; | 763 child->test_properties()->force_render_surface = true; |
| 764 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); | 764 grand_child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 765 grand_child->SetBounds(gfx::Size(20, 20)); | 765 grand_child->SetBounds(gfx::Size(20, 20)); |
| 766 grand_child->SetDrawsContent(true); | 766 grand_child->SetDrawsContent(true); |
| 767 | 767 |
| 768 gfx::Transform expected_grand_child_screen_space_transform; | 768 gfx::Transform expected_grand_child_screen_space_transform; |
| 769 expected_grand_child_screen_space_transform.Translate(10.0, 10.0); | 769 expected_grand_child_screen_space_transform.Translate(10.0, 10.0); |
| 770 expected_grand_child_screen_space_transform.Rotate(45.0); | 770 expected_grand_child_screen_space_transform.Rotate(45.0); |
| 771 expected_grand_child_screen_space_transform.Translate(2.0, 2.0); | 771 expected_grand_child_screen_space_transform.Translate(2.0, 2.0); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 1.f); | 813 1.f); |
| 814 gfx::Transform surface_sublayer_transform; | 814 gfx::Transform surface_sublayer_transform; |
| 815 surface_sublayer_transform.Scale(parent_composite_scale.x(), | 815 surface_sublayer_transform.Scale(parent_composite_scale.x(), |
| 816 parent_composite_scale.y()); | 816 parent_composite_scale.y()); |
| 817 gfx::Transform replica_composite_transform = | 817 gfx::Transform replica_composite_transform = |
| 818 parent_composite_transform * replica_layer_transform * | 818 parent_composite_transform * replica_layer_transform * |
| 819 Inverse(surface_sublayer_transform); | 819 Inverse(surface_sublayer_transform); |
| 820 | 820 |
| 821 root->SetBounds(gfx::Size(1, 2)); | 821 root->SetBounds(gfx::Size(1, 2)); |
| 822 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 3.0f, 0.f); | 822 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 3.0f, 0.f); |
| 823 parent->SetTransform(parent_layer_transform); | 823 parent->test_properties()->transform = parent_layer_transform; |
| 824 parent->SetBounds(gfx::Size(10, 12)); | 824 parent->SetBounds(gfx::Size(10, 12)); |
| 825 child->SetBounds(gfx::Size(16, 18)); | 825 child->SetBounds(gfx::Size(16, 18)); |
| 826 child->test_properties()->force_render_surface = true; | 826 child->test_properties()->force_render_surface = true; |
| 827 grand_child->SetPosition(gfx::PointF(-0.5f, -0.5f)); | 827 grand_child->SetPosition(gfx::PointF(-0.5f, -0.5f)); |
| 828 grand_child->SetBounds(gfx::Size(1, 1)); | 828 grand_child->SetBounds(gfx::Size(1, 1)); |
| 829 | 829 |
| 830 child_replica->SetTransform(replica_layer_transform); | 830 child_replica->test_properties()->transform = replica_layer_transform; |
| 831 child->test_properties()->SetReplicaLayer(std::move(child_replica)); | 831 child->test_properties()->SetReplicaLayer(std::move(child_replica)); |
| 832 | 832 |
| 833 ExecuteCalculateDrawProperties(root); | 833 ExecuteCalculateDrawProperties(root); |
| 834 | 834 |
| 835 // Render surface should have been created now. | 835 // Render surface should have been created now. |
| 836 ASSERT_TRUE(child->render_surface()); | 836 ASSERT_TRUE(child->render_surface()); |
| 837 ASSERT_EQ(child->render_surface(), child->render_target()); | 837 ASSERT_EQ(child->render_surface(), child->render_target()); |
| 838 | 838 |
| 839 EXPECT_TRANSFORMATION_MATRIX_EQ( | 839 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 840 replica_composite_transform, | 840 replica_composite_transform, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 surface2_parent_transform_scale.y()); | 922 surface2_parent_transform_scale.y()); |
| 923 | 923 |
| 924 // SS2 = transform given to the subtree of render_surface2 | 924 // SS2 = transform given to the subtree of render_surface2 |
| 925 gfx::Transform SS2 = surface2_sublayer_transform; | 925 gfx::Transform SS2 = surface2_sublayer_transform; |
| 926 // S2 = transform to move from render_surface2 pixels to the layer space of | 926 // S2 = transform to move from render_surface2 pixels to the layer space of |
| 927 // the owning layer | 927 // the owning layer |
| 928 gfx::Transform S2 = Inverse(surface2_sublayer_transform); | 928 gfx::Transform S2 = Inverse(surface2_sublayer_transform); |
| 929 | 929 |
| 930 root->SetBounds(gfx::Size(1, 2)); | 930 root->SetBounds(gfx::Size(1, 2)); |
| 931 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 0.f, 0.f); | 931 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 0.f, 0.f); |
| 932 parent->SetTransform(layer_transform); | 932 parent->test_properties()->transform = layer_transform; |
| 933 parent->SetBounds(gfx::Size(10, 10)); | 933 parent->SetBounds(gfx::Size(10, 10)); |
| 934 render_surface1->test_properties()->transform_origin = | 934 render_surface1->test_properties()->transform_origin = |
| 935 gfx::Point3F(2.5f, 0.f, 0.f); | 935 gfx::Point3F(2.5f, 0.f, 0.f); |
| 936 render_surface1->SetTransform(layer_transform); | 936 render_surface1->test_properties()->transform = layer_transform; |
| 937 render_surface1->SetBounds(gfx::Size(10, 10)); | 937 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 938 render_surface1->test_properties()->force_render_surface = true; | 938 render_surface1->test_properties()->force_render_surface = true; |
| 939 render_surface2->test_properties()->transform_origin = | 939 render_surface2->test_properties()->transform_origin = |
| 940 gfx::Point3F(2.5f, 0.f, 0.f); | 940 gfx::Point3F(2.5f, 0.f, 0.f); |
| 941 render_surface2->SetTransform(layer_transform); | 941 render_surface2->test_properties()->transform = layer_transform; |
| 942 render_surface2->SetBounds(gfx::Size(10, 10)); | 942 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 943 render_surface2->test_properties()->force_render_surface = true; | 943 render_surface2->test_properties()->force_render_surface = true; |
| 944 child_of_root->test_properties()->transform_origin = | 944 child_of_root->test_properties()->transform_origin = |
| 945 gfx::Point3F(2.5f, 0.f, 0.f); | 945 gfx::Point3F(2.5f, 0.f, 0.f); |
| 946 child_of_root->SetTransform(layer_transform); | 946 child_of_root->test_properties()->transform = layer_transform; |
| 947 child_of_root->SetBounds(gfx::Size(10, 10)); | 947 child_of_root->SetBounds(gfx::Size(10, 10)); |
| 948 child_of_rs1->test_properties()->transform_origin = | 948 child_of_rs1->test_properties()->transform_origin = |
| 949 gfx::Point3F(2.5f, 0.f, 0.f); | 949 gfx::Point3F(2.5f, 0.f, 0.f); |
| 950 child_of_rs1->SetTransform(layer_transform); | 950 child_of_rs1->test_properties()->transform = layer_transform; |
| 951 child_of_rs1->SetBounds(gfx::Size(10, 10)); | 951 child_of_rs1->SetBounds(gfx::Size(10, 10)); |
| 952 child_of_rs2->test_properties()->transform_origin = | 952 child_of_rs2->test_properties()->transform_origin = |
| 953 gfx::Point3F(2.5f, 0.f, 0.f); | 953 gfx::Point3F(2.5f, 0.f, 0.f); |
| 954 child_of_rs2->SetTransform(layer_transform); | 954 child_of_rs2->test_properties()->transform = layer_transform; |
| 955 child_of_rs2->SetBounds(gfx::Size(10, 10)); | 955 child_of_rs2->SetBounds(gfx::Size(10, 10)); |
| 956 grand_child_of_root->test_properties()->transform_origin = | 956 grand_child_of_root->test_properties()->transform_origin = |
| 957 gfx::Point3F(2.5f, 0.f, 0.f); | 957 gfx::Point3F(2.5f, 0.f, 0.f); |
| 958 grand_child_of_root->SetTransform(layer_transform); | 958 grand_child_of_root->test_properties()->transform = layer_transform; |
| 959 grand_child_of_root->SetBounds(gfx::Size(10, 10)); | 959 grand_child_of_root->SetBounds(gfx::Size(10, 10)); |
| 960 grand_child_of_rs1->test_properties()->transform_origin = | 960 grand_child_of_rs1->test_properties()->transform_origin = |
| 961 gfx::Point3F(2.5f, 0.f, 0.f); | 961 gfx::Point3F(2.5f, 0.f, 0.f); |
| 962 grand_child_of_rs1->SetTransform(layer_transform); | 962 grand_child_of_rs1->test_properties()->transform = layer_transform; |
| 963 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); | 963 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); |
| 964 grand_child_of_rs2->test_properties()->transform_origin = | 964 grand_child_of_rs2->test_properties()->transform_origin = |
| 965 gfx::Point3F(2.5f, 0.f, 0.f); | 965 gfx::Point3F(2.5f, 0.f, 0.f); |
| 966 grand_child_of_rs2->SetTransform(layer_transform); | 966 grand_child_of_rs2->test_properties()->transform = layer_transform; |
| 967 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); | 967 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); |
| 968 replica_of_rs1->test_properties()->transform_origin = | 968 replica_of_rs1->test_properties()->transform_origin = |
| 969 gfx::Point3F(2.5f, 0.f, 0.f); | 969 gfx::Point3F(2.5f, 0.f, 0.f); |
| 970 replica_of_rs1->SetTransform(replica_layer_transform); | 970 replica_of_rs1->test_properties()->transform = replica_layer_transform; |
| 971 replica_of_rs2->test_properties()->transform_origin = | 971 replica_of_rs2->test_properties()->transform_origin = |
| 972 gfx::Point3F(2.5f, 0.f, 0.f); | 972 gfx::Point3F(2.5f, 0.f, 0.f); |
| 973 replica_of_rs2->SetTransform(replica_layer_transform); | 973 replica_of_rs2->test_properties()->transform = replica_layer_transform; |
| 974 | 974 |
| 975 // We need to set parent on replica layers for property tree building. | 975 // We need to set parent on replica layers for property tree building. |
| 976 replica_of_rs1->test_properties()->parent = render_surface1; | 976 replica_of_rs1->test_properties()->parent = render_surface1; |
| 977 replica_of_rs2->test_properties()->parent = render_surface2; | 977 replica_of_rs2->test_properties()->parent = render_surface2; |
| 978 render_surface1->test_properties()->SetReplicaLayer( | 978 render_surface1->test_properties()->SetReplicaLayer( |
| 979 std::move(replica_of_rs1)); | 979 std::move(replica_of_rs1)); |
| 980 render_surface2->test_properties()->SetReplicaLayer( | 980 render_surface2->test_properties()->SetReplicaLayer( |
| 981 std::move(replica_of_rs2)); | 981 std::move(replica_of_rs2)); |
| 982 ExecuteCalculateDrawProperties(root); | 982 ExecuteCalculateDrawProperties(root); |
| 983 | 983 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 child->SetDrawsContent(true); | 1110 child->SetDrawsContent(true); |
| 1111 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1111 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1112 grand_child->SetDrawsContent(true); | 1112 grand_child->SetDrawsContent(true); |
| 1113 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); | 1113 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); |
| 1114 great_grand_child->SetDrawsContent(true); | 1114 great_grand_child->SetDrawsContent(true); |
| 1115 | 1115 |
| 1116 gfx::Transform rotation_about_y_axis; | 1116 gfx::Transform rotation_about_y_axis; |
| 1117 rotation_about_y_axis.RotateAboutYAxis(30.0); | 1117 rotation_about_y_axis.RotateAboutYAxis(30.0); |
| 1118 | 1118 |
| 1119 root->SetBounds(gfx::Size(100, 100)); | 1119 root->SetBounds(gfx::Size(100, 100)); |
| 1120 child->SetTransform(rotation_about_y_axis); | 1120 child->test_properties()->transform = rotation_about_y_axis; |
| 1121 child->SetBounds(gfx::Size(10, 10)); | 1121 child->SetBounds(gfx::Size(10, 10)); |
| 1122 child->test_properties()->force_render_surface = true; | 1122 child->test_properties()->force_render_surface = true; |
| 1123 grand_child->SetTransform(rotation_about_y_axis); | 1123 grand_child->test_properties()->transform = rotation_about_y_axis; |
| 1124 grand_child->SetBounds(gfx::Size(10, 10)); | 1124 grand_child->SetBounds(gfx::Size(10, 10)); |
| 1125 great_grand_child->SetBounds(gfx::Size(10, 10)); | 1125 great_grand_child->SetBounds(gfx::Size(10, 10)); |
| 1126 | 1126 |
| 1127 // No layers in this test should preserve 3d. | 1127 // No layers in this test should preserve 3d. |
| 1128 ASSERT_TRUE(root->test_properties()->should_flatten_transform); | 1128 ASSERT_TRUE(root->test_properties()->should_flatten_transform); |
| 1129 ASSERT_TRUE(child->test_properties()->should_flatten_transform); | 1129 ASSERT_TRUE(child->test_properties()->should_flatten_transform); |
| 1130 ASSERT_TRUE(grand_child->test_properties()->should_flatten_transform); | 1130 ASSERT_TRUE(grand_child->test_properties()->should_flatten_transform); |
| 1131 ASSERT_TRUE(great_grand_child->test_properties()->should_flatten_transform); | 1131 ASSERT_TRUE(great_grand_child->test_properties()->should_flatten_transform); |
| 1132 | 1132 |
| 1133 gfx::Transform expected_child_draw_transform = rotation_about_y_axis; | 1133 gfx::Transform expected_child_draw_transform = rotation_about_y_axis; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1172 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1173 | 1173 |
| 1174 gfx::Transform child_transform; | 1174 gfx::Transform child_transform; |
| 1175 child_transform.Translate(50.0, 50.0); | 1175 child_transform.Translate(50.0, 50.0); |
| 1176 child_transform.RotateAboutZAxis(30.0); | 1176 child_transform.RotateAboutZAxis(30.0); |
| 1177 | 1177 |
| 1178 gfx::Transform grand_child_transform; | 1178 gfx::Transform grand_child_transform; |
| 1179 grand_child_transform.RotateAboutYAxis(90.0); | 1179 grand_child_transform.RotateAboutYAxis(90.0); |
| 1180 | 1180 |
| 1181 root->SetBounds(gfx::Size(200, 200)); | 1181 root->SetBounds(gfx::Size(200, 200)); |
| 1182 child->SetTransform(child_transform); | 1182 child->test_properties()->transform = child_transform; |
| 1183 child->SetBounds(gfx::Size(10, 10)); | 1183 child->SetBounds(gfx::Size(10, 10)); |
| 1184 grand_child->SetTransform(grand_child_transform); | 1184 grand_child->test_properties()->transform = grand_child_transform; |
| 1185 grand_child->SetBounds(gfx::Size(100, 100)); | 1185 grand_child->SetBounds(gfx::Size(100, 100)); |
| 1186 grand_child->test_properties()->should_flatten_transform = false; | 1186 grand_child->test_properties()->should_flatten_transform = false; |
| 1187 grand_child->SetDrawsContent(true); | 1187 grand_child->SetDrawsContent(true); |
| 1188 ExecuteCalculateDrawProperties(root); | 1188 ExecuteCalculateDrawProperties(root); |
| 1189 | 1189 |
| 1190 // Mapping grand_child's bounds to target space produces a non-empty rect | 1190 // Mapping grand_child's bounds to target space produces a non-empty rect |
| 1191 // that is fully contained within the target's bounds, so grand_child should | 1191 // that is fully contained within the target's bounds, so grand_child should |
| 1192 // be considered fully visible. | 1192 // be considered fully visible. |
| 1193 EXPECT_EQ(gfx::Rect(grand_child->bounds()), | 1193 EXPECT_EQ(gfx::Rect(grand_child->bounds()), |
| 1194 grand_child->visible_layer_rect()); | 1194 grand_child->visible_layer_rect()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { | 1229 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { |
| 1230 LayerImpl* root = root_layer_for_testing(); | 1230 LayerImpl* root = root_layer_for_testing(); |
| 1231 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 1231 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 1232 LayerImpl* child = AddChild<LayerImpl>(render_surface); | 1232 LayerImpl* child = AddChild<LayerImpl>(render_surface); |
| 1233 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1233 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1234 | 1234 |
| 1235 gfx::Transform translate; | 1235 gfx::Transform translate; |
| 1236 translate.Translate3d(5, 5, 5); | 1236 translate.Translate3d(5, 5, 5); |
| 1237 | 1237 |
| 1238 root->SetBounds(gfx::Size(100, 100)); | 1238 root->SetBounds(gfx::Size(100, 100)); |
| 1239 render_surface->SetTransform(translate); | 1239 render_surface->test_properties()->transform = translate; |
| 1240 render_surface->SetBounds(gfx::Size(100, 100)); | 1240 render_surface->SetBounds(gfx::Size(100, 100)); |
| 1241 render_surface->test_properties()->force_render_surface = true; | 1241 render_surface->test_properties()->force_render_surface = true; |
| 1242 child->SetTransform(translate); | 1242 child->test_properties()->transform = translate; |
| 1243 child->SetBounds(gfx::Size(100, 100)); | 1243 child->SetBounds(gfx::Size(100, 100)); |
| 1244 grand_child->SetTransform(translate); | 1244 grand_child->test_properties()->transform = translate; |
| 1245 grand_child->SetBounds(gfx::Size(100, 100)); | 1245 grand_child->SetBounds(gfx::Size(100, 100)); |
| 1246 grand_child->SetDrawsContent(true); | 1246 grand_child->SetDrawsContent(true); |
| 1247 | 1247 |
| 1248 // render_surface will have a sublayer scale because of device scale factor. | 1248 // render_surface will have a sublayer scale because of device scale factor. |
| 1249 float device_scale_factor = 2.0f; | 1249 float device_scale_factor = 2.0f; |
| 1250 LayerImplList render_surface_layer_list_impl; | 1250 LayerImplList render_surface_layer_list_impl; |
| 1251 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1251 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1252 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1252 root, root->bounds(), translate, &render_surface_layer_list_impl); |
| 1253 inputs.device_scale_factor = device_scale_factor; | 1253 inputs.device_scale_factor = device_scale_factor; |
| 1254 inputs.property_trees->needs_rebuild = true; | 1254 inputs.property_trees->needs_rebuild = true; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); | 1376 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); |
| 1377 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1377 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1378 page_scaled_translate, root->draw_properties().target_space_transform); | 1378 page_scaled_translate, root->draw_properties().target_space_transform); |
| 1379 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1379 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1380 page_scaled_translate, child->draw_properties().target_space_transform); | 1380 page_scaled_translate, child->draw_properties().target_space_transform); |
| 1381 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1381 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1382 root->render_surface()->draw_transform()); | 1382 root->render_surface()->draw_transform()); |
| 1383 } | 1383 } |
| 1384 | 1384 |
| 1385 // Verify that it composes correctly with transforms directly on root layer. | 1385 // Verify that it composes correctly with transforms directly on root layer. |
| 1386 root->SetTransform(composite); | 1386 root->test_properties()->transform = composite; |
| 1387 | 1387 |
| 1388 { | 1388 { |
| 1389 LayerImplList render_surface_layer_list_impl; | 1389 LayerImplList render_surface_layer_list_impl; |
| 1390 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1390 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1391 root, root->bounds(), composite, &render_surface_layer_list_impl); | 1391 root, root->bounds(), composite, &render_surface_layer_list_impl); |
| 1392 inputs.property_trees->needs_rebuild = true; | 1392 inputs.property_trees->needs_rebuild = true; |
| 1393 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1393 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1394 gfx::Transform compositeSquared = composite; | 1394 gfx::Transform compositeSquared = composite; |
| 1395 compositeSquared.ConcatTransform(composite); | 1395 compositeSquared.ConcatTransform(composite); |
| 1396 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1396 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { | 1509 TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) { |
| 1510 LayerImpl* root = root_layer_for_testing(); | 1510 LayerImpl* root = root_layer_for_testing(); |
| 1511 LayerImpl* parent = AddChild<LayerImpl>(root); | 1511 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 1512 LayerImpl* child1 = AddChild<LayerImpl>(parent); | 1512 LayerImpl* child1 = AddChild<LayerImpl>(parent); |
| 1513 LayerImpl* child2 = AddChild<LayerImpl>(parent); | 1513 LayerImpl* child2 = AddChild<LayerImpl>(parent); |
| 1514 | 1514 |
| 1515 gfx::Transform scale_matrix; | 1515 gfx::Transform scale_matrix; |
| 1516 scale_matrix.Scale(2.0f, 2.0f); | 1516 scale_matrix.Scale(2.0f, 2.0f); |
| 1517 | 1517 |
| 1518 root->SetBounds(gfx::Size(100, 100)); | 1518 root->SetBounds(gfx::Size(100, 100)); |
| 1519 parent->SetTransform(scale_matrix); | 1519 parent->test_properties()->transform = scale_matrix; |
| 1520 FilterOperations filters; | 1520 FilterOperations filters; |
| 1521 filters.Append(FilterOperation::CreateBlurFilter(10.0f)); | 1521 filters.Append(FilterOperation::CreateBlurFilter(10.0f)); |
| 1522 parent->test_properties()->filters = filters; | 1522 parent->test_properties()->filters = filters; |
| 1523 parent->test_properties()->force_render_surface = true; | 1523 parent->test_properties()->force_render_surface = true; |
| 1524 child1->SetBounds(gfx::Size(25, 25)); | 1524 child1->SetBounds(gfx::Size(25, 25)); |
| 1525 child1->SetDrawsContent(true); | 1525 child1->SetDrawsContent(true); |
| 1526 child1->test_properties()->force_render_surface = true; | 1526 child1->test_properties()->force_render_surface = true; |
| 1527 child2->SetPosition(gfx::PointF(25, 25)); | 1527 child2->SetPosition(gfx::PointF(25, 25)); |
| 1528 child2->SetBounds(gfx::Size(25, 25)); | 1528 child2->SetBounds(gfx::Size(25, 25)); |
| 1529 child2->SetDrawsContent(true); | 1529 child2->SetDrawsContent(true); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 // always flatten the target-to-screen space transform seen by descendants. | 1738 // always flatten the target-to-screen space transform seen by descendants. |
| 1739 LayerImpl* root = root_layer_for_testing(); | 1739 LayerImpl* root = root_layer_for_testing(); |
| 1740 LayerImpl* parent = AddChild<LayerImpl>(root); | 1740 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 1741 LayerImpl* child = AddChild<LayerImpl>(parent); | 1741 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 1742 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1742 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1743 | 1743 |
| 1744 gfx::Transform rotation_about_y_axis; | 1744 gfx::Transform rotation_about_y_axis; |
| 1745 rotation_about_y_axis.RotateAboutYAxis(30.0); | 1745 rotation_about_y_axis.RotateAboutYAxis(30.0); |
| 1746 | 1746 |
| 1747 root->SetBounds(gfx::Size(100, 100)); | 1747 root->SetBounds(gfx::Size(100, 100)); |
| 1748 parent->SetTransform(rotation_about_y_axis); | 1748 parent->test_properties()->transform = rotation_about_y_axis; |
| 1749 parent->SetBounds(gfx::Size(10, 10)); | 1749 parent->SetBounds(gfx::Size(10, 10)); |
| 1750 parent->test_properties()->force_render_surface = true; | 1750 parent->test_properties()->force_render_surface = true; |
| 1751 child->SetBounds(gfx::Size(10, 10)); | 1751 child->SetBounds(gfx::Size(10, 10)); |
| 1752 child->SetDrawsContent(true); | 1752 child->SetDrawsContent(true); |
| 1753 grand_child->SetBounds(gfx::Size(10, 10)); | 1753 grand_child->SetBounds(gfx::Size(10, 10)); |
| 1754 grand_child->SetDrawsContent(true); | 1754 grand_child->SetDrawsContent(true); |
| 1755 grand_child->test_properties()->should_flatten_transform = false; | 1755 grand_child->test_properties()->should_flatten_transform = false; |
| 1756 ExecuteCalculateDrawProperties(root); | 1756 ExecuteCalculateDrawProperties(root); |
| 1757 | 1757 |
| 1758 EXPECT_TRUE(parent->render_surface()); | 1758 EXPECT_TRUE(parent->render_surface()); |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2530 grand_child_of_rs1->SetDrawsContent(true); | 2530 grand_child_of_rs1->SetDrawsContent(true); |
| 2531 render_surface2->SetDrawsContent(true); | 2531 render_surface2->SetDrawsContent(true); |
| 2532 child_of_rs2->SetDrawsContent(true); | 2532 child_of_rs2->SetDrawsContent(true); |
| 2533 grand_child_of_rs2->SetDrawsContent(true); | 2533 grand_child_of_rs2->SetDrawsContent(true); |
| 2534 child_of_root->SetDrawsContent(true); | 2534 child_of_root->SetDrawsContent(true); |
| 2535 grand_child_of_root->SetDrawsContent(true); | 2535 grand_child_of_root->SetDrawsContent(true); |
| 2536 | 2536 |
| 2537 gfx::Transform layer_transform; | 2537 gfx::Transform layer_transform; |
| 2538 layer_transform.Translate(1.0, 1.0); | 2538 layer_transform.Translate(1.0, 1.0); |
| 2539 | 2539 |
| 2540 root->SetTransform(layer_transform); | 2540 root->test_properties()->transform = layer_transform; |
| 2541 root->SetPosition(gfx::PointF(2.5f, 0.f)); | 2541 root->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2542 root->SetBounds(gfx::Size(10, 10)); | 2542 root->SetBounds(gfx::Size(10, 10)); |
| 2543 root->test_properties()->transform_origin = gfx::Point3F(0.25f, 0.f, 0.f); | 2543 root->test_properties()->transform_origin = gfx::Point3F(0.25f, 0.f, 0.f); |
| 2544 render_surface1->SetTransform(layer_transform); | 2544 render_surface1->test_properties()->transform = layer_transform; |
| 2545 render_surface1->SetPosition(gfx::PointF(2.5f, 0.f)); | 2545 render_surface1->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2546 render_surface1->SetBounds(gfx::Size(10, 10)); | 2546 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 2547 render_surface1->test_properties()->transform_origin = | 2547 render_surface1->test_properties()->transform_origin = |
| 2548 gfx::Point3F(0.25f, 0.f, 0.f); | 2548 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2549 render_surface1->test_properties()->force_render_surface = true; | 2549 render_surface1->test_properties()->force_render_surface = true; |
| 2550 render_surface2->SetTransform(layer_transform); | 2550 render_surface2->test_properties()->transform = layer_transform; |
| 2551 render_surface2->SetPosition(gfx::PointF(2.5f, 0.f)); | 2551 render_surface2->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2552 render_surface2->SetBounds(gfx::Size(10, 10)); | 2552 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 2553 render_surface2->test_properties()->transform_origin = | 2553 render_surface2->test_properties()->transform_origin = |
| 2554 gfx::Point3F(0.25f, 0.f, 0.f); | 2554 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2555 render_surface2->test_properties()->force_render_surface = true; | 2555 render_surface2->test_properties()->force_render_surface = true; |
| 2556 child_of_root->SetTransform(layer_transform); | 2556 child_of_root->test_properties()->transform = layer_transform; |
| 2557 child_of_root->SetPosition(gfx::PointF(2.5f, 0.f)); | 2557 child_of_root->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2558 child_of_root->SetBounds(gfx::Size(10, 10)); | 2558 child_of_root->SetBounds(gfx::Size(10, 10)); |
| 2559 child_of_root->test_properties()->transform_origin = | 2559 child_of_root->test_properties()->transform_origin = |
| 2560 gfx::Point3F(0.25f, 0.f, 0.f); | 2560 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2561 child_of_rs1->SetTransform(layer_transform); | 2561 child_of_rs1->test_properties()->transform = layer_transform; |
| 2562 child_of_rs1->SetPosition(gfx::PointF(2.5f, 0.f)); | 2562 child_of_rs1->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2563 child_of_rs1->SetBounds(gfx::Size(10, 10)); | 2563 child_of_rs1->SetBounds(gfx::Size(10, 10)); |
| 2564 child_of_rs1->test_properties()->transform_origin = | 2564 child_of_rs1->test_properties()->transform_origin = |
| 2565 gfx::Point3F(0.25f, 0.f, 0.f); | 2565 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2566 child_of_rs2->SetTransform(layer_transform); | 2566 child_of_rs2->test_properties()->transform = layer_transform; |
| 2567 child_of_rs2->SetPosition(gfx::PointF(2.5f, 0.f)); | 2567 child_of_rs2->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2568 child_of_rs2->SetBounds(gfx::Size(10, 10)); | 2568 child_of_rs2->SetBounds(gfx::Size(10, 10)); |
| 2569 child_of_rs2->test_properties()->transform_origin = | 2569 child_of_rs2->test_properties()->transform_origin = |
| 2570 gfx::Point3F(0.25f, 0.f, 0.f); | 2570 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2571 grand_child_of_root->SetTransform(layer_transform); | 2571 grand_child_of_root->test_properties()->transform = layer_transform; |
| 2572 grand_child_of_root->SetPosition(gfx::PointF(2.5f, 0.f)); | 2572 grand_child_of_root->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2573 grand_child_of_root->SetBounds(gfx::Size(10, 10)); | 2573 grand_child_of_root->SetBounds(gfx::Size(10, 10)); |
| 2574 grand_child_of_root->test_properties()->transform_origin = | 2574 grand_child_of_root->test_properties()->transform_origin = |
| 2575 gfx::Point3F(0.25f, 0.f, 0.f); | 2575 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2576 grand_child_of_rs1->SetTransform(layer_transform); | 2576 grand_child_of_rs1->test_properties()->transform = layer_transform; |
| 2577 grand_child_of_rs1->SetPosition(gfx::PointF(2.5f, 0.f)); | 2577 grand_child_of_rs1->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2578 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); | 2578 grand_child_of_rs1->SetBounds(gfx::Size(10, 10)); |
| 2579 grand_child_of_rs1->test_properties()->transform_origin = | 2579 grand_child_of_rs1->test_properties()->transform_origin = |
| 2580 gfx::Point3F(0.25f, 0.f, 0.f); | 2580 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2581 grand_child_of_rs2->SetTransform(layer_transform); | 2581 grand_child_of_rs2->test_properties()->transform = layer_transform; |
| 2582 grand_child_of_rs2->SetPosition(gfx::PointF(2.5f, 0.f)); | 2582 grand_child_of_rs2->SetPosition(gfx::PointF(2.5f, 0.f)); |
| 2583 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); | 2583 grand_child_of_rs2->SetBounds(gfx::Size(10, 10)); |
| 2584 grand_child_of_rs2->test_properties()->transform_origin = | 2584 grand_child_of_rs2->test_properties()->transform_origin = |
| 2585 gfx::Point3F(0.25f, 0.f, 0.f); | 2585 gfx::Point3F(0.25f, 0.f, 0.f); |
| 2586 | 2586 |
| 2587 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); | 2587 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
| 2588 SetElementIdsForTesting(); | 2588 SetElementIdsForTesting(); |
| 2589 | 2589 |
| 2590 // Put an animated opacity on the render surface. | 2590 // Put an animated opacity on the render surface. |
| 2591 AddOpacityTransitionToElementWithPlayer( | 2591 AddOpacityTransitionToElementWithPlayer( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 | 2676 |
| 2677 TEST_F(LayerTreeHostCommonTest, LargeTransforms) { | 2677 TEST_F(LayerTreeHostCommonTest, LargeTransforms) { |
| 2678 LayerImpl* root = root_layer_for_testing(); | 2678 LayerImpl* root = root_layer_for_testing(); |
| 2679 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 2679 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 2680 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 2680 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 2681 | 2681 |
| 2682 gfx::Transform large_transform; | 2682 gfx::Transform large_transform; |
| 2683 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37)); | 2683 large_transform.Scale(SkDoubleToMScalar(1e37), SkDoubleToMScalar(1e37)); |
| 2684 | 2684 |
| 2685 root->SetBounds(gfx::Size(10, 10)); | 2685 root->SetBounds(gfx::Size(10, 10)); |
| 2686 child->SetTransform(large_transform); | 2686 child->test_properties()->transform = large_transform; |
| 2687 child->SetBounds(gfx::Size(10, 10)); | 2687 child->SetBounds(gfx::Size(10, 10)); |
| 2688 grand_child->SetTransform(large_transform); | 2688 grand_child->test_properties()->transform = large_transform; |
| 2689 grand_child->SetBounds(gfx::Size(10, 10)); | 2689 grand_child->SetBounds(gfx::Size(10, 10)); |
| 2690 grand_child->SetDrawsContent(true); | 2690 grand_child->SetDrawsContent(true); |
| 2691 ExecuteCalculateDrawProperties(root); | 2691 ExecuteCalculateDrawProperties(root); |
| 2692 | 2692 |
| 2693 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); | 2693 EXPECT_EQ(gfx::Rect(), grand_child->visible_layer_rect()); |
| 2694 } | 2694 } |
| 2695 | 2695 |
| 2696 TEST_F(LayerTreeHostCommonTest, | 2696 TEST_F(LayerTreeHostCommonTest, |
| 2697 ScreenSpaceTransformIsAnimatingWithDelayedAnimation) { | 2697 ScreenSpaceTransformIsAnimatingWithDelayedAnimation) { |
| 2698 LayerImpl* root = root_layer_for_testing(); | 2698 LayerImpl* root = root_layer_for_testing(); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3135 LayerImpl* root = root_layer_for_testing(); | 3135 LayerImpl* root = root_layer_for_testing(); |
| 3136 LayerImpl* child = AddChild<LayerImpl>(root); | 3136 LayerImpl* child = AddChild<LayerImpl>(root); |
| 3137 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 3137 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 3138 | 3138 |
| 3139 gfx::Transform child_scale_matrix; | 3139 gfx::Transform child_scale_matrix; |
| 3140 child_scale_matrix.Scale(0.25f, 0.25f); | 3140 child_scale_matrix.Scale(0.25f, 0.25f); |
| 3141 gfx::Transform grand_child_scale_matrix; | 3141 gfx::Transform grand_child_scale_matrix; |
| 3142 grand_child_scale_matrix.Scale(0.246f, 0.246f); | 3142 grand_child_scale_matrix.Scale(0.246f, 0.246f); |
| 3143 | 3143 |
| 3144 root->SetBounds(gfx::Size(100, 100)); | 3144 root->SetBounds(gfx::Size(100, 100)); |
| 3145 child->SetTransform(child_scale_matrix); | 3145 child->test_properties()->transform = child_scale_matrix; |
| 3146 child->SetBounds(gfx::Size(10, 10)); | 3146 child->SetBounds(gfx::Size(10, 10)); |
| 3147 child->SetMasksToBounds(true); | 3147 child->SetMasksToBounds(true); |
| 3148 grand_child->SetTransform(grand_child_scale_matrix); | 3148 grand_child->test_properties()->transform = grand_child_scale_matrix; |
| 3149 grand_child->SetBounds(gfx::Size(100, 100)); | 3149 grand_child->SetBounds(gfx::Size(100, 100)); |
| 3150 grand_child->SetDrawsContent(true); | 3150 grand_child->SetDrawsContent(true); |
| 3151 ExecuteCalculateDrawProperties(root); | 3151 ExecuteCalculateDrawProperties(root); |
| 3152 | 3152 |
| 3153 // The visible rect is expanded to integer coordinates. | 3153 // The visible rect is expanded to integer coordinates. |
| 3154 EXPECT_EQ(gfx::Rect(41, 41), grand_child->visible_layer_rect()); | 3154 EXPECT_EQ(gfx::Rect(41, 41), grand_child->visible_layer_rect()); |
| 3155 } | 3155 } |
| 3156 | 3156 |
| 3157 TEST_F(LayerTreeHostCommonTest, | 3157 TEST_F(LayerTreeHostCommonTest, |
| 3158 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { | 3158 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3427 | 3427 |
| 3428 root->SetBounds(gfx::Size(100, 100)); | 3428 root->SetBounds(gfx::Size(100, 100)); |
| 3429 child->SetPosition(gfx::PointF(5.f, 5.f)); | 3429 child->SetPosition(gfx::PointF(5.f, 5.f)); |
| 3430 child->SetBounds(gfx::Size(50, 50)); | 3430 child->SetBounds(gfx::Size(50, 50)); |
| 3431 child->SetDrawsContent(true); | 3431 child->SetDrawsContent(true); |
| 3432 | 3432 |
| 3433 // Case 1: a truly degenerate matrix | 3433 // Case 1: a truly degenerate matrix |
| 3434 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | 3434 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
| 3435 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3435 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
| 3436 | 3436 |
| 3437 child->SetTransform(uninvertible_matrix); | 3437 child->test_properties()->transform = uninvertible_matrix; |
| 3438 ExecuteCalculateDrawProperties(root); | 3438 ExecuteCalculateDrawProperties(root); |
| 3439 | 3439 |
| 3440 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); | 3440 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); |
| 3441 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 3441 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
| 3442 | 3442 |
| 3443 // Case 2: a matrix with flattened z, uninvertible and not visible according | 3443 // Case 2: a matrix with flattened z, uninvertible and not visible according |
| 3444 // to the CSS spec. | 3444 // to the CSS spec. |
| 3445 uninvertible_matrix.MakeIdentity(); | 3445 uninvertible_matrix.MakeIdentity(); |
| 3446 uninvertible_matrix.matrix().set(2, 2, 0.0); | 3446 uninvertible_matrix.matrix().set(2, 2, 0.0); |
| 3447 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3447 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
| 3448 | 3448 |
| 3449 child->SetTransform(uninvertible_matrix); | 3449 child->test_properties()->transform = uninvertible_matrix; |
| 3450 ExecuteCalculateDrawProperties(root); | 3450 ExecuteCalculateDrawProperties(root); |
| 3451 | 3451 |
| 3452 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); | 3452 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); |
| 3453 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 3453 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
| 3454 | 3454 |
| 3455 // Case 3: a matrix with flattened z, also uninvertible and not visible. | 3455 // Case 3: a matrix with flattened z, also uninvertible and not visible. |
| 3456 uninvertible_matrix.MakeIdentity(); | 3456 uninvertible_matrix.MakeIdentity(); |
| 3457 uninvertible_matrix.Translate(500.0, 0.0); | 3457 uninvertible_matrix.Translate(500.0, 0.0); |
| 3458 uninvertible_matrix.matrix().set(2, 2, 0.0); | 3458 uninvertible_matrix.matrix().set(2, 2, 0.0); |
| 3459 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3459 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
| 3460 | 3460 |
| 3461 child->SetTransform(uninvertible_matrix); | 3461 child->test_properties()->transform = uninvertible_matrix; |
| 3462 ExecuteCalculateDrawProperties(root); | 3462 ExecuteCalculateDrawProperties(root); |
| 3463 | 3463 |
| 3464 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); | 3464 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); |
| 3465 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 3465 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
| 3466 } | 3466 } |
| 3467 | 3467 |
| 3468 TEST_F(LayerTreeHostCommonTest, | 3468 TEST_F(LayerTreeHostCommonTest, |
| 3469 VisibleContentRectForLayerWithUninvertibleDrawTransform) { | 3469 VisibleContentRectForLayerWithUninvertibleDrawTransform) { |
| 3470 LayerImpl* root = root_layer_for_testing(); | 3470 LayerImpl* root = root_layer_for_testing(); |
| 3471 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 3471 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 3472 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 3472 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 3473 | 3473 |
| 3474 gfx::Transform perspective; | 3474 gfx::Transform perspective; |
| 3475 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); | 3475 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); |
| 3476 | 3476 |
| 3477 gfx::Transform rotation; | 3477 gfx::Transform rotation; |
| 3478 rotation.RotateAboutYAxis(45.0); | 3478 rotation.RotateAboutYAxis(45.0); |
| 3479 | 3479 |
| 3480 root->SetBounds(gfx::Size(100, 100)); | 3480 root->SetBounds(gfx::Size(100, 100)); |
| 3481 child->SetTransform(perspective); | 3481 child->test_properties()->transform = perspective; |
| 3482 child->SetPosition(gfx::PointF(10.f, 10.f)); | 3482 child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 3483 child->SetBounds(gfx::Size(100, 100)); | 3483 child->SetBounds(gfx::Size(100, 100)); |
| 3484 child->SetDrawsContent(true); | 3484 child->SetDrawsContent(true); |
| 3485 child->Set3dSortingContextId(1); | 3485 child->Set3dSortingContextId(1); |
| 3486 child->test_properties()->should_flatten_transform = false; | 3486 child->test_properties()->should_flatten_transform = false; |
| 3487 grand_child->SetTransform(rotation); | 3487 grand_child->test_properties()->transform = rotation; |
| 3488 grand_child->SetBounds(gfx::Size(100, 100)); | 3488 grand_child->SetBounds(gfx::Size(100, 100)); |
| 3489 grand_child->SetDrawsContent(true); | 3489 grand_child->SetDrawsContent(true); |
| 3490 grand_child->Set3dSortingContextId(1); | 3490 grand_child->Set3dSortingContextId(1); |
| 3491 grand_child->test_properties()->should_flatten_transform = false; | 3491 grand_child->test_properties()->should_flatten_transform = false; |
| 3492 ExecuteCalculateDrawProperties(root); | 3492 ExecuteCalculateDrawProperties(root); |
| 3493 | 3493 |
| 3494 // Though all layers have invertible transforms, matrix multiplication using | 3494 // Though all layers have invertible transforms, matrix multiplication using |
| 3495 // floating-point math makes the draw transform uninvertible. | 3495 // floating-point math makes the draw transform uninvertible. |
| 3496 EXPECT_FALSE(root->layer_tree_impl() | 3496 EXPECT_FALSE(root->layer_tree_impl() |
| 3497 ->property_trees() | 3497 ->property_trees() |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 surface->SetContentsOpaque(true); | 3532 surface->SetContentsOpaque(true); |
| 3533 surface_child->SetContentsOpaque(true); | 3533 surface_child->SetContentsOpaque(true); |
| 3534 surface_sibling->SetContentsOpaque(true); | 3534 surface_sibling->SetContentsOpaque(true); |
| 3535 surface_child_mask->SetContentsOpaque(true); | 3535 surface_child_mask->SetContentsOpaque(true); |
| 3536 | 3536 |
| 3537 gfx::Transform translate; | 3537 gfx::Transform translate; |
| 3538 translate.Translate(20.f, 20.f); | 3538 translate.Translate(20.f, 20.f); |
| 3539 | 3539 |
| 3540 root->SetBounds(gfx::Size(1000, 1000)); | 3540 root->SetBounds(gfx::Size(1000, 1000)); |
| 3541 child->SetBounds(gfx::Size(300, 300)); | 3541 child->SetBounds(gfx::Size(300, 300)); |
| 3542 surface->SetTransform(translate); | 3542 surface->test_properties()->transform = translate; |
| 3543 surface->SetBounds(gfx::Size(300, 300)); | 3543 surface->SetBounds(gfx::Size(300, 300)); |
| 3544 surface->test_properties()->force_render_surface = true; | 3544 surface->test_properties()->force_render_surface = true; |
| 3545 surface_child->SetBounds(gfx::Size(300, 300)); | 3545 surface_child->SetBounds(gfx::Size(300, 300)); |
| 3546 surface_child->test_properties()->force_render_surface = true; | 3546 surface_child->test_properties()->force_render_surface = true; |
| 3547 surface_sibling->SetBounds(gfx::Size(200, 200)); | 3547 surface_sibling->SetBounds(gfx::Size(200, 200)); |
| 3548 | 3548 |
| 3549 LayerImpl* surface_ptr = surface.get(); | 3549 LayerImpl* surface_ptr = surface.get(); |
| 3550 LayerImpl* surface_child_ptr = surface_child.get(); | 3550 LayerImpl* surface_child_ptr = surface_child.get(); |
| 3551 LayerImpl* surface_child_mask_ptr = surface_child_mask.get(); | 3551 LayerImpl* surface_child_mask_ptr = surface_child_mask.get(); |
| 3552 | 3552 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 std::unique_ptr<LayerImpl> occluding_child = | 3599 std::unique_ptr<LayerImpl> occluding_child = |
| 3600 LayerImpl::Create(host_impl.active_tree(), 4); | 3600 LayerImpl::Create(host_impl.active_tree(), 4); |
| 3601 | 3601 |
| 3602 gfx::Transform perspective; | 3602 gfx::Transform perspective; |
| 3603 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); | 3603 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); |
| 3604 | 3604 |
| 3605 gfx::Transform rotation; | 3605 gfx::Transform rotation; |
| 3606 rotation.RotateAboutYAxis(45.0); | 3606 rotation.RotateAboutYAxis(45.0); |
| 3607 | 3607 |
| 3608 root->SetBounds(gfx::Size(1000, 1000)); | 3608 root->SetBounds(gfx::Size(1000, 1000)); |
| 3609 child->SetTransform(perspective); | 3609 child->test_properties()->transform = perspective; |
| 3610 child->SetPosition(gfx::PointF(10.f, 10.f)); | 3610 child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 3611 child->SetBounds(gfx::Size(300, 300)); | 3611 child->SetBounds(gfx::Size(300, 300)); |
| 3612 child->test_properties()->should_flatten_transform = false; | 3612 child->test_properties()->should_flatten_transform = false; |
| 3613 child->Set3dSortingContextId(1); | 3613 child->Set3dSortingContextId(1); |
| 3614 grand_child->SetTransform(rotation); | 3614 grand_child->test_properties()->transform = rotation; |
| 3615 grand_child->SetBounds(gfx::Size(200, 200)); | 3615 grand_child->SetBounds(gfx::Size(200, 200)); |
| 3616 grand_child->test_properties()->should_flatten_transform = false; | 3616 grand_child->test_properties()->should_flatten_transform = false; |
| 3617 grand_child->Set3dSortingContextId(1); | 3617 grand_child->Set3dSortingContextId(1); |
| 3618 occluding_child->SetBounds(gfx::Size(200, 200)); | 3618 occluding_child->SetBounds(gfx::Size(200, 200)); |
| 3619 occluding_child->test_properties()->should_flatten_transform = false; | 3619 occluding_child->test_properties()->should_flatten_transform = false; |
| 3620 | 3620 |
| 3621 child->SetDrawsContent(true); | 3621 child->SetDrawsContent(true); |
| 3622 grand_child->SetDrawsContent(true); | 3622 grand_child->SetDrawsContent(true); |
| 3623 occluding_child->SetDrawsContent(true); | 3623 occluding_child->SetDrawsContent(true); |
| 3624 occluding_child->SetContentsOpaque(true); | 3624 occluding_child->SetContentsOpaque(true); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3975 LayerImpl* root = root_layer_for_testing(); | 3975 LayerImpl* root = root_layer_for_testing(); |
| 3976 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); | 3976 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); |
| 3977 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); | 3977 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); |
| 3978 | 3978 |
| 3979 gfx::Transform child_rotation; | 3979 gfx::Transform child_rotation; |
| 3980 child_rotation.Rotate(45.0); | 3980 child_rotation.Rotate(45.0); |
| 3981 | 3981 |
| 3982 root->SetBounds(gfx::Size(100, 100)); | 3982 root->SetBounds(gfx::Size(100, 100)); |
| 3983 render_surface->SetBounds(gfx::Size(3, 4)); | 3983 render_surface->SetBounds(gfx::Size(3, 4)); |
| 3984 render_surface->test_properties()->force_render_surface = true; | 3984 render_surface->test_properties()->force_render_surface = true; |
| 3985 child1->SetTransform(child_rotation); | 3985 child1->test_properties()->transform = child_rotation; |
| 3986 child1->SetPosition(gfx::PointF(25.f, 25.f)); | 3986 child1->SetPosition(gfx::PointF(25.f, 25.f)); |
| 3987 child1->SetBounds(gfx::Size(50, 50)); | 3987 child1->SetBounds(gfx::Size(50, 50)); |
| 3988 child1->SetDrawsContent(true); | 3988 child1->SetDrawsContent(true); |
| 3989 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); | 3989 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); |
| 3990 ExecuteCalculateDrawProperties(root); | 3990 ExecuteCalculateDrawProperties(root); |
| 3991 | 3991 |
| 3992 ASSERT_TRUE(render_surface->render_surface()); | 3992 ASSERT_TRUE(render_surface->render_surface()); |
| 3993 | 3993 |
| 3994 EXPECT_EQ(gfx::RectF(100.f, 100.f), | 3994 EXPECT_EQ(gfx::RectF(100.f, 100.f), |
| 3995 root->render_surface()->DrawableContentRect()); | 3995 root->render_surface()->DrawableContentRect()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4025 gfx::Transform child_rotation; | 4025 gfx::Transform child_rotation; |
| 4026 child_rotation.Rotate(45.0); | 4026 child_rotation.Rotate(45.0); |
| 4027 | 4027 |
| 4028 root->SetBounds(gfx::Size(50, 50)); | 4028 root->SetBounds(gfx::Size(50, 50)); |
| 4029 root->SetMasksToBounds(true); | 4029 root->SetMasksToBounds(true); |
| 4030 render_surface->SetBounds(gfx::Size(3, 4)); | 4030 render_surface->SetBounds(gfx::Size(3, 4)); |
| 4031 render_surface->test_properties()->force_render_surface = true; | 4031 render_surface->test_properties()->force_render_surface = true; |
| 4032 child1->SetPosition(gfx::PointF(25.f, 25.f)); | 4032 child1->SetPosition(gfx::PointF(25.f, 25.f)); |
| 4033 child1->SetBounds(gfx::Size(50, 50)); | 4033 child1->SetBounds(gfx::Size(50, 50)); |
| 4034 child1->SetDrawsContent(true); | 4034 child1->SetDrawsContent(true); |
| 4035 child1->SetTransform(child_rotation); | 4035 child1->test_properties()->transform = child_rotation; |
| 4036 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); | 4036 child1->test_properties()->transform_origin = gfx::Point3F(25.f, 25.f, 0.f); |
| 4037 ExecuteCalculateDrawProperties(root); | 4037 ExecuteCalculateDrawProperties(root); |
| 4038 | 4038 |
| 4039 ASSERT_TRUE(render_surface->render_surface()); | 4039 ASSERT_TRUE(render_surface->render_surface()); |
| 4040 | 4040 |
| 4041 // The clipped surface clamps the DrawableContentRect that encloses the | 4041 // The clipped surface clamps the DrawableContentRect that encloses the |
| 4042 // rotated layer. | 4042 // rotated layer. |
| 4043 int diagonal_radius = ceil(sqrt(2.0) * 25.0); | 4043 int diagonal_radius = ceil(sqrt(2.0) * 25.0); |
| 4044 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius, | 4044 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius, |
| 4045 50 - diagonal_radius, | 4045 50 - diagonal_radius, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4179 front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4179 front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4180 back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4180 back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4181 front_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4181 front_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4182 back_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4182 back_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4183 front_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4183 front_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4184 back_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4184 back_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4185 | 4185 |
| 4186 front_facing_surface->test_properties()->force_render_surface = true; | 4186 front_facing_surface->test_properties()->force_render_surface = true; |
| 4187 back_facing_surface->test_properties()->force_render_surface = true; | 4187 back_facing_surface->test_properties()->force_render_surface = true; |
| 4188 | 4188 |
| 4189 back_facing_child->SetTransform(backface_matrix); | 4189 back_facing_child->test_properties()->transform = backface_matrix; |
| 4190 back_facing_surface->SetTransform(backface_matrix); | 4190 back_facing_surface->test_properties()->transform = backface_matrix; |
| 4191 back_facing_child_of_front_facing_surface->SetTransform(backface_matrix); | 4191 back_facing_child_of_front_facing_surface->test_properties()->transform = |
| 4192 back_facing_child_of_back_facing_surface->SetTransform(backface_matrix); | 4192 backface_matrix; |
| 4193 back_facing_child_of_back_facing_surface->test_properties()->transform = |
| 4194 backface_matrix; |
| 4193 | 4195 |
| 4194 // Note: No layers preserve 3d. According to current W3C CSS gfx::Transforms | 4196 // Note: No layers preserve 3d. According to current W3C CSS gfx::Transforms |
| 4195 // spec, these layers should blindly use their own local transforms to | 4197 // spec, these layers should blindly use their own local transforms to |
| 4196 // determine back-face culling. | 4198 // determine back-face culling. |
| 4197 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); | 4199 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); |
| 4198 | 4200 |
| 4199 // Verify which render surfaces were created. | 4201 // Verify which render surfaces were created. |
| 4200 EXPECT_FALSE(front_facing_child->has_render_surface()); | 4202 EXPECT_FALSE(front_facing_child->has_render_surface()); |
| 4201 EXPECT_FALSE(back_facing_child->has_render_surface()); | 4203 EXPECT_FALSE(back_facing_child->has_render_surface()); |
| 4202 EXPECT_TRUE(front_facing_surface->has_render_surface()); | 4204 EXPECT_TRUE(front_facing_surface->has_render_surface()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4275 root->SetBounds(gfx::Size(100, 100)); | 4277 root->SetBounds(gfx::Size(100, 100)); |
| 4276 front_facing_child->SetBounds(gfx::Size(100, 100)); | 4278 front_facing_child->SetBounds(gfx::Size(100, 100)); |
| 4277 back_facing_child->SetBounds(gfx::Size(100, 100)); | 4279 back_facing_child->SetBounds(gfx::Size(100, 100)); |
| 4278 front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4280 front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4279 back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4281 back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4280 front_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4282 front_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4281 back_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4283 back_facing_child_of_front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4282 front_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4284 front_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4283 back_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4285 back_facing_child_of_back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4284 | 4286 |
| 4285 back_facing_child->SetTransform(backface_matrix); | 4287 back_facing_child->test_properties()->transform = backface_matrix; |
| 4286 back_facing_surface->SetTransform(backface_matrix); | 4288 back_facing_surface->test_properties()->transform = backface_matrix; |
| 4287 back_facing_child_of_front_facing_surface->SetTransform(backface_matrix); | 4289 back_facing_child_of_front_facing_surface->test_properties()->transform = |
| 4288 back_facing_child_of_back_facing_surface->SetTransform(backface_matrix); | 4290 backface_matrix; |
| 4291 back_facing_child_of_back_facing_surface->test_properties()->transform = |
| 4292 backface_matrix; |
| 4289 | 4293 |
| 4290 // Each surface creates its own new 3d rendering context (as defined by W3C | 4294 // Each surface creates its own new 3d rendering context (as defined by W3C |
| 4291 // spec). According to current W3C CSS gfx::Transforms spec, layers in a 3d | 4295 // spec). According to current W3C CSS gfx::Transforms spec, layers in a 3d |
| 4292 // rendering context should use the transform with respect to that context. | 4296 // rendering context should use the transform with respect to that context. |
| 4293 // This 3d rendering context occurs when (a) parent's transform style is flat | 4297 // This 3d rendering context occurs when (a) parent's transform style is flat |
| 4294 // and (b) the layer's transform style is preserve-3d. | 4298 // and (b) the layer's transform style is preserve-3d. |
| 4295 front_facing_surface->test_properties()->should_flatten_transform = false; | 4299 front_facing_surface->test_properties()->should_flatten_transform = false; |
| 4296 front_facing_surface->Set3dSortingContextId(1); | 4300 front_facing_surface->Set3dSortingContextId(1); |
| 4297 back_facing_surface->test_properties()->should_flatten_transform = false; | 4301 back_facing_surface->test_properties()->should_flatten_transform = false; |
| 4298 back_facing_surface->Set3dSortingContextId(1); | 4302 back_facing_surface->Set3dSortingContextId(1); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4360 | 4364 |
| 4361 // Animate the transform on the render surface. | 4365 // Animate the transform on the render surface. |
| 4362 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(), | 4366 AddAnimatedTransformToElementWithPlayer(animating_surface->element_id(), |
| 4363 timeline_impl(), 10.0, 30, 0); | 4367 timeline_impl(), 10.0, 30, 0); |
| 4364 // This is just an animating layer, not a surface. | 4368 // This is just an animating layer, not a surface. |
| 4365 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(), | 4369 AddAnimatedTransformToElementWithPlayer(animating_child->element_id(), |
| 4366 timeline_impl(), 10.0, 30, 0); | 4370 timeline_impl(), 10.0, 30, 0); |
| 4367 | 4371 |
| 4368 root->SetBounds(gfx::Size(100, 100)); | 4372 root->SetBounds(gfx::Size(100, 100)); |
| 4369 child->SetBounds(gfx::Size(100, 100)); | 4373 child->SetBounds(gfx::Size(100, 100)); |
| 4370 child->SetTransform(backface_matrix); | 4374 child->test_properties()->transform = backface_matrix; |
| 4371 animating_surface->SetBounds(gfx::Size(100, 100)); | 4375 animating_surface->SetBounds(gfx::Size(100, 100)); |
| 4372 animating_surface->SetTransform(backface_matrix); | 4376 animating_surface->test_properties()->transform = backface_matrix; |
| 4373 animating_surface->test_properties()->force_render_surface = true; | 4377 animating_surface->test_properties()->force_render_surface = true; |
| 4374 child_of_animating_surface->SetBounds(gfx::Size(100, 100)); | 4378 child_of_animating_surface->SetBounds(gfx::Size(100, 100)); |
| 4375 child_of_animating_surface->SetTransform(backface_matrix); | 4379 child_of_animating_surface->test_properties()->transform = backface_matrix; |
| 4376 animating_child->SetBounds(gfx::Size(100, 100)); | 4380 animating_child->SetBounds(gfx::Size(100, 100)); |
| 4377 animating_child->SetTransform(backface_matrix); | 4381 animating_child->test_properties()->transform = backface_matrix; |
| 4378 child2->SetBounds(gfx::Size(100, 100)); | 4382 child2->SetBounds(gfx::Size(100, 100)); |
| 4379 | 4383 |
| 4380 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); | 4384 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); |
| 4381 | 4385 |
| 4382 EXPECT_FALSE(child->has_render_surface()); | 4386 EXPECT_FALSE(child->has_render_surface()); |
| 4383 EXPECT_TRUE(animating_surface->has_render_surface()); | 4387 EXPECT_TRUE(animating_surface->has_render_surface()); |
| 4384 EXPECT_FALSE(child_of_animating_surface->has_render_surface()); | 4388 EXPECT_FALSE(child_of_animating_surface->has_render_surface()); |
| 4385 EXPECT_FALSE(animating_child->has_render_surface()); | 4389 EXPECT_FALSE(animating_child->has_render_surface()); |
| 4386 EXPECT_FALSE(child2->has_render_surface()); | 4390 EXPECT_FALSE(child2->has_render_surface()); |
| 4387 | 4391 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4421 | 4425 |
| 4422 gfx::Transform backface_matrix; | 4426 gfx::Transform backface_matrix; |
| 4423 backface_matrix.Translate(50.0, 50.0); | 4427 backface_matrix.Translate(50.0, 50.0); |
| 4424 backface_matrix.RotateAboutYAxis(180.0); | 4428 backface_matrix.RotateAboutYAxis(180.0); |
| 4425 backface_matrix.Translate(-50.0, -50.0); | 4429 backface_matrix.Translate(-50.0, -50.0); |
| 4426 | 4430 |
| 4427 root->SetBounds(gfx::Size(100, 100)); | 4431 root->SetBounds(gfx::Size(100, 100)); |
| 4428 front_facing_surface->SetBounds(gfx::Size(100, 100)); | 4432 front_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4429 front_facing_surface->test_properties()->force_render_surface = true; | 4433 front_facing_surface->test_properties()->force_render_surface = true; |
| 4430 back_facing_surface->SetBounds(gfx::Size(100, 100)); | 4434 back_facing_surface->SetBounds(gfx::Size(100, 100)); |
| 4431 back_facing_surface->SetTransform(backface_matrix); | 4435 back_facing_surface->test_properties()->transform = backface_matrix; |
| 4432 back_facing_surface->test_properties()->force_render_surface = true; | 4436 back_facing_surface->test_properties()->force_render_surface = true; |
| 4433 child1->SetBounds(gfx::Size(100, 100)); | 4437 child1->SetBounds(gfx::Size(100, 100)); |
| 4434 child2->SetBounds(gfx::Size(100, 100)); | 4438 child2->SetBounds(gfx::Size(100, 100)); |
| 4435 | 4439 |
| 4436 front_facing_surface->Set3dSortingContextId(1); | 4440 front_facing_surface->Set3dSortingContextId(1); |
| 4437 back_facing_surface->Set3dSortingContextId(1); | 4441 back_facing_surface->Set3dSortingContextId(1); |
| 4438 | 4442 |
| 4439 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); | 4443 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); |
| 4440 | 4444 |
| 4441 // Verify which render surfaces were created and used. | 4445 // Verify which render surfaces were created and used. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4549 LayerImpl* page_scale = AddChildToRoot<LayerImpl>(); | 4553 LayerImpl* page_scale = AddChildToRoot<LayerImpl>(); |
| 4550 page_scale->SetBounds(gfx::Size(100, 100)); | 4554 page_scale->SetBounds(gfx::Size(100, 100)); |
| 4551 | 4555 |
| 4552 LayerImpl* parent = AddChild<LayerImpl>(page_scale); | 4556 LayerImpl* parent = AddChild<LayerImpl>(page_scale); |
| 4553 parent->SetBounds(gfx::Size(100, 100)); | 4557 parent->SetBounds(gfx::Size(100, 100)); |
| 4554 parent->SetDrawsContent(true); | 4558 parent->SetDrawsContent(true); |
| 4555 | 4559 |
| 4556 LayerImpl* perspective_surface = AddChild<LayerImpl>(parent); | 4560 LayerImpl* perspective_surface = AddChild<LayerImpl>(parent); |
| 4557 perspective_surface->SetPosition(gfx::PointF(2.f, 2.f)); | 4561 perspective_surface->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4558 perspective_surface->SetBounds(gfx::Size(10, 10)); | 4562 perspective_surface->SetBounds(gfx::Size(10, 10)); |
| 4559 perspective_surface->SetTransform(perspective_matrix * scale_small_matrix); | 4563 perspective_surface->test_properties()->transform = |
| 4564 perspective_matrix * scale_small_matrix; |
| 4560 perspective_surface->SetDrawsContent(true); | 4565 perspective_surface->SetDrawsContent(true); |
| 4561 perspective_surface->test_properties()->force_render_surface = true; | 4566 perspective_surface->test_properties()->force_render_surface = true; |
| 4562 | 4567 |
| 4563 LayerImpl* scale_surface = AddChild<LayerImpl>(parent); | 4568 LayerImpl* scale_surface = AddChild<LayerImpl>(parent); |
| 4564 scale_surface->SetPosition(gfx::PointF(2.f, 2.f)); | 4569 scale_surface->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4565 scale_surface->SetBounds(gfx::Size(10, 10)); | 4570 scale_surface->SetBounds(gfx::Size(10, 10)); |
| 4566 scale_surface->SetTransform(scale_small_matrix); | 4571 scale_surface->test_properties()->transform = scale_small_matrix; |
| 4567 scale_surface->SetDrawsContent(true); | 4572 scale_surface->SetDrawsContent(true); |
| 4568 scale_surface->test_properties()->force_render_surface = true; | 4573 scale_surface->test_properties()->force_render_surface = true; |
| 4569 | 4574 |
| 4570 float device_scale_factor = 2.5f; | 4575 float device_scale_factor = 2.5f; |
| 4571 float page_scale_factor = 3.f; | 4576 float page_scale_factor = 3.f; |
| 4572 root->layer_tree_impl()->SetViewportLayersFromIds( | 4577 root->layer_tree_impl()->SetViewportLayersFromIds( |
| 4573 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, | 4578 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, |
| 4574 Layer::INVALID_ID); | 4579 Layer::INVALID_ID); |
| 4575 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); | 4580 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
| 4576 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); | 4581 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4640 | 4645 |
| 4641 gfx::Transform child_scale_matrix; | 4646 gfx::Transform child_scale_matrix; |
| 4642 SkMScalar initial_child_scale = 0.25; | 4647 SkMScalar initial_child_scale = 0.25; |
| 4643 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 4648 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
| 4644 | 4649 |
| 4645 LayerImpl* root = root_layer_for_testing(); | 4650 LayerImpl* root = root_layer_for_testing(); |
| 4646 root->SetBounds(gfx::Size(100, 100)); | 4651 root->SetBounds(gfx::Size(100, 100)); |
| 4647 | 4652 |
| 4648 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | 4653 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 4649 parent->SetBounds(gfx::Size(100, 100)); | 4654 parent->SetBounds(gfx::Size(100, 100)); |
| 4650 parent->SetTransform(parent_scale_matrix); | 4655 parent->test_properties()->transform = parent_scale_matrix; |
| 4651 parent->SetDrawsContent(true); | 4656 parent->SetDrawsContent(true); |
| 4652 | 4657 |
| 4653 LayerImpl* child_scale = AddChild<LayerImpl>(parent); | 4658 LayerImpl* child_scale = AddChild<LayerImpl>(parent); |
| 4654 child_scale->SetPosition(gfx::PointF(2.f, 2.f)); | 4659 child_scale->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4655 child_scale->SetBounds(gfx::Size(10, 10)); | 4660 child_scale->SetBounds(gfx::Size(10, 10)); |
| 4656 child_scale->SetTransform(child_scale_matrix); | 4661 child_scale->test_properties()->transform = child_scale_matrix; |
| 4657 child_scale->SetDrawsContent(true); | 4662 child_scale->SetDrawsContent(true); |
| 4658 | 4663 |
| 4659 float device_scale_factor = 2.5f; | 4664 float device_scale_factor = 2.5f; |
| 4660 float page_scale_factor = 0.01f; | 4665 float page_scale_factor = 0.01f; |
| 4661 | 4666 |
| 4662 { | 4667 { |
| 4663 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, | 4668 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, |
| 4664 root); | 4669 root); |
| 4665 | 4670 |
| 4666 // The ideal scale is able to go below 1. | 4671 // The ideal scale is able to go below 1. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4683 | 4688 |
| 4684 gfx::Transform child_scale_matrix; | 4689 gfx::Transform child_scale_matrix; |
| 4685 SkMScalar initial_child_scale = 1.25; | 4690 SkMScalar initial_child_scale = 1.25; |
| 4686 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); | 4691 child_scale_matrix.Scale(initial_child_scale, initial_child_scale); |
| 4687 | 4692 |
| 4688 LayerImpl* root = root_layer_for_testing(); | 4693 LayerImpl* root = root_layer_for_testing(); |
| 4689 root->SetBounds(gfx::Size(100, 100)); | 4694 root->SetBounds(gfx::Size(100, 100)); |
| 4690 | 4695 |
| 4691 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | 4696 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 4692 parent->SetBounds(gfx::Size(100, 100)); | 4697 parent->SetBounds(gfx::Size(100, 100)); |
| 4693 parent->SetTransform(parent_scale_matrix); | 4698 parent->test_properties()->transform = parent_scale_matrix; |
| 4694 parent->SetDrawsContent(true); | 4699 parent->SetDrawsContent(true); |
| 4695 | 4700 |
| 4696 LayerImpl* child_scale = AddChild<LayerImpl>(parent); | 4701 LayerImpl* child_scale = AddChild<LayerImpl>(parent); |
| 4697 child_scale->SetBounds(gfx::Size(10, 10)); | 4702 child_scale->SetBounds(gfx::Size(10, 10)); |
| 4698 child_scale->SetPosition(gfx::PointF(2.f, 2.f)); | 4703 child_scale->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4699 child_scale->SetTransform(child_scale_matrix); | 4704 child_scale->test_properties()->transform = child_scale_matrix; |
| 4700 child_scale->SetDrawsContent(true); | 4705 child_scale->SetDrawsContent(true); |
| 4701 | 4706 |
| 4702 ExecuteCalculateDrawProperties(root); | 4707 ExecuteCalculateDrawProperties(root); |
| 4703 | 4708 |
| 4704 EXPECT_FLOAT_EQ(initial_parent_scale, parent->GetIdealContentsScale()); | 4709 EXPECT_FLOAT_EQ(initial_parent_scale, parent->GetIdealContentsScale()); |
| 4705 // Animating layers compute ideal scale in the same way as when | 4710 // Animating layers compute ideal scale in the same way as when |
| 4706 // they are static. | 4711 // they are static. |
| 4707 EXPECT_FLOAT_EQ(initial_child_scale * initial_parent_scale, | 4712 EXPECT_FLOAT_EQ(initial_child_scale * initial_parent_scale, |
| 4708 child_scale->GetIdealContentsScale()); | 4713 child_scale->GetIdealContentsScale()); |
| 4709 } | 4714 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4720 child->SetPosition(gfx::PointF(2.f, 2.f)); | 4725 child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4721 child->SetDrawsContent(true); | 4726 child->SetDrawsContent(true); |
| 4722 child->test_properties()->force_render_surface = true; | 4727 child->test_properties()->force_render_surface = true; |
| 4723 | 4728 |
| 4724 gfx::Transform replica_transform; | 4729 gfx::Transform replica_transform; |
| 4725 replica_transform.Scale(1.0, -1.0); | 4730 replica_transform.Scale(1.0, -1.0); |
| 4726 | 4731 |
| 4727 std::unique_ptr<LayerImpl> replica = | 4732 std::unique_ptr<LayerImpl> replica = |
| 4728 LayerImpl::Create(host_impl()->active_tree(), 7); | 4733 LayerImpl::Create(host_impl()->active_tree(), 7); |
| 4729 replica->SetPosition(gfx::PointF(2.f, 2.f)); | 4734 replica->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4730 replica->SetTransform(replica_transform); | 4735 replica->test_properties()->transform = replica_transform; |
| 4731 | 4736 |
| 4732 // We need to set parent on replica layer for property tree building. | 4737 // We need to set parent on replica layer for property tree building. |
| 4733 replica->test_properties()->parent = child; | 4738 replica->test_properties()->parent = child; |
| 4734 child->test_properties()->SetReplicaLayer(std::move(replica)); | 4739 child->test_properties()->SetReplicaLayer(std::move(replica)); |
| 4735 | 4740 |
| 4736 // This layer should end up in the same surface as child, with the same draw | 4741 // This layer should end up in the same surface as child, with the same draw |
| 4737 // and screen space transforms. | 4742 // and screen space transforms. |
| 4738 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child); | 4743 LayerImpl* duplicate_child_non_owner = AddChild<LayerImpl>(child); |
| 4739 duplicate_child_non_owner->SetBounds(gfx::Size(10, 10)); | 4744 duplicate_child_non_owner->SetBounds(gfx::Size(10, 10)); |
| 4740 duplicate_child_non_owner->SetDrawsContent(true); | 4745 duplicate_child_non_owner->SetDrawsContent(true); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4825 | 4830 |
| 4826 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4831 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4827 child->SetBounds(gfx::Size(13, 11)); | 4832 child->SetBounds(gfx::Size(13, 11)); |
| 4828 child->SetDrawsContent(true); | 4833 child->SetDrawsContent(true); |
| 4829 child->test_properties()->force_render_surface = true; | 4834 child->test_properties()->force_render_surface = true; |
| 4830 | 4835 |
| 4831 gfx::Transform replica_transform; | 4836 gfx::Transform replica_transform; |
| 4832 replica_transform.Scale(1.0, -1.0); | 4837 replica_transform.Scale(1.0, -1.0); |
| 4833 std::unique_ptr<LayerImpl> replica = | 4838 std::unique_ptr<LayerImpl> replica = |
| 4834 LayerImpl::Create(host_impl()->active_tree(), 7); | 4839 LayerImpl::Create(host_impl()->active_tree(), 7); |
| 4835 replica->SetTransform(replica_transform); | 4840 replica->test_properties()->transform = replica_transform; |
| 4836 child->test_properties()->SetReplicaLayer(std::move(replica)); | 4841 child->test_properties()->SetReplicaLayer(std::move(replica)); |
| 4837 | 4842 |
| 4838 float device_scale_factor = 1.7f; | 4843 float device_scale_factor = 1.7f; |
| 4839 ExecuteCalculateDrawProperties(parent, device_scale_factor); | 4844 ExecuteCalculateDrawProperties(parent, device_scale_factor); |
| 4840 | 4845 |
| 4841 // We should have two render surfaces. The root's render surface and child's | 4846 // We should have two render surfaces. The root's render surface and child's |
| 4842 // render surface (it needs one because it has a replica layer). | 4847 // render surface (it needs one because it has a replica layer). |
| 4843 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 4848 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
| 4844 | 4849 |
| 4845 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 4850 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5081 | 5086 |
| 5082 // Case 1: Identity transform. | 5087 // Case 1: Identity transform. |
| 5083 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5088 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5084 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5089 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5085 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5090 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 5086 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5091 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5087 | 5092 |
| 5088 // Case 2: Integral translation. | 5093 // Case 2: Integral translation. |
| 5089 gfx::Transform integral_translation; | 5094 gfx::Transform integral_translation; |
| 5090 integral_translation.Translate(1.0, 2.0); | 5095 integral_translation.Translate(1.0, 2.0); |
| 5091 child_->SetTransform(integral_translation); | 5096 child_->test_properties()->transform = integral_translation; |
| 5092 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5097 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5093 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5098 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5094 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5099 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5095 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5100 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 5096 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5101 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5097 | 5102 |
| 5098 // Case 3: Non-integral translation. | 5103 // Case 3: Non-integral translation. |
| 5099 gfx::Transform non_integral_translation; | 5104 gfx::Transform non_integral_translation; |
| 5100 non_integral_translation.Translate(1.5, 2.5); | 5105 non_integral_translation.Translate(1.5, 2.5); |
| 5101 child_->SetTransform(non_integral_translation); | 5106 child_->test_properties()->transform = non_integral_translation; |
| 5102 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5107 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5103 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5108 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5104 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5109 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5105 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5110 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5106 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5111 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 5107 | 5112 |
| 5108 // Case 4: Rotation. | 5113 // Case 4: Rotation. |
| 5109 gfx::Transform rotation; | 5114 gfx::Transform rotation; |
| 5110 rotation.Rotate(10.0); | 5115 rotation.Rotate(10.0); |
| 5111 child_->SetTransform(rotation); | 5116 child_->test_properties()->transform = rotation; |
| 5112 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5117 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5113 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5118 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5114 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5119 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5115 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5120 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5116 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5121 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 5117 | 5122 |
| 5118 // Case 5: Scale. | 5123 // Case 5: Scale. |
| 5119 gfx::Transform scale; | 5124 gfx::Transform scale; |
| 5120 scale.Scale(2.0, 2.0); | 5125 scale.Scale(2.0, 2.0); |
| 5121 child_->SetTransform(scale); | 5126 child_->test_properties()->transform = scale; |
| 5122 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5127 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5123 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5128 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5124 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5129 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5125 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5130 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5126 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5131 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 5127 | 5132 |
| 5128 // Case 6: Skew. | 5133 // Case 6: Skew. |
| 5129 gfx::Transform skew; | 5134 gfx::Transform skew; |
| 5130 skew.Skew(10.0, 0.0); | 5135 skew.Skew(10.0, 0.0); |
| 5131 child_->SetTransform(skew); | 5136 child_->test_properties()->transform = skew; |
| 5132 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5137 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5133 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5138 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5134 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5139 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5135 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5140 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5136 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5141 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 5137 | 5142 |
| 5138 // Case 7: Translucent. | 5143 // Case 7: Translucent. |
| 5139 child_->SetTransform(gfx::Transform()); | 5144 child_->test_properties()->transform = gfx::Transform(); |
| 5140 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5145 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5141 child_->test_properties()->opacity = 0.5f; | 5146 child_->test_properties()->opacity = 0.5f; |
| 5142 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5147 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5143 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5148 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5144 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 5149 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 5145 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 5150 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 5146 | 5151 |
| 5147 // Case 8: Sanity check: restore transform and opacity. | 5152 // Case 8: Sanity check: restore transform and opacity. |
| 5148 child_->SetTransform(gfx::Transform()); | 5153 child_->test_properties()->transform = gfx::Transform(); |
| 5149 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5154 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5150 child_->test_properties()->opacity = 1.f; | 5155 child_->test_properties()->opacity = 1.f; |
| 5151 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5156 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| 5152 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 5157 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 5153 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 5158 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 5154 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 5159 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 5155 | 5160 |
| 5156 // Case 9: Non-opaque content. | 5161 // Case 9: Non-opaque content. |
| 5157 child_->SetContentsOpaque(false); | 5162 child_->SetContentsOpaque(false); |
| 5158 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); | 5163 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, nullptr); |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5629 | 5634 |
| 5630 intervening->SetMasksToBounds(true); | 5635 intervening->SetMasksToBounds(true); |
| 5631 clip_parent->SetMasksToBounds(true); | 5636 clip_parent->SetMasksToBounds(true); |
| 5632 | 5637 |
| 5633 gfx::Transform scale_transform; | 5638 gfx::Transform scale_transform; |
| 5634 scale_transform.Scale(2, 2); | 5639 scale_transform.Scale(2, 2); |
| 5635 | 5640 |
| 5636 root->SetBounds(gfx::Size(50, 50)); | 5641 root->SetBounds(gfx::Size(50, 50)); |
| 5637 render_surface->SetBounds(gfx::Size(10, 10)); | 5642 render_surface->SetBounds(gfx::Size(10, 10)); |
| 5638 render_surface->test_properties()->force_render_surface = true; | 5643 render_surface->test_properties()->force_render_surface = true; |
| 5639 clip_parent->SetTransform(scale_transform); | 5644 clip_parent->test_properties()->transform = scale_transform; |
| 5640 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); | 5645 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5641 clip_parent->SetBounds(gfx::Size(10, 10)); | 5646 clip_parent->SetBounds(gfx::Size(10, 10)); |
| 5642 intervening->SetPosition(gfx::PointF(1.f, 1.f)); | 5647 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5643 intervening->SetBounds(gfx::Size(5, 5)); | 5648 intervening->SetBounds(gfx::Size(5, 5)); |
| 5644 clip_child->SetPosition(gfx::PointF(1.f, 1.f)); | 5649 clip_child->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5645 clip_child->SetBounds(gfx::Size(10, 10)); | 5650 clip_child->SetBounds(gfx::Size(10, 10)); |
| 5646 ExecuteCalculateDrawProperties(root); | 5651 ExecuteCalculateDrawProperties(root); |
| 5647 | 5652 |
| 5648 ASSERT_TRUE(root->render_surface()); | 5653 ASSERT_TRUE(root->render_surface()); |
| 5649 ASSERT_TRUE(render_surface->render_surface()); | 5654 ASSERT_TRUE(render_surface->render_surface()); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5773 | 5778 |
| 5774 intervening->SetMasksToBounds(true); | 5779 intervening->SetMasksToBounds(true); |
| 5775 clip_parent->SetMasksToBounds(true); | 5780 clip_parent->SetMasksToBounds(true); |
| 5776 intervening->SetScrollClipLayer(clip_parent->id()); | 5781 intervening->SetScrollClipLayer(clip_parent->id()); |
| 5777 intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3)); | 5782 intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3)); |
| 5778 | 5783 |
| 5779 gfx::Transform translation_transform; | 5784 gfx::Transform translation_transform; |
| 5780 translation_transform.Translate(2, 2); | 5785 translation_transform.Translate(2, 2); |
| 5781 | 5786 |
| 5782 root->SetBounds(gfx::Size(50, 50)); | 5787 root->SetBounds(gfx::Size(50, 50)); |
| 5783 clip_parent->SetTransform(translation_transform); | 5788 clip_parent->test_properties()->transform = translation_transform; |
| 5784 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); | 5789 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5785 clip_parent->SetBounds(gfx::Size(40, 40)); | 5790 clip_parent->SetBounds(gfx::Size(40, 40)); |
| 5786 render_surface1->SetBounds(gfx::Size(10, 10)); | 5791 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 5787 render_surface1->test_properties()->force_render_surface = true; | 5792 render_surface1->test_properties()->force_render_surface = true; |
| 5788 intervening->SetPosition(gfx::PointF(1.f, 1.f)); | 5793 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5789 intervening->SetBounds(gfx::Size(5, 5)); | 5794 intervening->SetBounds(gfx::Size(5, 5)); |
| 5790 render_surface2->SetBounds(gfx::Size(10, 10)); | 5795 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5791 render_surface2->test_properties()->force_render_surface = true; | 5796 render_surface2->test_properties()->force_render_surface = true; |
| 5792 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); | 5797 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5793 clip_child->SetBounds(gfx::Size(60, 60)); | 5798 clip_child->SetBounds(gfx::Size(60, 60)); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6130 .size()); | 6135 .size()); |
| 6131 EXPECT_EQ(1u, render_surface_layer_list_impl() | 6136 EXPECT_EQ(1u, render_surface_layer_list_impl() |
| 6132 ->at(1) | 6137 ->at(1) |
| 6133 ->render_surface() | 6138 ->render_surface() |
| 6134 ->layer_list() | 6139 ->layer_list() |
| 6135 .size()); | 6140 .size()); |
| 6136 | 6141 |
| 6137 gfx::Transform rotation_transform; | 6142 gfx::Transform rotation_transform; |
| 6138 rotation_transform.RotateAboutXAxis(180.0); | 6143 rotation_transform.RotateAboutXAxis(180.0); |
| 6139 | 6144 |
| 6140 back_facing->SetTransform(rotation_transform); | 6145 back_facing->test_properties()->transform = rotation_transform; |
| 6141 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6146 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6142 | 6147 |
| 6143 ExecuteCalculateDrawProperties(root); | 6148 ExecuteCalculateDrawProperties(root); |
| 6144 | 6149 |
| 6145 // render_surface1 is in the same 3d rendering context as back_facing and is | 6150 // render_surface1 is in the same 3d rendering context as back_facing and is |
| 6146 // not double sided, so it should not be in RSLL. render_surface2 is also not | 6151 // not double sided, so it should not be in RSLL. render_surface2 is also not |
| 6147 // double-sided, but will still be in RSLL as it's in a different 3d rendering | 6152 // double-sided, but will still be in RSLL as it's in a different 3d rendering |
| 6148 // context. | 6153 // context. |
| 6149 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 6154 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
| 6150 EXPECT_EQ(1u, render_surface_layer_list_impl() | 6155 EXPECT_EQ(1u, render_surface_layer_list_impl() |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6183 EXPECT_FALSE(grand_child->should_check_backface_visibility()); | 6188 EXPECT_FALSE(grand_child->should_check_backface_visibility()); |
| 6184 // As there are no 3d rendering contexts, all layers should use their local | 6189 // As there are no 3d rendering contexts, all layers should use their local |
| 6185 // transform for backface visibility. | 6190 // transform for backface visibility. |
| 6186 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); | 6191 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); |
| 6187 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); | 6192 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); |
| 6188 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); | 6193 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); |
| 6189 | 6194 |
| 6190 gfx::Transform rotation_transform; | 6195 gfx::Transform rotation_transform; |
| 6191 rotation_transform.RotateAboutXAxis(180.0); | 6196 rotation_transform.RotateAboutXAxis(180.0); |
| 6192 | 6197 |
| 6193 child->SetTransform(rotation_transform); | 6198 child->test_properties()->transform = rotation_transform; |
| 6194 child->Set3dSortingContextId(1); | 6199 child->Set3dSortingContextId(1); |
| 6195 grand_child->Set3dSortingContextId(1); | 6200 grand_child->Set3dSortingContextId(1); |
| 6196 child->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6201 child->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6197 | 6202 |
| 6198 ExecuteCalculateDrawProperties(root); | 6203 ExecuteCalculateDrawProperties(root); |
| 6199 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); | 6204 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); |
| 6200 EXPECT_EQ(0u, render_surface_layer_list_impl() | 6205 EXPECT_EQ(0u, render_surface_layer_list_impl() |
| 6201 ->at(0) | 6206 ->at(0) |
| 6202 ->render_surface() | 6207 ->render_surface() |
| 6203 ->layer_list() | 6208 ->layer_list() |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6247 LayerImpl* back_facing = AddChild<LayerImpl>(root); | 6252 LayerImpl* back_facing = AddChild<LayerImpl>(root); |
| 6248 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); | 6253 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); |
| 6249 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); | 6254 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); |
| 6250 | 6255 |
| 6251 gfx::Transform rotate_about_y; | 6256 gfx::Transform rotate_about_y; |
| 6252 rotate_about_y.RotateAboutYAxis(180.0); | 6257 rotate_about_y.RotateAboutYAxis(180.0); |
| 6253 | 6258 |
| 6254 root->SetBounds(gfx::Size(50, 50)); | 6259 root->SetBounds(gfx::Size(50, 50)); |
| 6255 root->Set3dSortingContextId(1); | 6260 root->Set3dSortingContextId(1); |
| 6256 root->test_properties()->should_flatten_transform = false; | 6261 root->test_properties()->should_flatten_transform = false; |
| 6257 back_facing->SetTransform(rotate_about_y); | 6262 back_facing->test_properties()->transform = rotate_about_y; |
| 6258 back_facing->SetBounds(gfx::Size(50, 50)); | 6263 back_facing->SetBounds(gfx::Size(50, 50)); |
| 6259 back_facing->Set3dSortingContextId(1); | 6264 back_facing->Set3dSortingContextId(1); |
| 6260 back_facing->test_properties()->should_flatten_transform = false; | 6265 back_facing->test_properties()->should_flatten_transform = false; |
| 6261 render_surface1->SetBounds(gfx::Size(30, 30)); | 6266 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 6262 render_surface1->Set3dSortingContextId(1); | 6267 render_surface1->Set3dSortingContextId(1); |
| 6263 render_surface1->test_properties()->should_flatten_transform = false; | 6268 render_surface1->test_properties()->should_flatten_transform = false; |
| 6264 render_surface1->test_properties()->double_sided = false; | 6269 render_surface1->test_properties()->double_sided = false; |
| 6265 render_surface1->test_properties()->force_render_surface = true; | 6270 render_surface1->test_properties()->force_render_surface = true; |
| 6266 render_surface2->SetBounds(gfx::Size(30, 30)); | 6271 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 6267 render_surface2->Set3dSortingContextId(1); | 6272 render_surface2->Set3dSortingContextId(1); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6391 child->Set3dSortingContextId(1); | 6396 child->Set3dSortingContextId(1); |
| 6392 child->test_properties()->force_render_surface = true; | 6397 child->test_properties()->force_render_surface = true; |
| 6393 ExecuteCalculateDrawProperties(root); | 6398 ExecuteCalculateDrawProperties(root); |
| 6394 | 6399 |
| 6395 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); | 6400 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); |
| 6396 | 6401 |
| 6397 gfx::Transform singular_transform; | 6402 gfx::Transform singular_transform; |
| 6398 singular_transform.Scale3d( | 6403 singular_transform.Scale3d( |
| 6399 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 6404 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
| 6400 | 6405 |
| 6401 child->SetTransform(singular_transform); | 6406 child->test_properties()->transform = singular_transform; |
| 6402 | 6407 |
| 6403 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6408 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6404 ExecuteCalculateDrawProperties(root); | 6409 ExecuteCalculateDrawProperties(root); |
| 6405 | 6410 |
| 6406 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 6411 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
| 6407 | 6412 |
| 6408 // Ensure that the entire subtree under a layer with singular transform does | 6413 // Ensure that the entire subtree under a layer with singular transform does |
| 6409 // not get rendered. | 6414 // not get rendered. |
| 6410 parent->SetTransform(singular_transform); | 6415 parent->test_properties()->transform = singular_transform; |
| 6411 child->SetTransform(gfx::Transform()); | 6416 child->test_properties()->transform = gfx::Transform(); |
| 6412 | 6417 |
| 6413 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6418 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6414 ExecuteCalculateDrawProperties(root); | 6419 ExecuteCalculateDrawProperties(root); |
| 6415 | 6420 |
| 6416 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); | 6421 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); |
| 6417 } | 6422 } |
| 6418 | 6423 |
| 6419 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { | 6424 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { |
| 6420 // Checks that clipping by a scroll parent that follows you in paint order | 6425 // Checks that clipping by a scroll parent that follows you in paint order |
| 6421 // still results in correct clipping. | 6426 // still results in correct clipping. |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6699 constraint.set_is_fixed_position(true); | 6704 constraint.set_is_fixed_position(true); |
| 6700 fixed->test_properties()->position_constraint = constraint; | 6705 fixed->test_properties()->position_constraint = constraint; |
| 6701 | 6706 |
| 6702 scroller->SetScrollClipLayer(container->id()); | 6707 scroller->SetScrollClipLayer(container->id()); |
| 6703 | 6708 |
| 6704 gfx::Transform container_transform; | 6709 gfx::Transform container_transform; |
| 6705 container_transform.Translate3d(10.0, 20.0, 0.0); | 6710 container_transform.Translate3d(10.0, 20.0, 0.0); |
| 6706 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 6711 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
| 6707 | 6712 |
| 6708 root->SetBounds(gfx::Size(50, 50)); | 6713 root->SetBounds(gfx::Size(50, 50)); |
| 6709 container->SetTransform(container_transform); | 6714 container->test_properties()->transform = container_transform; |
| 6710 container->SetBounds(gfx::Size(40, 40)); | 6715 container->SetBounds(gfx::Size(40, 40)); |
| 6711 container->SetDrawsContent(true); | 6716 container->SetDrawsContent(true); |
| 6712 scroller->SetBounds(gfx::Size(30, 30)); | 6717 scroller->SetBounds(gfx::Size(30, 30)); |
| 6713 scroller->SetDrawsContent(true); | 6718 scroller->SetDrawsContent(true); |
| 6714 fixed->SetBounds(gfx::Size(50, 50)); | 6719 fixed->SetBounds(gfx::Size(50, 50)); |
| 6715 fixed->SetDrawsContent(true); | 6720 fixed->SetDrawsContent(true); |
| 6716 | 6721 |
| 6717 scroller->test_properties()->AddChild(std::move(fixed)); | 6722 scroller->test_properties()->AddChild(std::move(fixed)); |
| 6718 container->test_properties()->AddChild(std::move(scroller)); | 6723 container->test_properties()->AddChild(std::move(scroller)); |
| 6719 root->test_properties()->AddChild(std::move(container)); | 6724 root->test_properties()->AddChild(std::move(container)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6765 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 6770 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
| 6766 .screen_space_transform.To2dTranslation(), | 6771 .screen_space_transform.To2dTranslation(), |
| 6767 container_offset - rounded_scroll_delta); | 6772 container_offset - rounded_scroll_delta); |
| 6768 } | 6773 } |
| 6769 | 6774 |
| 6770 // Scale is applied earlier in the tree. | 6775 // Scale is applied earlier in the tree. |
| 6771 { | 6776 { |
| 6772 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 6777 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
| 6773 gfx::Transform scaled_container_transform = container_transform; | 6778 gfx::Transform scaled_container_transform = container_transform; |
| 6774 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); | 6779 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); |
| 6775 container_layer->SetTransform(scaled_container_transform); | 6780 container_layer->test_properties()->transform = scaled_container_transform; |
| 6776 | 6781 |
| 6777 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6782 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6778 | 6783 |
| 6779 gfx::Vector2dF scroll_delta(4.5f, 8.5f); | 6784 gfx::Vector2dF scroll_delta(4.5f, 8.5f); |
| 6780 SetScrollOffsetDelta(scroll_layer, scroll_delta); | 6785 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
| 6781 | 6786 |
| 6782 LayerImplList render_surface_layer_list; | 6787 LayerImplList render_surface_layer_list; |
| 6783 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6788 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 6784 root, root->bounds(), &render_surface_layer_list); | 6789 root, root->bounds(), &render_surface_layer_list); |
| 6785 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 6790 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 6786 | 6791 |
| 6787 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6792 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 6788 container_layer->draw_properties().screen_space_transform, | 6793 container_layer->draw_properties().screen_space_transform, |
| 6789 fixed_layer->draw_properties().screen_space_transform); | 6794 fixed_layer->draw_properties().screen_space_transform); |
| 6790 EXPECT_VECTOR_EQ( | 6795 EXPECT_VECTOR_EQ( |
| 6791 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 6796 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
| 6792 container_offset); | 6797 container_offset); |
| 6793 | 6798 |
| 6794 container_layer->SetTransform(container_transform); | 6799 container_layer->test_properties()->transform = container_transform; |
| 6795 } | 6800 } |
| 6796 } | 6801 } |
| 6797 | 6802 |
| 6798 TEST_F(LayerTreeHostCommonTest, | 6803 TEST_F(LayerTreeHostCommonTest, |
| 6799 ScrollSnappingWithAnimatedScreenSpaceTransform) { | 6804 ScrollSnappingWithAnimatedScreenSpaceTransform) { |
| 6800 // This test verifies that a scrolling layer whose screen space transform is | 6805 // This test verifies that a scrolling layer whose screen space transform is |
| 6801 // animating doesn't get snapped to integer coordinates. | 6806 // animating doesn't get snapped to integer coordinates. |
| 6802 // | 6807 // |
| 6803 // + root | 6808 // + root |
| 6804 // + animated layer | 6809 // + animated layer |
| 6805 // + surface | 6810 // + surface |
| 6806 // + container | 6811 // + container |
| 6807 // + scroller | 6812 // + scroller |
| 6808 // | 6813 // |
| 6809 LayerImpl* root = root_layer_for_testing(); | 6814 LayerImpl* root = root_layer_for_testing(); |
| 6810 LayerImpl* animated_layer = AddChildToRoot<FakePictureLayerImpl>(); | 6815 LayerImpl* animated_layer = AddChildToRoot<FakePictureLayerImpl>(); |
| 6811 LayerImpl* surface = AddChild<LayerImpl>(animated_layer); | 6816 LayerImpl* surface = AddChild<LayerImpl>(animated_layer); |
| 6812 LayerImpl* container = AddChild<LayerImpl>(surface); | 6817 LayerImpl* container = AddChild<LayerImpl>(surface); |
| 6813 LayerImpl* scroller = AddChild<LayerImpl>(container); | 6818 LayerImpl* scroller = AddChild<LayerImpl>(container); |
| 6814 | 6819 |
| 6815 gfx::Transform start_scale; | 6820 gfx::Transform start_scale; |
| 6816 start_scale.Scale(1.5f, 1.5f); | 6821 start_scale.Scale(1.5f, 1.5f); |
| 6817 | 6822 |
| 6818 root->SetBounds(gfx::Size(50, 50)); | 6823 root->SetBounds(gfx::Size(50, 50)); |
| 6819 animated_layer->SetTransform(start_scale); | 6824 animated_layer->test_properties()->transform = start_scale; |
| 6820 animated_layer->SetBounds(gfx::Size(50, 50)); | 6825 animated_layer->SetBounds(gfx::Size(50, 50)); |
| 6821 surface->SetBounds(gfx::Size(50, 50)); | 6826 surface->SetBounds(gfx::Size(50, 50)); |
| 6822 surface->test_properties()->force_render_surface = true; | 6827 surface->test_properties()->force_render_surface = true; |
| 6823 container->SetBounds(gfx::Size(50, 50)); | 6828 container->SetBounds(gfx::Size(50, 50)); |
| 6824 scroller->SetBounds(gfx::Size(100, 100)); | 6829 scroller->SetBounds(gfx::Size(100, 100)); |
| 6825 scroller->SetScrollClipLayer(container->id()); | 6830 scroller->SetScrollClipLayer(container->id()); |
| 6826 scroller->SetDrawsContent(true); | 6831 scroller->SetDrawsContent(true); |
| 6827 | 6832 |
| 6828 gfx::Transform end_scale; | 6833 gfx::Transform end_scale; |
| 6829 end_scale.Scale(2.f, 2.f); | 6834 end_scale.Scale(2.f, 2.f); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7160 | 7165 |
| 7161 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); | 7166 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7162 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); | 7167 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7163 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); | 7168 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7164 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); | 7169 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7165 | 7170 |
| 7166 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, | 7171 AbortAnimationsOnElementWithPlayer(child_raw->element_id(), timeline, |
| 7167 TargetProperty::TRANSFORM); | 7172 TargetProperty::TRANSFORM); |
| 7168 gfx::Transform scale_matrix; | 7173 gfx::Transform scale_matrix; |
| 7169 scale_matrix.Scale(1.f, 2.f); | 7174 scale_matrix.Scale(1.f, 2.f); |
| 7170 grand_parent_raw->SetTransform(scale_matrix); | 7175 grand_parent_raw->test_properties()->transform = scale_matrix; |
| 7171 parent_raw->SetTransform(scale_matrix); | 7176 parent_raw->test_properties()->transform = scale_matrix; |
| 7172 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7177 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7173 | 7178 |
| 7174 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, | 7179 AddAnimatedTransformToElementWithPlayer(parent_raw->element_id(), timeline, |
| 7175 1.0, TransformOperations(), scale); | 7180 1.0, TransformOperations(), scale); |
| 7176 ExecuteCalculateDrawProperties(grand_parent_raw); | 7181 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7177 | 7182 |
| 7178 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale | 7183 // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale |
| 7179 // animation with maximum scale 5.f. | 7184 // animation with maximum scale 5.f. |
| 7180 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 7185 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7181 EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw)); | 7186 EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw)); |
| 7182 EXPECT_EQ(10.f, GetMaximumAnimationScale(child_raw)); | 7187 EXPECT_EQ(10.f, GetMaximumAnimationScale(child_raw)); |
| 7183 EXPECT_EQ(10.f, GetMaximumAnimationScale(grand_child_raw)); | 7188 EXPECT_EQ(10.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7184 | 7189 |
| 7185 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); | 7190 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7186 EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw)); | 7191 EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw)); |
| 7187 EXPECT_EQ(2.f, GetStartingAnimationScale(child_raw)); | 7192 EXPECT_EQ(2.f, GetStartingAnimationScale(child_raw)); |
| 7188 EXPECT_EQ(2.f, GetStartingAnimationScale(grand_child_raw)); | 7193 EXPECT_EQ(2.f, GetStartingAnimationScale(grand_child_raw)); |
| 7189 | 7194 |
| 7190 gfx::Transform perspective_matrix; | 7195 gfx::Transform perspective_matrix; |
| 7191 perspective_matrix.ApplyPerspectiveDepth(2.f); | 7196 perspective_matrix.ApplyPerspectiveDepth(2.f); |
| 7192 child_raw->SetTransform(perspective_matrix); | 7197 child_raw->test_properties()->transform = perspective_matrix; |
| 7193 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7198 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7194 ExecuteCalculateDrawProperties(grand_parent_raw); | 7199 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7195 | 7200 |
| 7196 // |child| has a transform that's neither a translation nor a scale. | 7201 // |child| has a transform that's neither a translation nor a scale. |
| 7197 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 7202 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7198 EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw)); | 7203 EXPECT_EQ(10.f, GetMaximumAnimationScale(parent_raw)); |
| 7199 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); | 7204 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7200 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); | 7205 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7201 | 7206 |
| 7202 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); | 7207 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7203 EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw)); | 7208 EXPECT_EQ(2.f, GetStartingAnimationScale(parent_raw)); |
| 7204 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); | 7209 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7205 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); | 7210 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7206 | 7211 |
| 7207 parent_raw->SetTransform(perspective_matrix); | 7212 parent_raw->test_properties()->transform = perspective_matrix; |
| 7208 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7213 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7209 ExecuteCalculateDrawProperties(grand_parent_raw); | 7214 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7210 | 7215 |
| 7211 // |parent| and |child| have transforms that are neither translations nor | 7216 // |parent| and |child| have transforms that are neither translations nor |
| 7212 // scales. | 7217 // scales. |
| 7213 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 7218 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7214 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); | 7219 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7215 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); | 7220 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7216 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); | 7221 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7217 | 7222 |
| 7218 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); | 7223 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7219 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); | 7224 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7220 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); | 7225 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7221 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); | 7226 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7222 | 7227 |
| 7223 parent_raw->SetTransform(gfx::Transform()); | 7228 parent_raw->test_properties()->transform = gfx::Transform(); |
| 7224 child_raw->SetTransform(gfx::Transform()); | 7229 child_raw->test_properties()->transform = gfx::Transform(); |
| 7225 grand_parent_raw->SetTransform(perspective_matrix); | 7230 grand_parent_raw->test_properties()->transform = perspective_matrix; |
| 7226 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7231 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7227 | 7232 |
| 7228 ExecuteCalculateDrawProperties(grand_parent_raw); | 7233 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7229 | 7234 |
| 7230 // |grand_parent| has a transform that's neither a translation nor a scale. | 7235 // |grand_parent| has a transform that's neither a translation nor a scale. |
| 7231 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 7236 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7232 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); | 7237 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7233 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); | 7238 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7234 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); | 7239 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7235 | 7240 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7517 std::unique_ptr<LayerImpl> child2 = | 7522 std::unique_ptr<LayerImpl> child2 = |
| 7518 LayerImpl::Create(host_impl.active_tree(), 3); | 7523 LayerImpl::Create(host_impl.active_tree(), 3); |
| 7519 LayerImpl* child2_layer = child2.get(); | 7524 LayerImpl* child2_layer = child2.get(); |
| 7520 | 7525 |
| 7521 gfx::Transform scale_transform_child1, scale_transform_child2; | 7526 gfx::Transform scale_transform_child1, scale_transform_child2; |
| 7522 scale_transform_child1.Scale(2, 3); | 7527 scale_transform_child1.Scale(2, 3); |
| 7523 scale_transform_child2.Scale(4, 5); | 7528 scale_transform_child2.Scale(4, 5); |
| 7524 | 7529 |
| 7525 root->SetBounds(gfx::Size(1, 1)); | 7530 root->SetBounds(gfx::Size(1, 1)); |
| 7526 root->SetDrawsContent(true); | 7531 root->SetDrawsContent(true); |
| 7527 child1_layer->SetTransform(scale_transform_child1); | 7532 child1_layer->test_properties()->transform = scale_transform_child1; |
| 7528 child1_layer->SetBounds(gfx::Size(1, 1)); | 7533 child1_layer->SetBounds(gfx::Size(1, 1)); |
| 7529 child1_layer->SetDrawsContent(true); | 7534 child1_layer->SetDrawsContent(true); |
| 7530 | 7535 |
| 7531 child1_layer->test_properties()->SetMaskLayer( | 7536 child1_layer->test_properties()->SetMaskLayer( |
| 7532 LayerImpl::Create(host_impl.active_tree(), 4)); | 7537 LayerImpl::Create(host_impl.active_tree(), 4)); |
| 7533 | 7538 |
| 7534 std::unique_ptr<LayerImpl> replica_layer = | 7539 std::unique_ptr<LayerImpl> replica_layer = |
| 7535 LayerImpl::Create(host_impl.active_tree(), 5); | 7540 LayerImpl::Create(host_impl.active_tree(), 5); |
| 7536 replica_layer->test_properties()->SetMaskLayer( | 7541 replica_layer->test_properties()->SetMaskLayer( |
| 7537 LayerImpl::Create(host_impl.active_tree(), 6)); | 7542 LayerImpl::Create(host_impl.active_tree(), 6)); |
| 7538 child1_layer->test_properties()->SetReplicaLayer(std::move(replica_layer)); | 7543 child1_layer->test_properties()->SetReplicaLayer(std::move(replica_layer)); |
| 7539 | 7544 |
| 7540 root->test_properties()->AddChild(std::move(child1)); | 7545 root->test_properties()->AddChild(std::move(child1)); |
| 7541 root->test_properties()->AddChild(std::move(child2)); | 7546 root->test_properties()->AddChild(std::move(child2)); |
| 7542 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 7547 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7543 host_impl.active_tree()->SetElementIdsForTesting(); | 7548 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7544 | 7549 |
| 7545 ExecuteCalculateDrawProperties(root_layer); | 7550 ExecuteCalculateDrawProperties(root_layer); |
| 7546 | 7551 |
| 7547 TransformOperations scale; | 7552 TransformOperations scale; |
| 7548 scale.AppendScale(5.f, 8.f, 3.f); | 7553 scale.AppendScale(5.f, 8.f, 3.f); |
| 7549 | 7554 |
| 7550 scoped_refptr<AnimationTimeline> timeline = | 7555 scoped_refptr<AnimationTimeline> timeline = |
| 7551 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7556 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7552 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7557 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7553 | 7558 |
| 7554 child2_layer->SetTransform(scale_transform_child2); | 7559 child2_layer->test_properties()->transform = scale_transform_child2; |
| 7555 child2_layer->SetBounds(gfx::Size(1, 1)); | 7560 child2_layer->SetBounds(gfx::Size(1, 1)); |
| 7556 child2_layer->SetDrawsContent(true); | 7561 child2_layer->SetDrawsContent(true); |
| 7557 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, | 7562 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, |
| 7558 1.0, TransformOperations(), scale); | 7563 1.0, TransformOperations(), scale); |
| 7559 | 7564 |
| 7560 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7565 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7561 ExecuteCalculateDrawProperties(root_layer); | 7566 ExecuteCalculateDrawProperties(root_layer); |
| 7562 | 7567 |
| 7563 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7568 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
| 7564 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 7569 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7649 child1_layer->test_properties()->AddChild(std::move(child2)); | 7654 child1_layer->test_properties()->AddChild(std::move(child2)); |
| 7650 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 7655 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7651 | 7656 |
| 7652 host_impl.active_tree()->SetElementIdsForTesting(); | 7657 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7653 | 7658 |
| 7654 gfx::Transform scale_transform_child1, scale_transform_child2; | 7659 gfx::Transform scale_transform_child1, scale_transform_child2; |
| 7655 scale_transform_child1.Scale(2, 3); | 7660 scale_transform_child1.Scale(2, 3); |
| 7656 scale_transform_child2.Scale(4, 5); | 7661 scale_transform_child2.Scale(4, 5); |
| 7657 | 7662 |
| 7658 root_layer->SetBounds(gfx::Size(1, 1)); | 7663 root_layer->SetBounds(gfx::Size(1, 1)); |
| 7659 child1_layer->SetTransform(scale_transform_child1); | 7664 child1_layer->test_properties()->transform = scale_transform_child1; |
| 7660 child1_layer->SetBounds(gfx::Size(1, 1)); | 7665 child1_layer->SetBounds(gfx::Size(1, 1)); |
| 7661 child2_layer->SetTransform(scale_transform_child2); | 7666 child2_layer->test_properties()->transform = scale_transform_child2; |
| 7662 child2_layer->SetBounds(gfx::Size(1, 1)); | 7667 child2_layer->SetBounds(gfx::Size(1, 1)); |
| 7663 | 7668 |
| 7664 TransformOperations scale; | 7669 TransformOperations scale; |
| 7665 scale.AppendScale(5.f, 8.f, 3.f); | 7670 scale.AppendScale(5.f, 8.f, 3.f); |
| 7666 | 7671 |
| 7667 scoped_refptr<AnimationTimeline> timeline = | 7672 scoped_refptr<AnimationTimeline> timeline = |
| 7668 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7673 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7669 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7674 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7670 | 7675 |
| 7671 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, | 7676 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, |
| 7672 1.0, TransformOperations(), scale); | 7677 1.0, TransformOperations(), scale); |
| 7673 | 7678 |
| 7674 // Correctly computes animation scale when rebuilding property trees. | 7679 // Correctly computes animation scale when rebuilding property trees. |
| 7675 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7680 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7676 ExecuteCalculateDrawProperties(root_layer); | 7681 ExecuteCalculateDrawProperties(root_layer); |
| 7677 | 7682 |
| 7678 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); | 7683 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
| 7679 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); | 7684 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
| 7680 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); | 7685 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); |
| 7681 | 7686 |
| 7682 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); | 7687 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); |
| 7683 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); | 7688 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); |
| 7684 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); | 7689 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); |
| 7685 | 7690 |
| 7686 // Correctly updates animation scale when layer property changes. | 7691 // Correctly updates animation scale when layer property changes. |
| 7687 child1_layer->SetTransform(gfx::Transform()); | 7692 child1_layer->test_properties()->transform = gfx::Transform(); |
| 7688 child1_layer->UpdatePropertyTreeTransform(); | 7693 child1_layer->UpdatePropertyTreeTransform(gfx::Transform()); |
| 7689 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; | 7694 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; |
| 7690 ExecuteCalculateDrawProperties(root_layer); | 7695 ExecuteCalculateDrawProperties(root_layer); |
| 7691 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); | 7696 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); |
| 7692 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); | 7697 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); |
| 7693 | 7698 |
| 7694 // Do not update animation scale if already updated. | 7699 // Do not update animation scale if already updated. |
| 7695 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( | 7700 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( |
| 7696 child2_layer->transform_tree_index(), 100.f, 100.f); | 7701 child2_layer->transform_tree_index(), 100.f, 100.f); |
| 7697 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); | 7702 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); |
| 7698 EXPECT_FLOAT_EQ(100.f, GetStartingAnimationScale(child2_layer)); | 7703 EXPECT_FLOAT_EQ(100.f, GetStartingAnimationScale(child2_layer)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7719 | 7724 |
| 7720 root->test_properties()->AddChild(std::move(child)); | 7725 root->test_properties()->AddChild(std::move(child)); |
| 7721 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 7726 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7722 | 7727 |
| 7723 host_impl.active_tree()->SetElementIdsForTesting(); | 7728 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7724 | 7729 |
| 7725 gfx::Transform scale_transform_child; | 7730 gfx::Transform scale_transform_child; |
| 7726 scale_transform_child.Scale(4, 5); | 7731 scale_transform_child.Scale(4, 5); |
| 7727 | 7732 |
| 7728 root_layer->SetBounds(gfx::Size(1, 1)); | 7733 root_layer->SetBounds(gfx::Size(1, 1)); |
| 7729 child_layer->SetTransform(scale_transform_child); | 7734 child_layer->test_properties()->transform = scale_transform_child; |
| 7730 child_layer->SetBounds(gfx::Size(1, 1)); | 7735 child_layer->SetBounds(gfx::Size(1, 1)); |
| 7731 | 7736 |
| 7732 TransformOperations scale; | 7737 TransformOperations scale; |
| 7733 scale.AppendScale(5.f, 8.f, 3.f); | 7738 scale.AppendScale(5.f, 8.f, 3.f); |
| 7734 | 7739 |
| 7735 scoped_refptr<AnimationTimeline> timeline = | 7740 scoped_refptr<AnimationTimeline> timeline = |
| 7736 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7741 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7737 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7742 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7738 | 7743 |
| 7739 AddAnimatedTransformToElementWithPlayer(child_layer->element_id(), timeline, | 7744 AddAnimatedTransformToElementWithPlayer(child_layer->element_id(), timeline, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7931 animated->SetDrawsContent(true); | 7936 animated->SetDrawsContent(true); |
| 7932 surface->SetDrawsContent(true); | 7937 surface->SetDrawsContent(true); |
| 7933 descendant_of_animation->SetDrawsContent(true); | 7938 descendant_of_animation->SetDrawsContent(true); |
| 7934 | 7939 |
| 7935 gfx::Transform uninvertible_matrix; | 7940 gfx::Transform uninvertible_matrix; |
| 7936 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); | 7941 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); |
| 7937 | 7942 |
| 7938 root->SetBounds(gfx::Size(100, 100)); | 7943 root->SetBounds(gfx::Size(100, 100)); |
| 7939 clip->SetBounds(gfx::Size(10, 10)); | 7944 clip->SetBounds(gfx::Size(10, 10)); |
| 7940 clip->SetMasksToBounds(true); | 7945 clip->SetMasksToBounds(true); |
| 7941 animated->SetTransform(uninvertible_matrix); | 7946 animated->test_properties()->transform = uninvertible_matrix; |
| 7942 animated->SetBounds(gfx::Size(120, 120)); | 7947 animated->SetBounds(gfx::Size(120, 120)); |
| 7943 surface->SetBounds(gfx::Size(100, 100)); | 7948 surface->SetBounds(gfx::Size(100, 100)); |
| 7944 surface->test_properties()->force_render_surface = true; | 7949 surface->test_properties()->force_render_surface = true; |
| 7945 descendant_of_animation->SetBounds(gfx::Size(200, 200)); | 7950 descendant_of_animation->SetBounds(gfx::Size(200, 200)); |
| 7946 | 7951 |
| 7947 TransformOperations start_transform_operations; | 7952 TransformOperations start_transform_operations; |
| 7948 start_transform_operations.AppendMatrix(uninvertible_matrix); | 7953 start_transform_operations.AppendMatrix(uninvertible_matrix); |
| 7949 TransformOperations end_transform_operations; | 7954 TransformOperations end_transform_operations; |
| 7950 | 7955 |
| 7951 AddAnimatedTransformToElementWithPlayer( | 7956 AddAnimatedTransformToElementWithPlayer( |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8216 | 8221 |
| 8217 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) { | 8222 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) { |
| 8218 LayerImpl* root = root_layer_for_testing(); | 8223 LayerImpl* root = root_layer_for_testing(); |
| 8219 LayerImpl* child = AddChild<LayerImpl>(root); | 8224 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8220 | 8225 |
| 8221 gfx::Transform scale_matrix; | 8226 gfx::Transform scale_matrix; |
| 8222 scale_matrix.Scale(2.f, 2.f); | 8227 scale_matrix.Scale(2.f, 2.f); |
| 8223 | 8228 |
| 8224 root->SetBounds(gfx::Size(100, 100)); | 8229 root->SetBounds(gfx::Size(100, 100)); |
| 8225 root->SetDrawsContent(true); | 8230 root->SetDrawsContent(true); |
| 8226 child->SetTransform(scale_matrix); | 8231 child->test_properties()->transform = scale_matrix; |
| 8227 child->SetBounds(gfx::Size(10, 10)); | 8232 child->SetBounds(gfx::Size(10, 10)); |
| 8228 child->SetDrawsContent(true); | 8233 child->SetDrawsContent(true); |
| 8229 | 8234 |
| 8230 ExecuteCalculateDrawProperties(root); | 8235 ExecuteCalculateDrawProperties(root); |
| 8231 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 8236 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 8232 | 8237 |
| 8233 child->test_properties()->transform_origin = gfx::Point3F(10.f, 10.f, 10.f); | 8238 child->test_properties()->transform_origin = gfx::Point3F(10.f, 10.f, 10.f); |
| 8234 | 8239 |
| 8235 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8240 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8236 ExecuteCalculateDrawProperties(root); | 8241 ExecuteCalculateDrawProperties(root); |
| 8237 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_layer_rect()); | 8242 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_layer_rect()); |
| 8238 } | 8243 } |
| 8239 | 8244 |
| 8240 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) { | 8245 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) { |
| 8241 LayerImpl* root = root_layer_for_testing(); | 8246 LayerImpl* root = root_layer_for_testing(); |
| 8242 LayerImpl* scroll_parent = AddChild<LayerImpl>(root); | 8247 LayerImpl* scroll_parent = AddChild<LayerImpl>(root); |
| 8243 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_parent); | 8248 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_parent); |
| 8244 | 8249 |
| 8245 gfx::Transform scale; | 8250 gfx::Transform scale; |
| 8246 scale.Scale(2.f, 2.f); | 8251 scale.Scale(2.f, 2.f); |
| 8247 | 8252 |
| 8248 root->SetBounds(gfx::Size(50, 50)); | 8253 root->SetBounds(gfx::Size(50, 50)); |
| 8249 scroll_child->SetTransform(scale); | 8254 scroll_child->test_properties()->transform = scale; |
| 8250 scroll_child->SetBounds(gfx::Size(40, 40)); | 8255 scroll_child->SetBounds(gfx::Size(40, 40)); |
| 8251 scroll_child->SetDrawsContent(true); | 8256 scroll_child->SetDrawsContent(true); |
| 8252 scroll_parent->SetBounds(gfx::Size(30, 30)); | 8257 scroll_parent->SetBounds(gfx::Size(30, 30)); |
| 8253 scroll_parent->SetDrawsContent(true); | 8258 scroll_parent->SetDrawsContent(true); |
| 8254 | 8259 |
| 8255 scroll_child->test_properties()->scroll_parent = scroll_parent; | 8260 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 8256 scroll_parent->test_properties()->scroll_children = | 8261 scroll_parent->test_properties()->scroll_children = |
| 8257 base::MakeUnique<std::set<LayerImpl*>>(); | 8262 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8258 scroll_parent->test_properties()->scroll_children->insert(scroll_child); | 8263 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 8259 | 8264 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8448 // different. | 8453 // different. |
| 8449 singular.matrix().set(0, 1, 1); | 8454 singular.matrix().set(0, 1, 1); |
| 8450 | 8455 |
| 8451 gfx::Transform rotate; | 8456 gfx::Transform rotate; |
| 8452 rotate.Rotate(90); | 8457 rotate.Rotate(90); |
| 8453 | 8458 |
| 8454 gfx::Transform rotate_back_and_translate; | 8459 gfx::Transform rotate_back_and_translate; |
| 8455 rotate_back_and_translate.RotateAboutYAxis(180); | 8460 rotate_back_and_translate.RotateAboutYAxis(180); |
| 8456 rotate_back_and_translate.Translate(-10, 0); | 8461 rotate_back_and_translate.Translate(-10, 0); |
| 8457 | 8462 |
| 8458 child_ptr->SetTransform(singular); | 8463 child_ptr->test_properties()->transform = singular; |
| 8459 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8464 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8460 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8465 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8461 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8466 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8462 child_ptr->SetTransform(gfx::Transform()); | 8467 child_ptr->test_properties()->transform = gfx::Transform(); |
| 8463 | 8468 |
| 8464 child_ptr->test_properties()->hide_layer_and_subtree = true; | 8469 child_ptr->test_properties()->hide_layer_and_subtree = true; |
| 8465 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8470 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8466 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8471 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8467 child_ptr->test_properties()->hide_layer_and_subtree = false; | 8472 child_ptr->test_properties()->hide_layer_and_subtree = false; |
| 8468 | 8473 |
| 8469 child_ptr->OnOpacityAnimated(0.f); | 8474 child_ptr->OnOpacityAnimated(0.f); |
| 8470 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8475 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8471 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8476 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8472 child_ptr->test_properties()->opacity = 1.f; | 8477 child_ptr->test_properties()->opacity = 1.f; |
| 8473 | 8478 |
| 8474 root_ptr->SetTransform(singular); | 8479 root_ptr->test_properties()->transform = singular; |
| 8475 // Force transform tree to have a node for child, so that ancestor's | 8480 // Force transform tree to have a node for child, so that ancestor's |
| 8476 // invertible transform can be tested. | 8481 // invertible transform can be tested. |
| 8477 child_ptr->SetTransform(rotate); | 8482 child_ptr->test_properties()->transform = rotate; |
| 8478 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8483 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8479 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8484 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8480 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8485 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8481 root_ptr->SetTransform(gfx::Transform()); | 8486 root_ptr->test_properties()->transform = gfx::Transform(); |
| 8482 child_ptr->SetTransform(gfx::Transform()); | 8487 child_ptr->test_properties()->transform = gfx::Transform(); |
| 8483 | 8488 |
| 8484 root_ptr->test_properties()->opacity = 0.f; | 8489 root_ptr->test_properties()->opacity = 0.f; |
| 8485 child_ptr->test_properties()->opacity = 0.7f; | 8490 child_ptr->test_properties()->opacity = 0.7f; |
| 8486 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8491 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8487 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8492 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8488 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8493 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8489 root_ptr->test_properties()->opacity = 1.f; | 8494 root_ptr->test_properties()->opacity = 1.f; |
| 8490 | 8495 |
| 8491 child_ptr->test_properties()->opacity = 0.f; | 8496 child_ptr->test_properties()->opacity = 0.f; |
| 8492 // Now, even though child has zero opacity, we will configure |grandchild| and | 8497 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8493 // |greatgrandchild| in several ways that should force the subtree to be | 8498 // |greatgrandchild| in several ways that should force the subtree to be |
| 8494 // processed anyhow. | 8499 // processed anyhow. |
| 8495 grandchild_ptr->test_properties()->copy_requests.push_back( | 8500 grandchild_ptr->test_properties()->copy_requests.push_back( |
| 8496 CopyOutputRequest::CreateEmptyRequest()); | 8501 CopyOutputRequest::CreateEmptyRequest()); |
| 8497 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8502 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8498 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8503 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8499 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8504 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8500 | 8505 |
| 8501 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); | 8506 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); |
| 8502 child_ptr->test_properties()->opacity = 1.f; | 8507 child_ptr->test_properties()->opacity = 1.f; |
| 8503 | 8508 |
| 8504 // A double sided render surface with backface visible should not be skipped | 8509 // A double sided render surface with backface visible should not be skipped |
| 8505 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8510 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8506 child_ptr->SetHasRenderSurface(true); | 8511 child_ptr->SetHasRenderSurface(true); |
| 8507 child_ptr->test_properties()->double_sided = true; | 8512 child_ptr->test_properties()->double_sided = true; |
| 8508 child_ptr->SetTransform(rotate_back_and_translate); | 8513 child_ptr->test_properties()->transform = rotate_back_and_translate; |
| 8509 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8514 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8510 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8515 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8511 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8516 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8512 child_ptr->SetTransform(gfx::Transform()); | 8517 child_ptr->test_properties()->transform = gfx::Transform(); |
| 8513 | 8518 |
| 8514 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 8519 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 8515 KeyframedTransformAnimationCurve::Create()); | 8520 KeyframedTransformAnimationCurve::Create()); |
| 8516 TransformOperations start; | 8521 TransformOperations start; |
| 8517 start.AppendTranslate(1.f, 2.f, 3.f); | 8522 start.AppendTranslate(1.f, 2.f, 3.f); |
| 8518 gfx::Transform transform; | 8523 gfx::Transform transform; |
| 8519 transform.Scale3d(1.0, 2.0, 3.0); | 8524 transform.Scale3d(1.0, 2.0, 3.0); |
| 8520 TransformOperations operation; | 8525 TransformOperations operation; |
| 8521 operation.AppendMatrix(transform); | 8526 operation.AppendMatrix(transform); |
| 8522 curve->AddKeyframe( | 8527 curve->AddKeyframe( |
| 8523 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8528 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 8524 curve->AddKeyframe(TransformKeyframe::Create( | 8529 curve->AddKeyframe(TransformKeyframe::Create( |
| 8525 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8530 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 8526 std::unique_ptr<Animation> transform_animation( | 8531 std::unique_ptr<Animation> transform_animation( |
| 8527 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8532 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 8528 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8533 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
| 8529 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( | 8534 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
| 8530 root_ptr->element_id(), player.get()); | 8535 root_ptr->element_id(), player.get()); |
| 8531 host_impl.active_tree() | 8536 host_impl.active_tree() |
| 8532 ->animation_host() | 8537 ->animation_host() |
| 8533 ->GetElementAnimationsForElementId(root_ptr->element_id()) | 8538 ->GetElementAnimationsForElementId(root_ptr->element_id()) |
| 8534 ->AddAnimation(std::move(transform_animation)); | 8539 ->AddAnimation(std::move(transform_animation)); |
| 8535 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8540 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8536 child_ptr->SetScrollClipLayer(root_ptr->id()); | 8541 child_ptr->SetScrollClipLayer(root_ptr->id()); |
| 8537 root_ptr->SetTransform(singular); | 8542 root_ptr->test_properties()->transform = singular; |
| 8538 child_ptr->SetTransform(singular); | 8543 child_ptr->test_properties()->transform = singular; |
| 8539 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8544 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8540 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8545 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8541 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8546 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8542 | 8547 |
| 8543 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8548 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8544 root_ptr->element_id(), player.get()); | 8549 root_ptr->element_id(), player.get()); |
| 8545 } | 8550 } |
| 8546 | 8551 |
| 8547 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 8552 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
| 8548 LayerImpl* root = root_layer_for_testing(); | 8553 LayerImpl* root = root_layer_for_testing(); |
| 8549 LayerImpl* child = AddChild<LayerImpl>(root); | 8554 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8550 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 8555 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 8551 | 8556 |
| 8552 SetElementIdsForTesting(); | 8557 SetElementIdsForTesting(); |
| 8553 | 8558 |
| 8554 gfx::Transform singular; | 8559 gfx::Transform singular; |
| 8555 singular.matrix().set(0, 0, 0); | 8560 singular.matrix().set(0, 0, 0); |
| 8556 singular.matrix().set(0, 1, 1); | 8561 singular.matrix().set(0, 1, 1); |
| 8557 | 8562 |
| 8558 root->SetBounds(gfx::Size(10, 10)); | 8563 root->SetBounds(gfx::Size(10, 10)); |
| 8559 child->SetTransform(singular); | 8564 child->test_properties()->transform = singular; |
| 8560 child->SetBounds(gfx::Size(10, 10)); | 8565 child->SetBounds(gfx::Size(10, 10)); |
| 8561 child->SetDrawsContent(true); | 8566 child->SetDrawsContent(true); |
| 8562 grand_child->SetBounds(gfx::Size(10, 10)); | 8567 grand_child->SetBounds(gfx::Size(10, 10)); |
| 8563 grand_child->SetDrawsContent(true); | 8568 grand_child->SetDrawsContent(true); |
| 8564 | 8569 |
| 8565 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 8570 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 8566 KeyframedTransformAnimationCurve::Create()); | 8571 KeyframedTransformAnimationCurve::Create()); |
| 8567 TransformOperations start; | 8572 TransformOperations start; |
| 8568 start.AppendTranslate(1.f, 2.f, 3.f); | 8573 start.AppendTranslate(1.f, 2.f, 3.f); |
| 8569 gfx::Transform transform; | 8574 gfx::Transform transform; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8679 | 8684 |
| 8680 child->SetBounds(gfx::Size()); | 8685 child->SetBounds(gfx::Size()); |
| 8681 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8686 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8682 ExecuteCalculateDrawProperties(root); | 8687 ExecuteCalculateDrawProperties(root); |
| 8683 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8688 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8684 child->SetBounds(gfx::Size(10, 10)); | 8689 child->SetBounds(gfx::Size(10, 10)); |
| 8685 | 8690 |
| 8686 gfx::Transform rotate; | 8691 gfx::Transform rotate; |
| 8687 child->test_properties()->double_sided = false; | 8692 child->test_properties()->double_sided = false; |
| 8688 rotate.RotateAboutXAxis(180.f); | 8693 rotate.RotateAboutXAxis(180.f); |
| 8689 child->SetTransform(rotate); | 8694 child->test_properties()->transform = rotate; |
| 8690 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8695 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8691 ExecuteCalculateDrawProperties(root); | 8696 ExecuteCalculateDrawProperties(root); |
| 8692 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8697 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8693 child->test_properties()->double_sided = true; | 8698 child->test_properties()->double_sided = true; |
| 8694 child->SetTransform(gfx::Transform()); | 8699 child->test_properties()->transform = gfx::Transform(); |
| 8695 | 8700 |
| 8696 child->test_properties()->opacity = 0.f; | 8701 child->test_properties()->opacity = 0.f; |
| 8697 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8702 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8698 ExecuteCalculateDrawProperties(root); | 8703 ExecuteCalculateDrawProperties(root); |
| 8699 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8704 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8700 } | 8705 } |
| 8701 | 8706 |
| 8702 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { | 8707 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { |
| 8703 // Ensure that the treewalk in LayerTreeHostCommom:: | 8708 // Ensure that the treewalk in LayerTreeHostCommom:: |
| 8704 // PreCalculateMetaInformation happens when its required. | 8709 // PreCalculateMetaInformation happens when its required. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8762 // formed for it. | 8767 // formed for it. |
| 8763 gfx::Transform transform1; | 8768 gfx::Transform transform1; |
| 8764 transform1.RotateAboutYAxis(45); | 8769 transform1.RotateAboutYAxis(45); |
| 8765 transform1.RotateAboutXAxis(30); | 8770 transform1.RotateAboutXAxis(30); |
| 8766 // This transform should be a 3d transform as we want the render surface | 8771 // This transform should be a 3d transform as we want the render surface |
| 8767 // to flatten the transform | 8772 // to flatten the transform |
| 8768 gfx::Transform transform2; | 8773 gfx::Transform transform2; |
| 8769 transform2.Translate3d(10, 10, 10); | 8774 transform2.Translate3d(10, 10, 10); |
| 8770 | 8775 |
| 8771 root->SetBounds(gfx::Size(30, 30)); | 8776 root->SetBounds(gfx::Size(30, 30)); |
| 8772 significant_transform->SetTransform(transform1); | 8777 significant_transform->test_properties()->transform = transform1; |
| 8773 significant_transform->SetBounds(gfx::Size(30, 30)); | 8778 significant_transform->SetBounds(gfx::Size(30, 30)); |
| 8774 layer_clips_subtree->SetBounds(gfx::Size(30, 30)); | 8779 layer_clips_subtree->SetBounds(gfx::Size(30, 30)); |
| 8775 layer_clips_subtree->SetMasksToBounds(true); | 8780 layer_clips_subtree->SetMasksToBounds(true); |
| 8776 layer_clips_subtree->test_properties()->force_render_surface = true; | 8781 layer_clips_subtree->test_properties()->force_render_surface = true; |
| 8777 render_surface->SetTransform(transform2); | 8782 render_surface->test_properties()->transform = transform2; |
| 8778 render_surface->SetBounds(gfx::Size(30, 30)); | 8783 render_surface->SetBounds(gfx::Size(30, 30)); |
| 8779 render_surface->test_properties()->force_render_surface = true; | 8784 render_surface->test_properties()->force_render_surface = true; |
| 8780 test_layer->SetBounds(gfx::Size(30, 30)); | 8785 test_layer->SetBounds(gfx::Size(30, 30)); |
| 8781 test_layer->SetDrawsContent(true); | 8786 test_layer->SetDrawsContent(true); |
| 8782 | 8787 |
| 8783 ExecuteCalculateDrawProperties(root); | 8788 ExecuteCalculateDrawProperties(root); |
| 8784 | 8789 |
| 8785 TransformTree& transform_tree = | 8790 TransformTree& transform_tree = |
| 8786 root->layer_tree_impl()->property_trees()->transform_tree; | 8791 root->layer_tree_impl()->property_trees()->transform_tree; |
| 8787 TransformNode* transform_node = | 8792 TransformNode* transform_node = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 8806 // target space and visible rects are calculated correctly. | 8811 // target space and visible rects are calculated correctly. |
| 8807 LayerImpl* root = root_layer_for_testing(); | 8812 LayerImpl* root = root_layer_for_testing(); |
| 8808 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 8813 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 8809 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); | 8814 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); |
| 8810 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); | 8815 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); |
| 8811 | 8816 |
| 8812 gfx::Transform transform; | 8817 gfx::Transform transform; |
| 8813 transform.RotateAboutYAxis(45); | 8818 transform.RotateAboutYAxis(45); |
| 8814 | 8819 |
| 8815 root->SetBounds(gfx::Size(30, 30)); | 8820 root->SetBounds(gfx::Size(30, 30)); |
| 8816 clip_layer->SetTransform(transform); | 8821 clip_layer->test_properties()->transform = transform; |
| 8817 clip_layer->SetBounds(gfx::Size(30, 30)); | 8822 clip_layer->SetBounds(gfx::Size(30, 30)); |
| 8818 clip_layer->SetMasksToBounds(true); | 8823 clip_layer->SetMasksToBounds(true); |
| 8819 target_layer->SetTransform(transform); | 8824 target_layer->test_properties()->transform = transform; |
| 8820 target_layer->SetBounds(gfx::Size(30, 30)); | 8825 target_layer->SetBounds(gfx::Size(30, 30)); |
| 8821 target_layer->SetMasksToBounds(true); | 8826 target_layer->SetMasksToBounds(true); |
| 8822 test_layer->SetBounds(gfx::Size(30, 30)); | 8827 test_layer->SetBounds(gfx::Size(30, 30)); |
| 8823 test_layer->SetDrawsContent(true); | 8828 test_layer->SetDrawsContent(true); |
| 8824 | 8829 |
| 8825 ExecuteCalculateDrawProperties(root); | 8830 ExecuteCalculateDrawProperties(root); |
| 8826 | 8831 |
| 8827 EXPECT_EQ(gfx::Rect(30, 30), test_layer->visible_layer_rect()); | 8832 EXPECT_EQ(gfx::Rect(30, 30), test_layer->visible_layer_rect()); |
| 8828 } | 8833 } |
| 8829 | 8834 |
| 8830 TEST_F(LayerTreeHostCommonTest, | 8835 TEST_F(LayerTreeHostCommonTest, |
| 8831 RenderSurfaceWithUnclippedDescendantsClipsSubtree) { | 8836 RenderSurfaceWithUnclippedDescendantsClipsSubtree) { |
| 8832 // Ensure clip rect is calculated correctly when render surface has unclipped | 8837 // Ensure clip rect is calculated correctly when render surface has unclipped |
| 8833 // descendants. | 8838 // descendants. |
| 8834 LayerImpl* root = root_layer_for_testing(); | 8839 LayerImpl* root = root_layer_for_testing(); |
| 8835 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 8840 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 8836 LayerImpl* between_clip_parent_and_child = AddChild<LayerImpl>(clip_parent); | 8841 LayerImpl* between_clip_parent_and_child = AddChild<LayerImpl>(clip_parent); |
| 8837 LayerImpl* render_surface = | 8842 LayerImpl* render_surface = |
| 8838 AddChild<LayerImpl>(between_clip_parent_and_child); | 8843 AddChild<LayerImpl>(between_clip_parent_and_child); |
| 8839 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 8844 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 8840 | 8845 |
| 8841 gfx::Transform translate; | 8846 gfx::Transform translate; |
| 8842 translate.Translate(2.0, 2.0); | 8847 translate.Translate(2.0, 2.0); |
| 8843 | 8848 |
| 8844 root->SetBounds(gfx::Size(30, 30)); | 8849 root->SetBounds(gfx::Size(30, 30)); |
| 8845 clip_parent->SetTransform(translate); | 8850 clip_parent->test_properties()->transform = translate; |
| 8846 clip_parent->SetBounds(gfx::Size(30, 30)); | 8851 clip_parent->SetBounds(gfx::Size(30, 30)); |
| 8847 clip_parent->SetMasksToBounds(true); | 8852 clip_parent->SetMasksToBounds(true); |
| 8848 between_clip_parent_and_child->SetTransform(translate); | 8853 between_clip_parent_and_child->test_properties()->transform = translate; |
| 8849 between_clip_parent_and_child->SetBounds(gfx::Size(30, 30)); | 8854 between_clip_parent_and_child->SetBounds(gfx::Size(30, 30)); |
| 8850 render_surface->SetBounds(gfx::Size(30, 30)); | 8855 render_surface->SetBounds(gfx::Size(30, 30)); |
| 8851 render_surface->test_properties()->force_render_surface = true; | 8856 render_surface->test_properties()->force_render_surface = true; |
| 8852 test_layer->SetBounds(gfx::Size(30, 30)); | 8857 test_layer->SetBounds(gfx::Size(30, 30)); |
| 8853 test_layer->SetDrawsContent(true); | 8858 test_layer->SetDrawsContent(true); |
| 8854 | 8859 |
| 8855 render_surface->test_properties()->clip_parent = clip_parent; | 8860 render_surface->test_properties()->clip_parent = clip_parent; |
| 8856 clip_parent->test_properties()->clip_children = | 8861 clip_parent->test_properties()->clip_children = |
| 8857 base::MakeUnique<std::set<LayerImpl*>>(); | 8862 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8858 clip_parent->test_properties()->clip_children->insert(render_surface); | 8863 clip_parent->test_properties()->clip_children->insert(render_surface); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9020 gfx::Transform translate; | 9025 gfx::Transform translate; |
| 9021 translate.Translate(10, 10); | 9026 translate.Translate(10, 10); |
| 9022 | 9027 |
| 9023 gfx::Transform rotate; | 9028 gfx::Transform rotate; |
| 9024 rotate.RotateAboutXAxis(10); | 9029 rotate.RotateAboutXAxis(10); |
| 9025 | 9030 |
| 9026 root->SetBounds(gfx::Size(100, 100)); | 9031 root->SetBounds(gfx::Size(100, 100)); |
| 9027 surface->SetBounds(gfx::Size(100, 100)); | 9032 surface->SetBounds(gfx::Size(100, 100)); |
| 9028 surface->SetMasksToBounds(true); | 9033 surface->SetMasksToBounds(true); |
| 9029 surface->test_properties()->force_render_surface = true; | 9034 surface->test_properties()->force_render_surface = true; |
| 9030 surface->SetTransform(rotate); | 9035 surface->test_properties()->transform = rotate; |
| 9031 clip_layer->SetBounds(gfx::Size(20, 20)); | 9036 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 9032 clip_layer->SetMasksToBounds(true); | 9037 clip_layer->SetMasksToBounds(true); |
| 9033 clip_parent->SetBounds(gfx::Size(50, 50)); | 9038 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 9034 unclipped_desc_surface->SetTransform(translate); | 9039 unclipped_desc_surface->test_properties()->transform = translate; |
| 9035 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | 9040 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 9036 unclipped_desc_surface->SetDrawsContent(true); | 9041 unclipped_desc_surface->SetDrawsContent(true); |
| 9037 unclipped_desc_surface->test_properties()->force_render_surface = true; | 9042 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 9038 clip_child->SetBounds(gfx::Size(100, 100)); | 9043 clip_child->SetBounds(gfx::Size(100, 100)); |
| 9039 clip_child->SetDrawsContent(true); | 9044 clip_child->SetDrawsContent(true); |
| 9040 | 9045 |
| 9041 clip_child->test_properties()->clip_parent = clip_parent; | 9046 clip_child->test_properties()->clip_parent = clip_parent; |
| 9042 clip_parent->test_properties()->clip_children = | 9047 clip_parent->test_properties()->clip_children = |
| 9043 base::MakeUnique<std::set<LayerImpl*>>(); | 9048 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9044 clip_parent->test_properties()->clip_children->insert(clip_child); | 9049 clip_parent->test_properties()->clip_children->insert(clip_child); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9055 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); | 9060 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); |
| 9056 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | 9061 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 9057 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 9062 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| 9058 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | 9063 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); |
| 9059 | 9064 |
| 9060 | 9065 |
| 9061 gfx::Transform scale; | 9066 gfx::Transform scale; |
| 9062 scale.Scale(2, 2); | 9067 scale.Scale(2, 2); |
| 9063 | 9068 |
| 9064 root->SetBounds(gfx::Size(100, 100)); | 9069 root->SetBounds(gfx::Size(100, 100)); |
| 9065 surface->SetTransform(scale); | 9070 surface->test_properties()->transform = scale; |
| 9066 surface->SetBounds(gfx::Size(100, 100)); | 9071 surface->SetBounds(gfx::Size(100, 100)); |
| 9067 surface->SetMasksToBounds(true); | 9072 surface->SetMasksToBounds(true); |
| 9068 surface->test_properties()->force_render_surface = true; | 9073 surface->test_properties()->force_render_surface = true; |
| 9069 clip_layer->SetBounds(gfx::Size(20, 20)); | 9074 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 9070 clip_layer->SetMasksToBounds(true); | 9075 clip_layer->SetMasksToBounds(true); |
| 9071 clip_parent->SetBounds(gfx::Size(50, 50)); | 9076 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 9072 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | 9077 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 9073 unclipped_desc_surface->SetDrawsContent(true); | 9078 unclipped_desc_surface->SetDrawsContent(true); |
| 9074 unclipped_desc_surface->test_properties()->force_render_surface = true; | 9079 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 9075 clip_child->SetBounds(gfx::Size(100, 100)); | 9080 clip_child->SetBounds(gfx::Size(100, 100)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9090 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 9095 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 9091 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 9096 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 9092 | 9097 |
| 9093 gfx::Transform translation; | 9098 gfx::Transform translation; |
| 9094 translation.Translate(10, 10); | 9099 translation.Translate(10, 10); |
| 9095 | 9100 |
| 9096 root->SetBounds(gfx::Size(30, 30)); | 9101 root->SetBounds(gfx::Size(30, 30)); |
| 9097 render_surface->SetBounds(gfx::Size(30, 30)); | 9102 render_surface->SetBounds(gfx::Size(30, 30)); |
| 9098 render_surface->SetMasksToBounds(true); | 9103 render_surface->SetMasksToBounds(true); |
| 9099 render_surface->test_properties()->force_render_surface = true; | 9104 render_surface->test_properties()->force_render_surface = true; |
| 9100 test_layer->SetTransform(translation); | 9105 test_layer->test_properties()->transform = translation; |
| 9101 test_layer->SetBounds(gfx::Size(20, 20)); | 9106 test_layer->SetBounds(gfx::Size(20, 20)); |
| 9102 test_layer->SetDrawsContent(true); | 9107 test_layer->SetDrawsContent(true); |
| 9103 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); | 9108 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); |
| 9104 test_layer->test_properties()->opacity = 0.f; | 9109 test_layer->test_properties()->opacity = 0.f; |
| 9105 | 9110 |
| 9106 ExecuteCalculateDrawProperties(root); | 9111 ExecuteCalculateDrawProperties(root); |
| 9107 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, | 9112 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, |
| 9108 test_layer->ScreenSpaceTransform()); | 9113 test_layer->ScreenSpaceTransform()); |
| 9109 } | 9114 } |
| 9110 | 9115 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9214 LayerImpl* child = AddChild<LayerImpl>(root); | 9219 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9215 child->test_properties()->SetMaskLayer( | 9220 child->test_properties()->SetMaskLayer( |
| 9216 LayerImpl::Create(root->layer_tree_impl(), 100)); | 9221 LayerImpl::Create(root->layer_tree_impl(), 100)); |
| 9217 LayerImpl* mask = child->test_properties()->mask_layer; | 9222 LayerImpl* mask = child->test_properties()->mask_layer; |
| 9218 | 9223 |
| 9219 gfx::Transform transform; | 9224 gfx::Transform transform; |
| 9220 transform.Translate(10, 10); | 9225 transform.Translate(10, 10); |
| 9221 | 9226 |
| 9222 root->SetBounds(gfx::Size(40, 40)); | 9227 root->SetBounds(gfx::Size(40, 40)); |
| 9223 root->SetDrawsContent(true); | 9228 root->SetDrawsContent(true); |
| 9224 child->SetTransform(transform); | 9229 child->test_properties()->transform = transform; |
| 9225 child->SetBounds(gfx::Size(30, 30)); | 9230 child->SetBounds(gfx::Size(30, 30)); |
| 9226 child->SetDrawsContent(false); | 9231 child->SetDrawsContent(false); |
| 9227 mask->SetBounds(gfx::Size(20, 20)); | 9232 mask->SetBounds(gfx::Size(20, 20)); |
| 9228 ExecuteCalculateDrawProperties(root); | 9233 ExecuteCalculateDrawProperties(root); |
| 9229 | 9234 |
| 9230 // The render surface created for the mask has no contributing content, so the | 9235 // The render surface created for the mask has no contributing content, so the |
| 9231 // mask isn't a drawn RSLL member. This means it has an empty visible rect, | 9236 // mask isn't a drawn RSLL member. This means it has an empty visible rect, |
| 9232 // but its screen space transform can still be computed correctly on-demand. | 9237 // but its screen space transform can still be computed correctly on-demand. |
| 9233 EXPECT_FALSE(mask->is_drawn_render_surface_layer_list_member()); | 9238 EXPECT_FALSE(mask->is_drawn_render_surface_layer_list_member()); |
| 9234 EXPECT_EQ(gfx::Rect(), mask->visible_layer_rect()); | 9239 EXPECT_EQ(gfx::Rect(), mask->visible_layer_rect()); |
| 9235 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 9240 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 9236 | 9241 |
| 9237 // Make the child's render surface have contributing content. | 9242 // Make the child's render surface have contributing content. |
| 9238 child->SetDrawsContent(true); | 9243 child->SetDrawsContent(true); |
| 9239 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9244 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9240 ExecuteCalculateDrawProperties(root); | 9245 ExecuteCalculateDrawProperties(root); |
| 9241 EXPECT_TRUE(mask->is_drawn_render_surface_layer_list_member()); | 9246 EXPECT_TRUE(mask->is_drawn_render_surface_layer_list_member()); |
| 9242 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); | 9247 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); |
| 9243 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 9248 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 9244 | 9249 |
| 9245 transform.Translate(10, 10); | 9250 transform.Translate(10, 10); |
| 9246 child->SetTransform(transform); | 9251 child->test_properties()->transform = transform; |
| 9247 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9252 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9248 ExecuteCalculateDrawProperties(root); | 9253 ExecuteCalculateDrawProperties(root); |
| 9249 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 9254 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 9250 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); | 9255 EXPECT_EQ(gfx::Rect(20, 20), mask->visible_layer_rect()); |
| 9251 } | 9256 } |
| 9252 | 9257 |
| 9253 TEST_F(LayerTreeHostCommonTest, ReplicaMaskLayerDrawProperties) { | 9258 TEST_F(LayerTreeHostCommonTest, ReplicaMaskLayerDrawProperties) { |
| 9254 // Tests that a replica mask layer's draw properties are computed correctly. | 9259 // Tests that a replica mask layer's draw properties are computed correctly. |
| 9255 LayerImpl* root = root_layer_for_testing(); | 9260 LayerImpl* root = root_layer_for_testing(); |
| 9256 LayerImpl* child = AddChild<LayerImpl>(root); | 9261 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9257 child->test_properties()->SetReplicaLayer( | 9262 child->test_properties()->SetReplicaLayer( |
| 9258 LayerImpl::Create(root->layer_tree_impl(), 100)); | 9263 LayerImpl::Create(root->layer_tree_impl(), 100)); |
| 9259 LayerImpl* replica = child->test_properties()->replica_layer; | 9264 LayerImpl* replica = child->test_properties()->replica_layer; |
| 9260 replica->test_properties()->parent = child; | 9265 replica->test_properties()->parent = child; |
| 9261 replica->test_properties()->SetMaskLayer( | 9266 replica->test_properties()->SetMaskLayer( |
| 9262 LayerImpl::Create(root->layer_tree_impl(), 200)); | 9267 LayerImpl::Create(root->layer_tree_impl(), 200)); |
| 9263 LayerImpl* replica_mask = replica->test_properties()->mask_layer; | 9268 LayerImpl* replica_mask = replica->test_properties()->mask_layer; |
| 9264 | 9269 |
| 9265 gfx::Transform transform; | 9270 gfx::Transform transform; |
| 9266 transform.Translate(10, 10); | 9271 transform.Translate(10, 10); |
| 9267 | 9272 |
| 9268 gfx::PointF replica_position(3.f, 3.f); | 9273 gfx::PointF replica_position(3.f, 3.f); |
| 9269 | 9274 |
| 9270 root->SetBounds(gfx::Size(40, 40)); | 9275 root->SetBounds(gfx::Size(40, 40)); |
| 9271 root->SetDrawsContent(true); | 9276 root->SetDrawsContent(true); |
| 9272 child->SetTransform(transform); | 9277 child->test_properties()->transform = transform; |
| 9273 child->SetBounds(gfx::Size(30, 30)); | 9278 child->SetBounds(gfx::Size(30, 30)); |
| 9274 replica->SetPosition(replica_position); | 9279 replica->SetPosition(replica_position); |
| 9275 replica_mask->SetBounds(gfx::Size(20, 20)); | 9280 replica_mask->SetBounds(gfx::Size(20, 20)); |
| 9276 | 9281 |
| 9277 ExecuteCalculateDrawProperties(root); | 9282 ExecuteCalculateDrawProperties(root); |
| 9278 | 9283 |
| 9279 // The render surface created for the replica has no contributing content, so | 9284 // The render surface created for the replica has no contributing content, so |
| 9280 // the replica's mask isn't a drawn RSLL member. This means it has an empty | 9285 // the replica's mask isn't a drawn RSLL member. This means it has an empty |
| 9281 // visible rect, but its screen space transform can still be computed | 9286 // visible rect, but its screen space transform can still be computed |
| 9282 // correctly on-demand. | 9287 // correctly on-demand. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 9305 LayerImpl* root = root_layer_for_testing(); | 9310 LayerImpl* root = root_layer_for_testing(); |
| 9306 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9311 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9307 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); | 9312 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); |
| 9308 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); | 9313 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); |
| 9309 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); | 9314 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); |
| 9310 | 9315 |
| 9311 gfx::Transform scale; | 9316 gfx::Transform scale; |
| 9312 scale.Scale(2.f, 2.f); | 9317 scale.Scale(2.f, 2.f); |
| 9313 | 9318 |
| 9314 root->SetBounds(gfx::Size(30, 30)); | 9319 root->SetBounds(gfx::Size(30, 30)); |
| 9315 render_surface1->SetTransform(scale); | 9320 render_surface1->test_properties()->transform = scale; |
| 9316 render_surface1->SetBounds(gfx::Size(30, 30)); | 9321 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 9317 render_surface1->test_properties()->force_render_surface = true; | 9322 render_surface1->test_properties()->force_render_surface = true; |
| 9318 between_targets->SetBounds(gfx::Size(30, 30)); | 9323 between_targets->SetBounds(gfx::Size(30, 30)); |
| 9319 render_surface2->SetBounds(gfx::Size(30, 30)); | 9324 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 9320 render_surface2->test_properties()->force_render_surface = true; | 9325 render_surface2->test_properties()->force_render_surface = true; |
| 9321 test_layer->SetBounds(gfx::Size(30, 30)); | 9326 test_layer->SetBounds(gfx::Size(30, 30)); |
| 9322 test_layer->SetDrawsContent(true); | 9327 test_layer->SetDrawsContent(true); |
| 9323 | 9328 |
| 9324 // We want layer between the two targets to create a clip node and transform | 9329 // We want layer between the two targets to create a clip node and transform |
| 9325 // node but it shouldn't create a render surface. | 9330 // node but it shouldn't create a render surface. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9358 | 9363 |
| 9359 root->SetBounds(gfx::Size(30, 30)); | 9364 root->SetBounds(gfx::Size(30, 30)); |
| 9360 render_surface1->SetBounds(gfx::Size(30, 30)); | 9365 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 9361 render_surface1->test_properties()->force_render_surface = true; | 9366 render_surface1->test_properties()->force_render_surface = true; |
| 9362 | 9367 |
| 9363 // TODO(sunxd): we make child have no render surface, because if the | 9368 // TODO(sunxd): we make child have no render surface, because if the |
| 9364 // child has one, the large transform applied to child will result in NaNs in | 9369 // child has one, the large transform applied to child will result in NaNs in |
| 9365 // the draw_transform of the render_surface, thus make draw property updates | 9370 // the draw_transform of the render_surface, thus make draw property updates |
| 9366 // skip the child layer. We need further investigation into this to know | 9371 // skip the child layer. We need further investigation into this to know |
| 9367 // what exactly happens here. | 9372 // what exactly happens here. |
| 9368 child->SetTransform(large_transform); | 9373 child->test_properties()->transform = large_transform; |
| 9369 child->SetBounds(gfx::Size(30, 30)); | 9374 child->SetBounds(gfx::Size(30, 30)); |
| 9370 | 9375 |
| 9371 ExecuteCalculateDrawProperties(root); | 9376 ExecuteCalculateDrawProperties(root); |
| 9372 | 9377 |
| 9373 EXPECT_EQ(gfx::RectF(), | 9378 EXPECT_EQ(gfx::RectF(), |
| 9374 render_surface1->render_surface()->DrawableContentRect()); | 9379 render_surface1->render_surface()->DrawableContentRect()); |
| 9375 | 9380 |
| 9376 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || | 9381 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || |
| 9377 std::isnan(child->DrawTransform().matrix().get(0, 0)); | 9382 std::isnan(child->DrawTransform().matrix().get(0, 0)); |
| 9378 EXPECT_TRUE(is_inf_or_nan); | 9383 EXPECT_TRUE(is_inf_or_nan); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9760 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9765 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9761 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9766 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9762 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9767 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9763 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9768 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9764 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9769 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9765 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9770 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9766 } | 9771 } |
| 9767 | 9772 |
| 9768 } // namespace | 9773 } // namespace |
| 9769 } // namespace cc | 9774 } // namespace cc |
| OLD | NEW |