| 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 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3196 gfx::PointF(), gfx::Size(10, 10), true, false, | 3196 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 3197 false); | 3197 false); |
| 3198 SetLayerPropertiesForTesting(grand_child, grand_child_scale_matrix, | 3198 SetLayerPropertiesForTesting(grand_child, grand_child_scale_matrix, |
| 3199 gfx::Point3F(), gfx::PointF(), | 3199 gfx::Point3F(), gfx::PointF(), |
| 3200 gfx::Size(100, 100), true, false, false); | 3200 gfx::Size(100, 100), true, false, false); |
| 3201 | 3201 |
| 3202 child->SetMasksToBounds(true); | 3202 child->SetMasksToBounds(true); |
| 3203 grand_child->SetDrawsContent(true); | 3203 grand_child->SetDrawsContent(true); |
| 3204 ExecuteCalculateDrawProperties(root); | 3204 ExecuteCalculateDrawProperties(root); |
| 3205 | 3205 |
| 3206 // The visible rect is expanded to integer coordinates in target space before | 3206 // The visible rect is expanded to integer coordinates. |
| 3207 // being projected back to layer space, where it is once again expanded to | 3207 EXPECT_EQ(gfx::Rect(41, 41), grand_child->visible_layer_rect()); |
| 3208 // integer coordinates. | |
| 3209 EXPECT_EQ(gfx::Rect(49, 49), grand_child->visible_layer_rect()); | |
| 3210 } | 3208 } |
| 3211 | 3209 |
| 3212 TEST_F(LayerTreeHostCommonTest, | 3210 TEST_F(LayerTreeHostCommonTest, |
| 3213 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { | 3211 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { |
| 3214 LayerImpl* root = root_layer(); | 3212 LayerImpl* root = root_layer(); |
| 3215 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); | 3213 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); |
| 3216 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); | 3214 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); |
| 3217 child1->SetDrawsContent(true); | 3215 child1->SetDrawsContent(true); |
| 3218 LayerImpl* child2 = AddChild<LayerImpl>(render_surface); | 3216 LayerImpl* child2 = AddChild<LayerImpl>(render_surface); |
| 3219 child2->SetDrawsContent(true); | 3217 child2->SetDrawsContent(true); |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4123 diagonal_radius * 2, | 4121 diagonal_radius * 2, |
| 4124 diagonal_radius * 2); | 4122 diagonal_radius * 2); |
| 4125 gfx::RectF expected_surface_drawable_content( | 4123 gfx::RectF expected_surface_drawable_content( |
| 4126 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(50, 50))); | 4124 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(50, 50))); |
| 4127 EXPECT_EQ(expected_surface_drawable_content, | 4125 EXPECT_EQ(expected_surface_drawable_content, |
| 4128 render_surface->render_surface()->DrawableContentRect()); | 4126 render_surface->render_surface()->DrawableContentRect()); |
| 4129 | 4127 |
| 4130 // On the clipped surface, only a quarter of the child1 is visible, but when | 4128 // On the clipped surface, only a quarter of the child1 is visible, but when |
| 4131 // rotating it back to child1's content space, the actual enclosing rect ends | 4129 // rotating it back to child1's content space, the actual enclosing rect ends |
| 4132 // up covering the full left half of child1. | 4130 // up covering the full left half of child1. |
| 4133 // | 4131 EXPECT_EQ(gfx::Rect(0, 0, 25, 50), child1->visible_layer_rect()); |
| 4134 // Given the floating point math, this number is a little bit fuzzy. | |
| 4135 EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_layer_rect()); | |
| 4136 | 4132 |
| 4137 // The child's DrawableContentRect is unclipped. | 4133 // The child's DrawableContentRect is unclipped. |
| 4138 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); | 4134 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); |
| 4139 } | 4135 } |
| 4140 | 4136 |
| 4141 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { | 4137 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { |
| 4142 LayerImpl* root = root_layer(); | 4138 LayerImpl* root = root_layer(); |
| 4143 FakePictureLayerImpl* render_surface1 = | 4139 FakePictureLayerImpl* render_surface1 = |
| 4144 AddChildToRoot<FakePictureLayerImpl>(); | 4140 AddChildToRoot<FakePictureLayerImpl>(); |
| 4145 render_surface1->SetDrawsContent(true); | 4141 render_surface1->SetDrawsContent(true); |
| (...skipping 4964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9110 | 9106 |
| 9111 EXPECT_TRUE(root->has_render_surface()); | 9107 EXPECT_TRUE(root->has_render_surface()); |
| 9112 EXPECT_FALSE(significant_transform->has_render_surface()); | 9108 EXPECT_FALSE(significant_transform->has_render_surface()); |
| 9113 EXPECT_TRUE(layer_clips_subtree->has_render_surface()); | 9109 EXPECT_TRUE(layer_clips_subtree->has_render_surface()); |
| 9114 EXPECT_TRUE(render_surface->has_render_surface()); | 9110 EXPECT_TRUE(render_surface->has_render_surface()); |
| 9115 EXPECT_FALSE(test_layer->has_render_surface()); | 9111 EXPECT_FALSE(test_layer->has_render_surface()); |
| 9116 | 9112 |
| 9117 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; | 9113 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; |
| 9118 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); | 9114 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); |
| 9119 EXPECT_FALSE(clip_node->data.applies_local_clip); | 9115 EXPECT_FALSE(clip_node->data.applies_local_clip); |
| 9120 EXPECT_EQ(gfx::Rect(22, 21), test_layer->visible_layer_rect()); | 9116 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect()); |
| 9121 } | 9117 } |
| 9122 | 9118 |
| 9123 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { | 9119 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { |
| 9124 // Ensure that when parent clip node's transform is an ancestor of current | 9120 // Ensure that when parent clip node's transform is an ancestor of current |
| 9125 // clip node's target, clip is 'projected' from parent space to current | 9121 // clip node's target, clip is 'projected' from parent space to current |
| 9126 // target space and visible rects are calculated correctly. | 9122 // target space and visible rects are calculated correctly. |
| 9127 LayerImpl* root = root_layer(); | 9123 LayerImpl* root = root_layer(); |
| 9128 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 9124 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 9129 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); | 9125 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); |
| 9130 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); | 9126 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10136 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10132 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10137 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10133 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10138 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10134 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10139 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10135 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10140 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10136 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10141 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10137 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10142 } | 10138 } |
| 10143 | 10139 |
| 10144 } // namespace | 10140 } // namespace |
| 10145 } // namespace cc | 10141 } // namespace cc |
| OLD | NEW |