| 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 5751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5762 ASSERT_EQ(2u, render_surface_layer_list.size()); | 5762 ASSERT_EQ(2u, render_surface_layer_list.size()); |
| 5763 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); | 5763 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); |
| 5764 | 5764 |
| 5765 // The root render surface should only have 2 contributing layer, since the | 5765 // The root render surface should only have 2 contributing layer, since the |
| 5766 // other layers are empty/clipped away. | 5766 // other layers are empty/clipped away. |
| 5767 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); | 5767 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
| 5768 EXPECT_EQ(root_layer->id(), | 5768 EXPECT_EQ(root_layer->id(), |
| 5769 root_layer->render_surface()->layer_list().at(0)->id()); | 5769 root_layer->render_surface()->layer_list().at(0)->id()); |
| 5770 } | 5770 } |
| 5771 | 5771 |
| 5772 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
| 5773 const gfx::Transform identity_matrix; |
| 5774 |
| 5775 LayerImpl* root = root_layer(); |
| 5776 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 5777 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5778 true); |
| 5779 root->SetDrawsContent(true); |
| 5780 root->SetMasksToBounds(true); |
| 5781 |
| 5782 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
| 5783 SetLayerPropertiesForTesting(copy_layer, identity_matrix, gfx::Point3F(), |
| 5784 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 5785 true); |
| 5786 copy_layer->SetDrawsContent(true); |
| 5787 |
| 5788 LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); |
| 5789 SetLayerPropertiesForTesting(copy_child, identity_matrix, gfx::Point3F(), |
| 5790 gfx::PointF(40, 40), gfx::Size(20, 20), true, |
| 5791 false, false); |
| 5792 copy_child->SetDrawsContent(true); |
| 5793 |
| 5794 LayerImpl* copy_clip = AddChild<LayerImpl>(copy_layer); |
| 5795 SetLayerPropertiesForTesting(copy_clip, identity_matrix, gfx::Point3F(), |
| 5796 gfx::PointF(), gfx::Size(55, 55), true, false, |
| 5797 false); |
| 5798 copy_clip->SetMasksToBounds(true); |
| 5799 |
| 5800 LayerImpl* copy_clipped_child = AddChild<LayerImpl>(copy_clip); |
| 5801 SetLayerPropertiesForTesting(copy_clipped_child, identity_matrix, |
| 5802 gfx::Point3F(), gfx::PointF(40, 40), |
| 5803 gfx::Size(20, 20), true, false, false); |
| 5804 copy_clipped_child->SetDrawsContent(true); |
| 5805 |
| 5806 LayerImpl* copy_surface = AddChild<LayerImpl>(copy_clip); |
| 5807 SetLayerPropertiesForTesting(copy_surface, identity_matrix, gfx::Point3F(), |
| 5808 gfx::PointF(45, 45), gfx::Size(20, 20), true, |
| 5809 false, true); |
| 5810 copy_surface->SetDrawsContent(true); |
| 5811 |
| 5812 copy_layer->test_properties()->copy_requests.push_back( |
| 5813 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5814 |
| 5815 ExecuteCalculateDrawProperties(root); |
| 5816 |
| 5817 EXPECT_EQ(gfx::Rect(100, 100), copy_layer->visible_layer_rect()); |
| 5818 EXPECT_EQ(gfx::Rect(20, 20), copy_child->visible_layer_rect()); |
| 5819 EXPECT_EQ(gfx::Rect(15, 15), copy_clipped_child->visible_layer_rect()); |
| 5820 EXPECT_EQ(gfx::Rect(10, 10), copy_surface->visible_layer_rect()); |
| 5821 |
| 5822 // Case 2: When the non root copy request layer is clipped. |
| 5823 copy_layer->SetBounds(gfx::Size(50, 50)); |
| 5824 copy_layer->SetMasksToBounds(true); |
| 5825 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5826 |
| 5827 ExecuteCalculateDrawProperties(root); |
| 5828 |
| 5829 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect()); |
| 5830 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect()); |
| 5831 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect()); |
| 5832 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect()); |
| 5833 } |
| 5834 |
| 5772 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { | 5835 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { |
| 5773 LayerImpl* root = root_layer(); | 5836 LayerImpl* root = root_layer(); |
| 5774 LayerImpl* surface = AddChild<LayerImpl>(root); | 5837 LayerImpl* surface = AddChild<LayerImpl>(root); |
| 5775 LayerImpl* surface_child = AddChild<LayerImpl>(surface); | 5838 LayerImpl* surface_child = AddChild<LayerImpl>(surface); |
| 5776 | 5839 |
| 5777 const gfx::Transform identity_matrix; | 5840 const gfx::Transform identity_matrix; |
| 5778 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 5841 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 5779 gfx::PointF(), gfx::Size(50, 50), true, false, | 5842 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5780 true); | 5843 true); |
| 5781 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(), | 5844 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(), |
| (...skipping 4479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10261 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10324 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10262 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10325 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10263 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10326 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10264 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10327 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10265 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10328 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10266 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10329 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10267 } | 10330 } |
| 10268 | 10331 |
| 10269 } // namespace | 10332 } // namespace |
| 10270 } // namespace cc | 10333 } // namespace cc |
| OLD | NEW |