summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorenne <enne@chromium.org>2015-08-18 10:55:33 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-18 17:56:14 +0000
commit76bf8982ed26069929e8dba929aa3f9b57460355 (patch)
tree28c85b000e685ad3cbd1539ff8c5685113579538 /cc
parent085b48a17a831123595a7538ac140592217a99d8 (diff)
downloadchromium_src-76bf8982ed26069929e8dba929aa3f9b57460355.zip
chromium_src-76bf8982ed26069929e8dba929aa3f9b57460355.tar.gz
chromium_src-76bf8982ed26069929e8dba929aa3f9b57460355.tar.bz2
cc: Split IsClippedCorrectly unit test into two versions
The main thread doesn't know anything about render surface clipping. However, the main thread is the only place that sets is_clipped on layers, so it seemed worthwhile keeping both versions of this test, even if it's a bit redundant. It's possible that is_clipped can be answered by property trees instead of layer properties in the future, in which case this could be collapsed back into one test. R=weiliangc@chromium.org,ajuma@chromium.org BUG=502041 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1300723003 Cr-Commit-Position: refs/heads/master@{#343959}
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc110
1 files changed, 106 insertions, 4 deletions
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index f97f40b..47db2a9 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -1634,11 +1634,9 @@ TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
ASSERT_TRUE(child2->render_surface());
EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(root->render_surface()->is_clipped());
EXPECT_FALSE(parent->is_clipped());
EXPECT_FALSE(child1->is_clipped());
EXPECT_FALSE(child2->is_clipped());
- EXPECT_FALSE(child2->render_surface()->is_clipped());
EXPECT_FALSE(grand_child->is_clipped());
EXPECT_FALSE(leaf_node1->is_clipped());
EXPECT_FALSE(leaf_node2->is_clipped());
@@ -1660,11 +1658,9 @@ TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
ASSERT_TRUE(child2->render_surface());
EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(root->render_surface()->is_clipped());
EXPECT_TRUE(parent->is_clipped());
EXPECT_TRUE(child1->is_clipped());
EXPECT_FALSE(child2->is_clipped());
- EXPECT_TRUE(child2->render_surface()->is_clipped());
EXPECT_TRUE(grand_child->is_clipped());
EXPECT_TRUE(leaf_node1->is_clipped());
EXPECT_FALSE(leaf_node2->is_clipped());
@@ -1685,6 +1681,112 @@ TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectly) {
ASSERT_TRUE(child2->render_surface());
EXPECT_FALSE(root->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_TRUE(child2->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_TRUE(leaf_node2->is_clipped());
+ }
+}
+
+TEST_F(LayerTreeHostCommonTest, IsClippedIsSetCorrectlyLayerImpl) {
+ // This is identical to the IsClippedIsSetCorrectly test,
+ // but tests render surfaces instead of the layers.
+
+ const gfx::Transform identity_matrix;
+ LayerImpl* root = root_layer();
+ LayerImpl* parent = AddChild<LayerImpl>(root);
+ LayerImpl* child1 = AddChild<LayerImpl>(parent);
+ LayerImpl* child2 = AddChild<LayerImpl>(parent);
+ LayerImpl* grand_child = AddChild<LayerImpl>(child1);
+ LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
+ leaf_node1->SetDrawsContent(true);
+ LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
+ leaf_node2->SetDrawsContent(true);
+
+ SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ true);
+ SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+ SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+ SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ true);
+ SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+ SetLayerPropertiesForTesting(leaf_node1, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+ SetLayerPropertiesForTesting(leaf_node2, identity_matrix, gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ false);
+
+ // Case 1: nothing is clipped except the root render surface.
+ {
+ ExecuteCalculateDrawProperties(root);
+
+ ASSERT_TRUE(root->render_surface());
+ ASSERT_TRUE(child2->render_surface());
+
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_FALSE(child2->is_clipped());
+ EXPECT_FALSE(child2->render_surface()->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_FALSE(leaf_node2->is_clipped());
+ }
+
+ // Case 2: parent masksToBounds, so the parent, child1, and child2's
+ // surface are clipped. But layers that contribute to child2's surface are
+ // not clipped explicitly because child2's surface already accounts for
+ // that clip.
+ {
+ parent->SetMasksToBounds(true);
+
+ parent->set_is_clipped(true);
+ child1->set_is_clipped(true);
+ grand_child->set_is_clipped(true);
+ leaf_node1->set_is_clipped(true);
+ host_impl()->active_tree()->property_trees()->needs_rebuild = true;
+
+ ExecuteCalculateDrawProperties(root);
+
+ ASSERT_TRUE(root->render_surface());
+ ASSERT_TRUE(child2->render_surface());
+
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_TRUE(child2->render_surface()->is_clipped());
+
+ parent->SetMasksToBounds(false);
+ parent->set_is_clipped(false);
+ child1->set_is_clipped(false);
+ grand_child->set_is_clipped(false);
+ leaf_node1->set_is_clipped(false);
+ }
+
+ // Case 3: child2 masksToBounds. The layer and subtree are clipped, and
+ // child2's render surface is not clipped.
+ {
+ child2->SetMasksToBounds(true);
+ child2->set_is_clipped(true);
+ leaf_node2->set_is_clipped(true);
+ host_impl()->active_tree()->property_trees()->needs_rebuild = true;
+
+ ExecuteCalculateDrawProperties(root);
+
+ ASSERT_TRUE(root->render_surface());
+ ASSERT_TRUE(child2->render_surface());
+
+ EXPECT_FALSE(root->is_clipped());
EXPECT_TRUE(root->render_surface()->is_clipped());
EXPECT_FALSE(parent->is_clipped());
EXPECT_FALSE(child1->is_clipped());