| 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 9604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9615 gfx::PointF(), gfx::Size(30, 30), true, false, | 9615 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9616 false); | 9616 false); |
| 9617 ExecuteCalculateDrawProperties(root); | 9617 ExecuteCalculateDrawProperties(root); |
| 9618 | 9618 |
| 9619 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); | 9619 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); |
| 9620 // A clip node is created for every render surface and for layers that have | 9620 // A clip node is created for every render surface and for layers that have |
| 9621 // local clip. So, here it should be craeted for every layer. | 9621 // local clip. So, here it should be craeted for every layer. |
| 9622 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); | 9622 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); |
| 9623 } | 9623 } |
| 9624 | 9624 |
| 9625 TEST_F(LayerTreeHostCommonTest, MaskLayerScreenSpaceTransform) { | 9625 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) { |
| 9626 // Tests that the mask layer gets its owning layer's screen space transform. | 9626 // Tests that a mask layer's draw properties are computed correctly. |
| 9627 LayerImpl* root = root_layer(); | 9627 LayerImpl* root = root_layer(); |
| 9628 LayerImpl* child = AddChild<LayerImpl>(root); | 9628 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9629 child->SetMaskLayer(LayerImpl::Create(root->layer_tree_impl(), 100)); |
| 9629 | 9630 |
| 9630 const gfx::Transform identity_matrix; | 9631 const gfx::Transform identity_matrix; |
| 9631 gfx::Transform transform; | 9632 gfx::Transform transform; |
| 9632 transform.Translate(10, 10); | 9633 transform.Translate(10, 10); |
| 9633 | 9634 |
| 9634 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9635 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9635 gfx::PointF(), gfx::Size(30, 30), true, false, | 9636 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 9636 true); | 9637 true); |
| 9637 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), | 9638 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), |
| 9638 gfx::Size(30, 30), true, false, false); | 9639 gfx::Size(30, 30), true, false, false); |
| 9640 SetLayerPropertiesForTesting(child->mask_layer(), identity_matrix, |
| 9641 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 9642 true, false, false); |
| 9639 root->SetDrawsContent(true); | 9643 root->SetDrawsContent(true); |
| 9640 child->SetDrawsContent(false); | 9644 child->SetDrawsContent(false); |
| 9641 child->SetMaskLayer(LayerImpl::Create(root->layer_tree_impl(), 100)); | |
| 9642 ExecuteCalculateDrawProperties(root); | 9645 ExecuteCalculateDrawProperties(root); |
| 9643 | 9646 |
| 9647 // The render surface created for the mask has no contributing content, so the |
| 9648 // mask isn't a drawn RSLL member. This means it has an empty visible rect, |
| 9649 // but its screen space transform can still be computed correctly on-demand. |
| 9650 EXPECT_FALSE( |
| 9651 child->mask_layer()->is_drawn_render_surface_layer_list_member()); |
| 9652 EXPECT_EQ(gfx::Rect(), child->mask_layer()->visible_layer_rect()); |
| 9644 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9653 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 9645 child->mask_layer()->ScreenSpaceTransform()); | 9654 child->mask_layer()->ScreenSpaceTransform()); |
| 9655 |
| 9656 // Make the child's render surface have contributing content. |
| 9657 child->SetDrawsContent(true); |
| 9658 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9659 ExecuteCalculateDrawProperties(root); |
| 9660 EXPECT_TRUE(child->mask_layer()->is_drawn_render_surface_layer_list_member()); |
| 9661 EXPECT_EQ(gfx::Rect(20, 20), child->mask_layer()->visible_layer_rect()); |
| 9662 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 9663 child->mask_layer()->ScreenSpaceTransform()); |
| 9664 |
| 9646 transform.Translate(10, 10); | 9665 transform.Translate(10, 10); |
| 9647 child->SetTransform(transform); | 9666 child->SetTransform(transform); |
| 9648 child->SetDrawsContent(true); | |
| 9649 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9667 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9650 ExecuteCalculateDrawProperties(root); | 9668 ExecuteCalculateDrawProperties(root); |
| 9651 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 9669 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 9652 child->mask_layer()->ScreenSpaceTransform()); | 9670 child->mask_layer()->ScreenSpaceTransform()); |
| 9671 EXPECT_EQ(gfx::Rect(20, 20), child->mask_layer()->visible_layer_rect()); |
| 9672 } |
| 9673 |
| 9674 TEST_F(LayerTreeHostCommonTest, ReplicaMaskLayerDrawProperties) { |
| 9675 // Tests that a replica mask layer's draw properties are computed correctly. |
| 9676 LayerImpl* root = root_layer(); |
| 9677 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9678 child->SetReplicaLayer(LayerImpl::Create(root->layer_tree_impl(), 100)); |
| 9679 child->replica_layer()->SetParent(child); |
| 9680 child->replica_layer()->SetMaskLayer( |
| 9681 LayerImpl::Create(root->layer_tree_impl(), 200)); |
| 9682 |
| 9683 const gfx::Transform identity_matrix; |
| 9684 gfx::Transform transform; |
| 9685 transform.Translate(10, 10); |
| 9686 |
| 9687 gfx::PointF replica_position(3.f, 3.f); |
| 9688 |
| 9689 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9690 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 9691 true); |
| 9692 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), |
| 9693 gfx::Size(30, 30), true, false, false); |
| 9694 SetLayerPropertiesForTesting(child->replica_layer(), identity_matrix, |
| 9695 gfx::Point3F(), replica_position, |
| 9696 gfx::Size(30, 30), true, false, false); |
| 9697 SetLayerPropertiesForTesting(child->replica_layer()->mask_layer(), |
| 9698 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 9699 gfx::Size(20, 20), true, false, false); |
| 9700 root->SetDrawsContent(true); |
| 9701 child->SetDrawsContent(false); |
| 9702 ExecuteCalculateDrawProperties(root); |
| 9703 |
| 9704 // The render surface created for the replica has no contributing content, so |
| 9705 // the replica's mask isn't a drawn RSLL member. This means it has an empty |
| 9706 // visible rect, but its screen space transform can still be computed |
| 9707 // correctly on-demand. |
| 9708 EXPECT_FALSE(child->replica_layer() |
| 9709 ->mask_layer() |
| 9710 ->is_drawn_render_surface_layer_list_member()); |
| 9711 EXPECT_EQ(gfx::Rect(), |
| 9712 child->replica_layer()->mask_layer()->visible_layer_rect()); |
| 9713 |
| 9714 gfx::Transform expected_screen_space_transform = transform; |
| 9715 expected_screen_space_transform.Translate(replica_position.x(), |
| 9716 replica_position.y()); |
| 9717 |
| 9718 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 9719 expected_screen_space_transform, |
| 9720 child->replica_layer()->mask_layer()->ScreenSpaceTransform()); |
| 9721 |
| 9722 // Make the child's render surface have contributing content. |
| 9723 child->SetDrawsContent(true); |
| 9724 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9725 ExecuteCalculateDrawProperties(root); |
| 9726 EXPECT_TRUE(child->replica_layer() |
| 9727 ->mask_layer() |
| 9728 ->is_drawn_render_surface_layer_list_member()); |
| 9729 EXPECT_EQ(gfx::Rect(20, 20), |
| 9730 child->replica_layer()->mask_layer()->visible_layer_rect()); |
| 9731 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 9732 expected_screen_space_transform, |
| 9733 child->replica_layer()->mask_layer()->ScreenSpaceTransform()); |
| 9653 } | 9734 } |
| 9654 | 9735 |
| 9655 TEST_F(LayerTreeHostCommonTest, | 9736 TEST_F(LayerTreeHostCommonTest, |
| 9656 SublayerScaleWithTransformNodeBetweenTwoTargets) { | 9737 SublayerScaleWithTransformNodeBetweenTwoTargets) { |
| 9657 LayerImpl* root = root_layer(); | 9738 LayerImpl* root = root_layer(); |
| 9658 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9739 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9659 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); | 9740 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); |
| 9660 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); | 9741 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); |
| 9661 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); | 9742 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); |
| 9662 const gfx::Transform identity_matrix; | 9743 const gfx::Transform identity_matrix; |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10136 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10217 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10137 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10218 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10138 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10219 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10139 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10220 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10140 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10221 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10141 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10222 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10142 } | 10223 } |
| 10143 | 10224 |
| 10144 } // namespace | 10225 } // namespace |
| 10145 } // namespace cc | 10226 } // namespace cc |
| OLD | NEW |