Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1252313004: Add ClipNode when Render Surface Inherits Clip (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 have empty visible rect.
ajuma 2015/08/06 14:25:46 "|surface| and layers that draw into it as having
jaydasika 2015/08/06 16:39:34 Done.
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
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 = transform_tree.Node(2);
7827 EXPECT_EQ(transform_node->owner_id, significant_transform->id());
7828
7829 ClipTree clip_tree = root->layer_tree_impl()->property_trees()->clip_tree;
7830 ClipNode* clip_node = clip_tree.Node(3);
7831 EXPECT_EQ(clip_node->owner_id, render_surface->id());
7832 EXPECT_TRUE(clip_node->data.inherit_parent_target_space_clip);
7833 EXPECT_EQ(test_layer->visible_rect_from_property_trees().ToString(),
7834 test_layer->visible_layer_rect().ToString());
ajuma 2015/08/06 14:25:45 Please compare to an actual value rather than to C
jaydasika 2015/08/06 16:39:34 Done.
7835 }
7836
7784 } // namespace 7837 } // namespace
7785 } // namespace cc 7838 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698