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/keyframed_animation_curve.h" | 10 #include "cc/animation/keyframed_animation_curve.h" |
(...skipping 6936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6947 gfx::PointF(), gfx::Size(120, 120), true, false); | 6947 gfx::PointF(), gfx::Size(120, 120), true, false); |
6948 | 6948 |
6949 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 6949 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
6950 | 6950 |
6951 // The animated layer maps to the empty rect in clipped target space, so is | 6951 // The animated layer maps to the empty rect in clipped target space, so is |
6952 // treated as having an empty visible rect. | 6952 // treated as having an empty visible rect. |
6953 EXPECT_EQ(gfx::Rect(), animated->visible_rect_from_property_trees()); | 6953 EXPECT_EQ(gfx::Rect(), animated->visible_rect_from_property_trees()); |
6954 | 6954 |
6955 // This time, flattening does not make |animated|'s transform invertible. This | 6955 // This time, flattening does not make |animated|'s transform invertible. This |
6956 // means the clip cannot be projected into |surface|'s space, so we treat | 6956 // means the clip cannot be projected into |surface|'s space, so we treat |
6957 // |surface| and layers that draw into it as fully visible. | 6957 // |surface| and layers that draw into it as having empty visible rect. |
6958 EXPECT_EQ(gfx::Rect(100, 100), surface->visible_rect_from_property_trees()); | 6958 EXPECT_EQ(gfx::Rect(), surface->visible_rect_from_property_trees()); |
6959 EXPECT_EQ(gfx::Rect(200, 200), | 6959 EXPECT_EQ(gfx::Rect(), |
6960 descendant_of_animation->visible_rect_from_property_trees()); | 6960 descendant_of_animation->visible_rect_from_property_trees()); |
6961 } | 6961 } |
6962 | 6962 |
6963 // Verify that having an animated filter (but no current filter, as these | 6963 // Verify that having an animated filter (but no current filter, as these |
6964 // are mutually exclusive) correctly creates a render surface. | 6964 // are mutually exclusive) correctly creates a render surface. |
6965 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { | 6965 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
6966 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 6966 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
6967 scoped_refptr<Layer> child = Layer::Create(layer_settings()); | 6967 scoped_refptr<Layer> child = Layer::Create(layer_settings()); |
6968 scoped_refptr<Layer> grandchild = Layer::Create(layer_settings()); | 6968 scoped_refptr<Layer> grandchild = Layer::Create(layer_settings()); |
6969 root->AddChild(child); | 6969 root->AddChild(child); |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7774 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root.get()); | 7774 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root.get()); |
7775 | 7775 |
7776 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); | 7776 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); |
7777 EXPECT_FALSE(root->visited()); | 7777 EXPECT_FALSE(root->visited()); |
7778 EXPECT_FALSE(root->sorted_for_recursion()); | 7778 EXPECT_FALSE(root->sorted_for_recursion()); |
7779 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); | 7779 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); |
7780 EXPECT_FALSE(child->visited()); | 7780 EXPECT_FALSE(child->visited()); |
7781 EXPECT_FALSE(child->sorted_for_recursion()); | 7781 EXPECT_FALSE(child->sorted_for_recursion()); |
7782 } | 7782 } |
7783 | 7783 |
| 7784 TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) { |
| 7785 // Ensure that a Clip Node is added when a render surface applies clip. |
| 7786 LayerImpl* root = root_layer(); |
| 7787 LayerImpl* significant_transform = AddChildToRoot<LayerImpl>(); |
| 7788 LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform); |
| 7789 LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree); |
| 7790 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 7791 |
| 7792 const gfx::Transform identity_matrix; |
| 7793 // This transform should be a significant one so that a transform node is |
| 7794 // formed for it. |
| 7795 gfx::Transform transform1; |
| 7796 transform1.RotateAboutYAxis(45); |
| 7797 transform1.RotateAboutXAxis(30); |
| 7798 // This transform should be a 3d transform as we want the render surface |
| 7799 // to flatten the transform |
| 7800 gfx::Transform transform2; |
| 7801 transform2.Translate3d(10, 10, 10); |
| 7802 |
| 7803 layer_clips_subtree->SetMasksToBounds(true); |
| 7804 test_layer->SetDrawsContent(true); |
| 7805 |
| 7806 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 7807 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7808 true); |
| 7809 SetLayerPropertiesForTesting(significant_transform, transform1, |
| 7810 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 7811 true, false, false); |
| 7812 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, |
| 7813 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 7814 true, false, false); |
| 7815 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), |
| 7816 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7817 true); |
| 7818 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
| 7819 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7820 false); |
| 7821 |
| 7822 ExecuteCalculateDrawProperties(root); |
| 7823 |
| 7824 TransformTree transform_tree = |
| 7825 root->layer_tree_impl()->property_trees()->transform_tree; |
| 7826 TransformNode* transform_node = |
| 7827 transform_tree.Node(significant_transform->transform_tree_index()); |
| 7828 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); |
| 7829 |
| 7830 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; |
| 7831 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); |
| 7832 EXPECT_TRUE(clip_node->data.inherit_parent_target_space_clip); |
| 7833 EXPECT_EQ(test_layer->visible_rect_from_property_trees(), gfx::RectF(30, 21)); |
| 7834 } |
| 7835 |
| 7836 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { |
| 7837 // Ensure that when parent clip node's transform is an ancestor of current |
| 7838 // clip node's target, clip is 'projected' from parent space to current |
| 7839 // target space and visible rects are calculated correctly. |
| 7840 LayerImpl* root = root_layer(); |
| 7841 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 7842 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); |
| 7843 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); |
| 7844 |
| 7845 const gfx::Transform identity_matrix; |
| 7846 gfx::Transform transform; |
| 7847 transform.RotateAboutYAxis(45); |
| 7848 clip_layer->SetMasksToBounds(true); |
| 7849 target_layer->SetMasksToBounds(true); |
| 7850 test_layer->SetDrawsContent(true); |
| 7851 |
| 7852 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 7853 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7854 true); |
| 7855 SetLayerPropertiesForTesting(clip_layer, transform, gfx::Point3F(), |
| 7856 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7857 false); |
| 7858 SetLayerPropertiesForTesting(target_layer, transform, gfx::Point3F(), |
| 7859 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7860 true); |
| 7861 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), |
| 7862 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 7863 false); |
| 7864 ExecuteCalculateDrawProperties(root); |
| 7865 |
| 7866 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; |
| 7867 ClipNode* clip_node = clip_tree.Node(target_layer->clip_tree_index()); |
| 7868 EXPECT_EQ(clip_node->data.combined_clip, gfx::RectF(30, 30)); |
| 7869 EXPECT_EQ(test_layer->visible_rect_from_property_trees(), gfx::RectF(30, 30)); |
| 7870 } |
| 7871 |
7784 } // namespace | 7872 } // namespace |
7785 } // namespace cc | 7873 } // namespace cc |
OLD | NEW |