Chromium Code Reviews| 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 3321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3332 EXPECT_EQ(gfx::Rect(14, 14, 388, 388), grand_child1->drawable_content_rect()); | 3332 EXPECT_EQ(gfx::Rect(14, 14, 388, 388), grand_child1->drawable_content_rect()); |
| 3333 EXPECT_EQ(gfx::Rect(12, 12, 390, 390), grand_child2->drawable_content_rect()); | 3333 EXPECT_EQ(gfx::Rect(12, 12, 390, 390), grand_child2->drawable_content_rect()); |
| 3334 EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node1->drawable_content_rect()); | 3334 EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node1->drawable_content_rect()); |
| 3335 EXPECT_EQ(gfx::Rect(21, 21, 381, 381), leaf_node2->drawable_content_rect()); | 3335 EXPECT_EQ(gfx::Rect(21, 21, 381, 381), leaf_node2->drawable_content_rect()); |
| 3336 | 3336 |
| 3337 parent->SetMasksToBounds(false); | 3337 parent->SetMasksToBounds(false); |
| 3338 | 3338 |
| 3339 // Case 3: child1 and grand_child2 clip. In this case, descendants of these | 3339 // Case 3: child1 and grand_child2 clip. In this case, descendants of these |
| 3340 // layers have their visible rects clipped by them; without surfaces, these | 3340 // layers have their visible rects clipped by them; without surfaces, these |
| 3341 // rects are also clipped by the viewport. Similarly, descendants of these | 3341 // rects are also clipped by the viewport. Similarly, descendants of these |
| 3342 // layers have their drawable content rects clipped by them. | 3342 // layers have their drawable content rects clipped by them. |
|
ajuma
2016/09/01 23:52:54
Please update the comment.
jaydasika
2016/09/02 00:38:31
Done.
| |
| 3343 child1->SetMasksToBounds(true); | 3343 child1->SetMasksToBounds(true); |
| 3344 grand_child2->SetMasksToBounds(true); | 3344 grand_child2->SetMasksToBounds(true); |
| 3345 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 3345 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 3346 ExecuteCalculateDrawProperties(root); | 3346 ExecuteCalculateDrawProperties(root); |
| 3347 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); | 3347 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); |
| 3348 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); | 3348 EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect()); |
| 3349 EXPECT_EQ(gfx::Rect(800, 800), child1->visible_layer_rect()); | 3349 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect()); |
| 3350 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); | 3350 EXPECT_EQ(gfx::Rect(800, 800), child2->visible_layer_rect()); |
| 3351 EXPECT_EQ(gfx::Rect(792, 792), grand_child1->visible_layer_rect()); | 3351 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect()); |
| 3352 EXPECT_EQ(gfx::Rect(1500, 1500), grand_child2->visible_layer_rect()); | 3352 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect()); |
| 3353 EXPECT_EQ(gfx::Rect(776, 776), leaf_node1->visible_layer_rect()); | 3353 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect()); |
| 3354 EXPECT_EQ(gfx::Rect(1491, 1491), leaf_node2->visible_layer_rect()); | 3354 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect()); |
| 3355 | 3355 |
| 3356 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect()); | 3356 EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect()); |
| 3357 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect()); | 3357 EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect()); |
| 3358 EXPECT_EQ(gfx::Rect(800, 800), child1->drawable_content_rect()); | 3358 EXPECT_EQ(gfx::Rect(800, 800), child1->drawable_content_rect()); |
| 3359 EXPECT_EQ(gfx::Rect(800, 800), child2->drawable_content_rect()); | 3359 EXPECT_EQ(gfx::Rect(800, 800), child2->drawable_content_rect()); |
| 3360 EXPECT_EQ(gfx::Rect(8, 8, 792, 792), grand_child1->drawable_content_rect()); | 3360 EXPECT_EQ(gfx::Rect(8, 8, 792, 792), grand_child1->drawable_content_rect()); |
| 3361 EXPECT_EQ(gfx::Rect(7, 7, 1500, 1500), grand_child2->drawable_content_rect()); | 3361 EXPECT_EQ(gfx::Rect(7, 7, 1500, 1500), grand_child2->drawable_content_rect()); |
| 3362 EXPECT_EQ(gfx::Rect(24, 24, 776, 776), leaf_node1->drawable_content_rect()); | 3362 EXPECT_EQ(gfx::Rect(24, 24, 776, 776), leaf_node1->drawable_content_rect()); |
| 3363 EXPECT_EQ(gfx::Rect(16, 16, 1491, 1491), leaf_node2->drawable_content_rect()); | 3363 EXPECT_EQ(gfx::Rect(16, 16, 1491, 1491), leaf_node2->drawable_content_rect()); |
| 3364 | 3364 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3786 child1->SetDrawsContent(true); | 3786 child1->SetDrawsContent(true); |
| 3787 child2->SetBounds(gfx::Size(700, 700)); | 3787 child2->SetBounds(gfx::Size(700, 700)); |
| 3788 child2->SetDrawsContent(true); | 3788 child2->SetDrawsContent(true); |
| 3789 render_surface2->SetBounds(gfx::Size(1000, 1000)); | 3789 render_surface2->SetBounds(gfx::Size(1000, 1000)); |
| 3790 render_surface2->test_properties()->force_render_surface = true; | 3790 render_surface2->test_properties()->force_render_surface = true; |
| 3791 render_surface2->SetDrawsContent(true); | 3791 render_surface2->SetDrawsContent(true); |
| 3792 | 3792 |
| 3793 child1->SetMasksToBounds(true); | 3793 child1->SetMasksToBounds(true); |
| 3794 child2->SetMasksToBounds(true); | 3794 child2->SetMasksToBounds(true); |
| 3795 ExecuteCalculateDrawProperties(root); | 3795 ExecuteCalculateDrawProperties(root); |
| 3796 EXPECT_EQ(gfx::Rect(500, 500), child1->visible_layer_rect()); | 3796 EXPECT_EQ(gfx::Rect(100, 100), child1->visible_layer_rect()); |
| 3797 EXPECT_EQ(gfx::Rect(100, 100), render_surface2->visible_layer_rect()); | 3797 EXPECT_EQ(gfx::Rect(100, 100), render_surface2->visible_layer_rect()); |
| 3798 } | 3798 } |
| 3799 | 3799 |
| 3800 TEST_F(LayerTreeHostCommonTest, | 3800 TEST_F(LayerTreeHostCommonTest, |
| 3801 VisibleRectsWhenClipChildIsBetweenTwoRenderSurfaces) { | 3801 VisibleRectsWhenClipChildIsBetweenTwoRenderSurfaces) { |
| 3802 LayerImpl* root = root_layer_for_testing(); | 3802 LayerImpl* root = root_layer_for_testing(); |
| 3803 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 3803 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 3804 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); | 3804 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); |
| 3805 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); | 3805 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); |
| 3806 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child); | 3806 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3959 | 3959 |
| 3960 clipped_surface->SetBounds(gfx::Size(50, 50)); | 3960 clipped_surface->SetBounds(gfx::Size(50, 50)); |
| 3961 clipped_surface->SetDrawsContent(true); | 3961 clipped_surface->SetDrawsContent(true); |
| 3962 clipped_surface->test_properties()->force_render_surface = true; | 3962 clipped_surface->test_properties()->force_render_surface = true; |
| 3963 | 3963 |
| 3964 clip_parent->SetMasksToBounds(true); | 3964 clip_parent->SetMasksToBounds(true); |
| 3965 unclipped_desc_surface->SetMasksToBounds(true); | 3965 unclipped_desc_surface->SetMasksToBounds(true); |
| 3966 | 3966 |
| 3967 ExecuteCalculateDrawProperties(root); | 3967 ExecuteCalculateDrawProperties(root); |
| 3968 EXPECT_EQ(gfx::Rect(50, 50), unclipped_surface->visible_layer_rect()); | 3968 EXPECT_EQ(gfx::Rect(50, 50), unclipped_surface->visible_layer_rect()); |
| 3969 EXPECT_EQ(gfx::Rect(50, 50), unclipped_desc_surface->visible_layer_rect()); | 3969 EXPECT_EQ(gfx::Rect(10, 10), unclipped_desc_surface->visible_layer_rect()); |
| 3970 EXPECT_EQ(gfx::Rect(10, 10), clipped_surface->visible_layer_rect()); | 3970 EXPECT_EQ(gfx::Rect(10, 10), clipped_surface->visible_layer_rect()); |
| 3971 } | 3971 } |
| 3972 | 3972 |
| 3973 TEST_F(LayerTreeHostCommonTest, | 3973 TEST_F(LayerTreeHostCommonTest, |
| 3974 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { | 3974 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { |
| 3975 // Layers that have non-axis aligned bounds (due to transforms) have an | 3975 // Layers that have non-axis aligned bounds (due to transforms) have an |
| 3976 // expanded, axis-aligned DrawableContentRect and visible content rect. | 3976 // expanded, axis-aligned DrawableContentRect and visible content rect. |
| 3977 LayerImpl* root = root_layer_for_testing(); | 3977 LayerImpl* root = root_layer_for_testing(); |
| 3978 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); | 3978 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); |
| 3979 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); | 3979 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); |
| (...skipping 5840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9820 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9820 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9821 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9821 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9822 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9822 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9823 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9823 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9824 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9824 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9825 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9825 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9826 } | 9826 } |
| 9827 | 9827 |
| 9828 } // namespace | 9828 } // namespace |
| 9829 } // namespace cc | 9829 } // namespace cc |
| OLD | NEW |