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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 8222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8233 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root.get()); | 8233 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root.get()); |
8234 | 8234 |
8235 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); | 8235 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); |
8236 EXPECT_FALSE(root->visited()); | 8236 EXPECT_FALSE(root->visited()); |
8237 EXPECT_FALSE(root->sorted_for_recursion()); | 8237 EXPECT_FALSE(root->sorted_for_recursion()); |
8238 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); | 8238 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); |
8239 EXPECT_FALSE(child->visited()); | 8239 EXPECT_FALSE(child->visited()); |
8240 EXPECT_FALSE(child->sorted_for_recursion()); | 8240 EXPECT_FALSE(child->sorted_for_recursion()); |
8241 } | 8241 } |
8242 | 8242 |
| 8243 TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) { |
| 8244 // Ensure that a Clip Node is added when a render surface applies clip. |
| 8245 LayerImpl* root = root_layer(); |
| 8246 LayerImpl* significant_transform = AddChildToRoot<LayerImpl>(); |
| 8247 LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform); |
| 8248 LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree); |
| 8249 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 8250 |
| 8251 const gfx::Transform identity_matrix; |
| 8252 // This transform should be a significant one so that a transform node is |
| 8253 // formed for it. |
| 8254 gfx::Transform transform1; |
| 8255 transform1.RotateAboutYAxis(45); |
| 8256 transform1.RotateAboutXAxis(30); |
| 8257 // This transform should be a 3d transform as we want the render surface |
| 8258 // to flatten the transform |
| 8259 gfx::Transform transform2; |
| 8260 transform2.Translate3d(10, 10, 10); |
| 8261 |
| 8262 layer_clips_subtree->SetMasksToBounds(true); |
| 8263 test_layer->SetDrawsContent(true); |
| 8264 |
| 8265 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 8266 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 8267 true); |
| 8268 SetLayerPropertiesForTesting(significant_transform, transform1, |
| 8269 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 8270 true, false, false); |
| 8271 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, |
| 8272 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 8273 true, false, false); |
| 8274 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), |
| 8275 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 8276 true); |
| 8277 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
| 8278 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 8279 false); |
| 8280 |
| 8281 ExecuteCalculateDrawProperties(root); |
| 8282 |
| 8283 TransformTree transform_tree = |
| 8284 root->layer_tree_impl()->property_trees()->transform_tree; |
| 8285 TransformNode* transform_node = transform_tree.Node(2); |
| 8286 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); |
| 8287 |
| 8288 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; |
| 8289 ClipNode* clip_node = clip_tree.Node(3); |
| 8290 EXPECT_EQ(clip_node->owner_id, render_surface->id()); |
| 8291 EXPECT_TRUE(clip_node->data.inherit_parent_target_space_clip); |
| 8292 EXPECT_EQ(test_layer->visible_rect_from_property_trees().ToString(), |
| 8293 test_layer->visible_layer_rect().ToString()); |
| 8294 } |
| 8295 |
8243 } // namespace | 8296 } // namespace |
8244 } // namespace cc | 8297 } // namespace cc |
OLD | NEW |