summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authorweiliangc <weiliangc@chromium.org>2016-03-03 16:24:42 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-04 00:25:52 +0000
commitbb2e8644b0c77267e6d1a3cdc6f4c5ac412ccfad (patch)
treeffd7c7a73e13e51b57227addd24e40fb7dd683f0 /cc/trees
parentf6ede73c84e4ea8022c4a27b411aa27c3a10c923 (diff)
downloadchromium_src-bb2e8644b0c77267e6d1a3cdc6f4c5ac412ccfad.zip
chromium_src-bb2e8644b0c77267e6d1a3cdc6f4c5ac412ccfad.tar.gz
chromium_src-bb2e8644b0c77267e6d1a3cdc6f4c5ac412ccfad.tar.bz2
cc: Do not set clip when layers are not clipped
We only use a layer's clip_rect when layer is_clipped. Do not set clip_rect when layer is not clipped. BUG=581843 R=ajuma CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1763873002 Cr-Commit-Position: refs/heads/master@{#379151}
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/draw_property_utils.cc32
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc104
2 files changed, 78 insertions, 58 deletions
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index e74b4e5..85bf5d7 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -67,7 +67,6 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
// The entire layer is visible if it has copy requests.
if (layer->HasCopyRequest()) {
layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
- layer->set_clip_rect_in_target_space(gfx::Rect());
continue;
}
@@ -80,7 +79,6 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
// this clip rect should be mapped to the current layer's target space.
gfx::Rect clip_rect_in_target_space;
gfx::Rect combined_clip_rect_in_target_space;
- bool success = true;
// When we only have a root surface, the clip node and the layer must
// necessarily have the same target (the root).
@@ -92,9 +90,9 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
// target has unclippped descendants, it is unclippped.
if (!clip_node->data.layers_are_clipped) {
layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
- layer->set_clip_rect_in_target_space(gfx::Rect());
continue;
}
+ bool success = true;
gfx::Transform clip_to_target;
if (clip_node->data.target_id > target_node->id) {
// In this case, layer has a scroll parent. We need to keep the scale
@@ -117,7 +115,6 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
// animation, so we still need to compute a visible rect. In this
// situation, we treat the entire layer as visible.
layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
- layer->set_clip_rect_in_target_space(gfx::Rect());
continue;
}
// We use the clip node's clip_in_target_space (and not
@@ -130,17 +127,12 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
combined_clip_rect_in_target_space =
gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
clip_to_target, clip_node->data.clip_in_target_space));
- clip_rect_in_target_space =
- gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
- clip_to_target, clip_node->data.clip_in_target_space));
} else {
combined_clip_rect_in_target_space =
gfx::ToEnclosingRect(MathUtil::MapClippedRect(
clip_to_target, clip_node->data.clip_in_target_space));
- clip_rect_in_target_space =
- gfx::ToEnclosingRect(MathUtil::MapClippedRect(
- clip_to_target, clip_node->data.clip_in_target_space));
}
+ clip_rect_in_target_space = combined_clip_rect_in_target_space;
} else {
clip_rect_in_target_space =
@@ -153,9 +145,7 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
}
if (!clip_rect_in_target_space.IsEmpty()) {
- layer->set_clip_rect_in_target_space(clip_rect_in_target_space);
- } else {
- layer->set_clip_rect_in_target_space(gfx::Rect());
+ layer->set_clip_rect(clip_rect_in_target_space);
}
// The clip rect should be intersected with layer rect in target space.
@@ -188,12 +178,11 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
gfx::Transform target_to_content;
gfx::Transform target_to_layer;
-
+ bool success = true;
if (transform_node->data.ancestors_are_invertible) {
target_to_layer = non_root_surfaces_enabled
? transform_node->data.from_target
: transform_node->data.from_screen;
- success = true;
} else {
success = transform_tree.ComputeTransformWithSourceSublayerScale(
target_node->id, transform_node->id, &target_to_layer);
@@ -219,9 +208,6 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
layer->set_visible_layer_rect(visible_rect);
} else {
layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
- // As the layer is unclipped, the clip rect in target space of this layer
- // is not used. So, we set it to an empty rect.
- layer->set_clip_rect_in_target_space(gfx::Rect());
}
}
}
@@ -974,14 +960,6 @@ static gfx::Transform ReplicaToSurfaceTransform(
return replica_to_surface;
}
-static gfx::Rect LayerClipRect(const LayerImpl* layer,
- const gfx::Rect& layer_bounds_in_target_space) {
- if (layer->is_clipped())
- return layer->clip_rect_in_target_space();
-
- return layer_bounds_in_target_space;
-}
-
void ComputeLayerDrawProperties(LayerImpl* layer,
const PropertyTrees* property_trees,
bool layers_always_allowed_lcd_text,
@@ -1031,8 +1009,6 @@ void ComputeLayerDrawProperties(LayerImpl* layer,
gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect(
layer->draw_properties().target_space_transform,
gfx::Rect(layer->bounds()));
- layer->draw_properties().clip_rect =
- LayerClipRect(layer, bounds_in_target_space);
layer->draw_properties().drawable_content_rect = LayerDrawableContentRect(
layer, bounds_in_target_space, layer->draw_properties().clip_rect);
}
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index d2c1f55..cb78047 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -2257,22 +2257,28 @@ TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) {
EXPECT_TRUE(grand_child->has_render_surface());
EXPECT_FALSE(leaf_node1->has_render_surface());
EXPECT_FALSE(leaf_node2->has_render_surface());
- EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
- EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect());
- EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect());
- EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect());
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_FALSE(child2->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_FALSE(leaf_node2->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_FALSE(child1->render_surface()->is_clipped());
+ EXPECT_FALSE(grand_child->render_surface()->is_clipped());
+ EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
- EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->clip_rect());
- EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->clip_rect());
- EXPECT_EQ(gfx::Rect(14, 14, 1500, 1500), grand_child->clip_rect());
- EXPECT_EQ(gfx::Rect(30, 30, 2000, 2000), leaf_node1->clip_rect());
- EXPECT_EQ(gfx::Rect(14, 14, 2000, 2000), leaf_node2->clip_rect());
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_FALSE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_FALSE(child2->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_FALSE(leaf_node2->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
// Case 2: The root is clipped. In this case, layers that draw into the root
// render surface are clipped by the root's bounds.
@@ -2289,15 +2295,29 @@ TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) {
EXPECT_TRUE(grand_child->has_render_surface());
EXPECT_FALSE(leaf_node1->has_render_surface());
EXPECT_FALSE(leaf_node2->has_render_surface());
+ EXPECT_TRUE(root->is_clipped());
+ EXPECT_TRUE(parent->is_clipped());
+ EXPECT_FALSE(child1->is_clipped());
+ EXPECT_TRUE(child1->render_surface()->is_clipped());
+ EXPECT_TRUE(child2->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_FALSE(grand_child->render_surface()->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_TRUE(leaf_node2->is_clipped());
EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
+ EXPECT_EQ(gfx::Rect(100, 100), child1->render_surface()->clip_rect());
EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect());
- EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect());
EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect());
ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
+ EXPECT_TRUE(root->is_clipped());
+ EXPECT_TRUE(parent->is_clipped());
+ EXPECT_TRUE(child1->is_clipped());
+ EXPECT_TRUE(child2->is_clipped());
+ EXPECT_TRUE(grand_child->is_clipped());
+ EXPECT_TRUE(leaf_node1->is_clipped());
+ EXPECT_TRUE(leaf_node2->is_clipped());
EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
EXPECT_EQ(gfx::Rect(100, 100), parent->clip_rect());
EXPECT_EQ(gfx::Rect(100, 100), child1->clip_rect());
@@ -2328,16 +2348,32 @@ TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) {
EXPECT_TRUE(grand_child->has_render_surface());
EXPECT_FALSE(leaf_node1->has_render_surface());
EXPECT_FALSE(leaf_node2->has_render_surface());
- EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_TRUE(parent->is_clipped());
+ EXPECT_TRUE(child1->is_clipped());
+ EXPECT_TRUE(child2->is_clipped());
+ EXPECT_FALSE(grand_child->is_clipped());
+ EXPECT_TRUE(grand_child->render_surface()->is_clipped());
+ EXPECT_FALSE(leaf_node1->is_clipped());
+ EXPECT_TRUE(leaf_node2->is_clipped());
+ EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
EXPECT_EQ(gfx::Rect(800, 800), child1->clip_rect());
EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
- EXPECT_EQ(gfx::Rect(1500, 1500), grand_child->clip_rect());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node1->clip_rect());
+ EXPECT_EQ(gfx::Rect(800, 800), grand_child->render_surface()->clip_rect());
EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->clip_rect());
+ EXPECT_FALSE(root->is_clipped());
+ EXPECT_TRUE(root->render_surface()->is_clipped());
+ EXPECT_TRUE(parent->is_clipped());
+ EXPECT_TRUE(child1->is_clipped());
+ EXPECT_TRUE(child2->is_clipped());
+ EXPECT_TRUE(grand_child->is_clipped());
+ EXPECT_TRUE(leaf_node1->is_clipped());
+ EXPECT_TRUE(leaf_node2->is_clipped());
+ EXPECT_EQ(gfx::Rect(100, 100), root->render_surface()->clip_rect());
EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->clip_rect());
EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->clip_rect());
EXPECT_EQ(gfx::Rect(2, 2, 400, 400), child2->clip_rect());
@@ -2394,7 +2430,8 @@ TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) {
expected_leaf_draw_transform_without_surfaces.Translate(30.0, 30.0);
ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect());
+ EXPECT_FALSE(leaf_node->is_clipped());
+ EXPECT_TRUE(leaf_node->render_target()->render_surface()->is_clipped());
EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
EXPECT_EQ(expected_leaf_draw_transform_with_surfaces,
leaf_node->DrawTransform());
@@ -2404,6 +2441,7 @@ TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) {
grand_child->SetHasRenderSurface(true);
ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
+ EXPECT_TRUE(leaf_node->is_clipped());
EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node->clip_rect());
EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node->drawable_content_rect());
EXPECT_EQ(expected_leaf_draw_transform_without_surfaces,
@@ -2414,7 +2452,8 @@ TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) {
grand_child->SetHasRenderSurface(true);
ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->clip_rect());
+ EXPECT_FALSE(leaf_node->is_clipped());
+ EXPECT_TRUE(leaf_node->render_target()->render_surface()->is_clipped());
EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
EXPECT_EQ(expected_leaf_draw_transform_with_surfaces,
leaf_node->DrawTransform());
@@ -6280,9 +6319,10 @@ TEST_F(LayerTreeHostCommonTest,
render_surface1->render_surface()->content_rect().ToString());
// This render surface should clip. It has no unclipped descendants.
- EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(),
- render_surface2->clip_rect().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 10).ToString(),
+ render_surface2->render_surface()->clip_rect().ToString());
EXPECT_TRUE(render_surface2->render_surface()->is_clipped());
+ EXPECT_FALSE(render_surface2->is_clipped());
// It also shouldn't have grown to accomodate the clip child.
EXPECT_EQ(gfx::Rect(0, 0, 5, 5).ToString(),
@@ -9391,9 +9431,10 @@ TEST_F(LayerTreeHostCommonTest,
LayerImpl* test_layer = AddChild<LayerImpl>(render_surface);
const gfx::Transform identity_matrix;
- gfx::Transform transform;
- transform.Translate(2.0, 2.0);
+ gfx::Transform translate;
+ translate.Translate(2.0, 2.0);
+ clip_parent->SetMasksToBounds(true);
test_layer->SetDrawsContent(true);
render_surface->SetClipParent(clip_parent);
scoped_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>);
@@ -9402,10 +9443,10 @@ TEST_F(LayerTreeHostCommonTest,
SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(30, 30), true, false,
true);
- SetLayerPropertiesForTesting(clip_parent, transform, gfx::Point3F(),
+ SetLayerPropertiesForTesting(clip_parent, translate, gfx::Point3F(),
gfx::PointF(), gfx::Size(30, 30), true, false,
false);
- SetLayerPropertiesForTesting(between_clip_parent_and_child, transform,
+ SetLayerPropertiesForTesting(between_clip_parent_and_child, translate,
gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
true, false, false);
SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(),
@@ -9417,7 +9458,10 @@ TEST_F(LayerTreeHostCommonTest,
ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(gfx::Rect(30, 30), test_layer->clip_rect());
+ EXPECT_TRUE(test_layer->is_clipped());
+ EXPECT_FALSE(test_layer->render_target()->render_surface()->is_clipped());
+ EXPECT_EQ(gfx::Rect(-2, -2, 28, 28), test_layer->clip_rect());
+ EXPECT_EQ(gfx::Rect(26, 26), test_layer->drawable_content_rect());
}
TEST_F(LayerTreeHostCommonTest,