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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2693703010: cc: Remove support for disabling non-root render surfaces. (Closed)
Patch Set: softwaredraw-remove-no-surfaces: rebase Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_perftest.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 873c9265b9059c8f71f9b09fe1acbdb9a9355e35..6817657d07dd8ec3c4685866c9914aa6aabd1235 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -181,8 +181,6 @@ class LayerTreeHostCommonTestBase : public LayerTestCommon::LayerImplTest {
void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(Layer* root_layer) {
DCHECK(root_layer->layer_tree_host());
- bool can_render_to_separate_surface = true;
-
const Layer* page_scale_layer =
root_layer->layer_tree_host()->page_scale_layer();
Layer* inner_viewport_scroll_layer =
@@ -207,8 +205,7 @@ class LayerTreeHostCommonTestBase : public LayerTestCommon::LayerImplTest {
elastic_overscroll, page_scale_factor, device_scale_factor,
gfx::Rect(device_viewport_size), gfx::Transform(), property_trees);
draw_property_utils::UpdatePropertyTrees(root_layer->layer_tree_host(),
- property_trees,
- can_render_to_separate_surface);
+ property_trees);
draw_property_utils::FindLayersThatNeedUpdates(
root_layer->layer_tree_host(), property_trees, &update_layer_list_);
}
@@ -216,7 +213,6 @@ class LayerTreeHostCommonTestBase : public LayerTestCommon::LayerImplTest {
void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(
LayerImpl* root_layer) {
DCHECK(root_layer->layer_tree_impl());
- bool can_render_to_separate_surface = true;
bool can_adjust_raster_scales = true;
const LayerImpl* page_scale_layer = nullptr;
@@ -244,8 +240,7 @@ class LayerTreeHostCommonTestBase : public LayerTestCommon::LayerImplTest {
elastic_overscroll, page_scale_factor, device_scale_factor,
gfx::Rect(device_viewport_size), gfx::Transform(), property_trees);
draw_property_utils::UpdatePropertyTreesAndRenderSurfaces(
- root_layer, property_trees, can_render_to_separate_surface,
- can_adjust_raster_scales);
+ root_layer, property_trees, can_adjust_raster_scales);
draw_property_utils::FindLayersThatNeedUpdates(
root_layer->layer_tree_impl(), property_trees,
update_layer_list_impl_.get());
@@ -263,7 +258,6 @@ class LayerTreeHostCommonTestBase : public LayerTestCommon::LayerImplTest {
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root_layer, device_viewport_size, render_surface_list_impl_.get());
inputs.can_adjust_raster_scales = true;
- inputs.can_render_to_separate_surface = false;
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
}
@@ -277,7 +271,6 @@ class LayerTreeHostCommonTestBase : public LayerTestCommon::LayerImplTest {
DCHECK(!root_layer->bounds().IsEmpty());
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root_layer, device_viewport_size, render_surface_list_impl_.get());
- inputs.can_render_to_separate_surface = true;
inputs.can_adjust_raster_scales = false;
LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
@@ -770,54 +763,6 @@ TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) {
child->render_target()->screen_space_transform());
}
-TEST_F(LayerTreeHostCommonTest, TransformsWhenCannotRenderToSeparateSurface) {
- LayerImpl* root = root_layer_for_testing();
- LayerImpl* parent = AddChildToRoot<LayerImpl>();
- LayerImpl* child = AddChild<LayerImpl>(parent);
- LayerImpl* grand_child = AddChild<LayerImpl>(child);
-
- gfx::Transform parent_transform;
- parent_transform.Translate(10.0, 10.0);
-
- gfx::Transform child_transform;
- child_transform.Rotate(45.0);
-
- root->SetBounds(gfx::Size(100, 100));
- parent->test_properties()->transform = parent_transform;
- parent->SetBounds(gfx::Size(10, 10));
- child->test_properties()->transform = child_transform;
- child->SetBounds(gfx::Size(10, 10));
- child->test_properties()->force_render_surface = true;
- grand_child->SetPosition(gfx::PointF(2.f, 2.f));
- grand_child->SetBounds(gfx::Size(20, 20));
- grand_child->SetDrawsContent(true);
-
- gfx::Transform expected_grand_child_screen_space_transform;
- expected_grand_child_screen_space_transform.Translate(10.0, 10.0);
- expected_grand_child_screen_space_transform.Rotate(45.0);
- expected_grand_child_screen_space_transform.Translate(2.0, 2.0);
-
- // First compute draw properties with separate surfaces enabled.
- ExecuteCalculateDrawProperties(root);
-
- // The grand child's draw transform should be its offset wrt the child.
- gfx::Transform expected_grand_child_draw_transform;
- expected_grand_child_draw_transform.Translate(2.0, 2.0);
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_draw_transform,
- grand_child->DrawTransform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
- grand_child->ScreenSpaceTransform());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
-
- // With separate surfaces disabled, the grand child's draw transform should be
- // the same as its screen space transform.
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
- grand_child->DrawTransform());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_screen_space_transform,
- grand_child->ScreenSpaceTransform());
-}
-
TEST_F(LayerTreeHostCommonTest, TransformsForRenderSurfaceHierarchy) {
// This test creates a more complex tree and verifies it all at once. This
// covers the following cases:
@@ -1611,66 +1556,6 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) {
EXPECT_EQ(0.25f, GetRenderSurface(surface2)->draw_opacity());
}
-TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) {
- // Tests that when separate surfaces are disabled, a layer's draw opacity is
- // the product of all ancestor layer opacties and the layer's own opacity.
- // (Rendering will still be incorrect in situations where we really do need
- // surfaces to apply opacity, such as when we have overlapping layers with an
- // ancestor whose opacity is <1.)
- LayerImpl* root = root_layer_for_testing();
- 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);
- LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
-
- root->SetBounds(gfx::Size(100, 100));
- root->SetDrawsContent(true);
- parent->SetBounds(gfx::Size(100, 100));
- parent->SetDrawsContent(true);
- child1->SetBounds(gfx::Size(100, 100));
- child1->SetDrawsContent(true);
- child1->test_properties()->opacity = 0.5f;
- child1->test_properties()->force_render_surface = true;
- child2->SetBounds(gfx::Size(100, 100));
- child2->SetDrawsContent(true);
- grand_child->SetBounds(gfx::Size(100, 100));
- grand_child->SetDrawsContent(true);
- grand_child->test_properties()->opacity = 0.5f;
- grand_child->test_properties()->force_render_surface = true;
- leaf_node1->SetBounds(gfx::Size(100, 100));
- leaf_node1->SetDrawsContent(true);
- leaf_node1->test_properties()->opacity = 0.5f;
- leaf_node2->SetBounds(gfx::Size(100, 100));
- leaf_node2->SetDrawsContent(true);
- leaf_node2->test_properties()->opacity = 0.5f;
-
- // With surfaces enabled, each layer's draw opacity is the product of layer
- // opacities on the path from the layer to its render target, not including
- // the opacity of the layer that owns the target surface (since that opacity
- // is applied by the surface).
- ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(1.f, root->draw_opacity());
- EXPECT_EQ(1.f, parent->draw_opacity());
- EXPECT_EQ(1.f, child1->draw_opacity());
- EXPECT_EQ(1.f, child2->draw_opacity());
- EXPECT_EQ(1.f, grand_child->draw_opacity());
- EXPECT_EQ(0.5f, leaf_node1->draw_opacity());
- EXPECT_EQ(0.5f, leaf_node2->draw_opacity());
-
- // With surfaces disabled, each layer's draw opacity is the product of layer
- // opacities on the path from the layer to the root.
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_EQ(1.f, root->draw_opacity());
- EXPECT_EQ(1.f, parent->draw_opacity());
- EXPECT_EQ(0.5f, child1->draw_opacity());
- EXPECT_EQ(1.f, child2->draw_opacity());
- EXPECT_EQ(0.25f, grand_child->draw_opacity());
- EXPECT_EQ(0.125f, leaf_node1->draw_opacity());
- EXPECT_EQ(0.5f, leaf_node2->draw_opacity());
-}
-
TEST_F(LayerTreeHostCommonTest, ForceRenderSurface) {
LayerImpl* root = root_layer_for_testing();
LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
@@ -1953,154 +1838,6 @@ TEST_F(LayerTreeHostCommonTest, UpdateClipRectCorrectly) {
EXPECT_EQ(gfx::Rect(), child->clip_rect());
}
-TEST_F(LayerTreeHostCommonTest, IsClippedWhenCannotRenderToSeparateSurface) {
- // Tests that when separate surfaces are disabled, is_clipped is true exactly
- // when a layer or its ancestor has a clip; in particular, if a layer
- // is_clipped, so is its entire subtree (since there are no render surfaces
- // that can reset is_clipped).
- LayerImpl* root = root_layer_for_testing();
- 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);
- LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
-
- root->SetBounds(gfx::Size(100, 100));
- root->SetDrawsContent(true);
- parent->SetBounds(gfx::Size(100, 100));
- parent->SetDrawsContent(true);
- child1->SetBounds(gfx::Size(100, 100));
- child1->SetDrawsContent(true);
- child1->test_properties()->force_render_surface = true;
- child2->SetBounds(gfx::Size(100, 100));
- child2->SetDrawsContent(true);
- grand_child->SetBounds(gfx::Size(100, 100));
- grand_child->SetDrawsContent(true);
- grand_child->test_properties()->force_render_surface = true;
- leaf_node1->SetBounds(gfx::Size(100, 100));
- leaf_node1->SetDrawsContent(true);
- leaf_node2->SetBounds(gfx::Size(100, 100));
- leaf_node2->SetDrawsContent(true);
-
- // Case 1: Nothing is clipped. In this case, is_clipped is always false, with
- // or without surfaces.
- ExecuteCalculateDrawProperties(root);
- 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());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- 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());
-
- // Case 2: The root is clipped. With surfaces, this only persists until the
- // next render surface. Without surfaces, the entire tree is clipped.
- root->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_TRUE(root->is_clipped());
- EXPECT_TRUE(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());
-
- 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());
-
- root->SetMasksToBounds(false);
-
- // Case 3: The parent is clipped. Again, with surfaces, this only persists
- // until the next render surface. Without surfaces, parent's entire subtree is
- // clipped.
- parent->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(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());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_FALSE(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());
-
- parent->SetMasksToBounds(false);
-
- // Case 4: child1 is clipped. With surfaces, only child1 is_clipped, since it
- // has no non-surface children. Without surfaces, child1's entire subtree is
- // clipped.
- child1->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_FALSE(root->is_clipped());
- EXPECT_FALSE(parent->is_clipped());
- EXPECT_TRUE(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());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_FALSE(root->is_clipped());
- EXPECT_FALSE(parent->is_clipped());
- EXPECT_TRUE(child1->is_clipped());
- EXPECT_FALSE(child2->is_clipped());
- EXPECT_TRUE(grand_child->is_clipped());
- EXPECT_TRUE(leaf_node1->is_clipped());
- EXPECT_FALSE(leaf_node2->is_clipped());
-
- child1->SetMasksToBounds(false);
-
- // Case 5: Only the leaf nodes are clipped. The behavior with and without
- // surfaces is the same.
- leaf_node1->SetMasksToBounds(true);
- leaf_node2->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
- 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_TRUE(leaf_node1->is_clipped());
- EXPECT_TRUE(leaf_node2->is_clipped());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- 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_TRUE(leaf_node1->is_clipped());
- EXPECT_TRUE(leaf_node2->is_clipped());
-}
-
TEST_F(LayerTreeHostCommonTest, DrawableContentRectForLayers) {
// Verify that layers get the appropriate DrawableContentRect when their
// parent MasksToBounds is true.
@@ -2210,274 +1947,6 @@ TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
GetRenderSurface(grand_child3)->clip_rect());
}
-TEST_F(LayerTreeHostCommonTest, ClipRectWhenCannotRenderToSeparateSurface) {
- // Tests that when separate surfaces are disabled, a layer's clip_rect is the
- // intersection of all ancestor clips in screen space; in particular, if a
- // layer masks to bounds, it contributes to the clip_rect of all layers in its
- // subtree (since there are no render surfaces that can reset the clip_rect).
- LayerImpl* root = root_layer_for_testing();
- 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);
- LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
-
- root->SetBounds(gfx::Size(100, 100));
- parent->SetPosition(gfx::PointF(2.f, 2.f));
- parent->SetBounds(gfx::Size(400, 400));
- child1->SetPosition(gfx::PointF(4.f, 4.f));
- child1->SetBounds(gfx::Size(800, 800));
- child2->SetPosition(gfx::PointF(3.f, 3.f));
- child2->SetBounds(gfx::Size(800, 800));
- grand_child->SetPosition(gfx::PointF(8.f, 8.f));
- grand_child->SetBounds(gfx::Size(1500, 1500));
- leaf_node1->SetPosition(gfx::PointF(16.f, 16.f));
- leaf_node1->SetBounds(gfx::Size(2000, 2000));
- leaf_node2->SetPosition(gfx::PointF(9.f, 9.f));
- leaf_node2->SetBounds(gfx::Size(2000, 2000));
-
- root->SetDrawsContent(true);
- parent->SetDrawsContent(true);
- child1->SetDrawsContent(true);
- child2->SetDrawsContent(true);
- grand_child->SetDrawsContent(true);
- leaf_node1->SetDrawsContent(true);
- leaf_node2->SetDrawsContent(true);
-
- root->test_properties()->force_render_surface = true;
- child1->test_properties()->force_render_surface = true;
- grand_child->test_properties()->force_render_surface = true;
-
- // Case 1: Nothing is clipped. In this case, each layer's clip rect is its
- // bounds in target space. The only thing that changes when surfaces are
- // disabled is that target space is always screen space.
- ExecuteCalculateDrawProperties(root);
- EXPECT_TRUE(GetRenderSurface(root));
- EXPECT_FALSE(GetRenderSurface(parent));
- EXPECT_TRUE(GetRenderSurface(child1));
- EXPECT_FALSE(GetRenderSurface(child2));
- EXPECT_TRUE(GetRenderSurface(grand_child));
- EXPECT_FALSE(GetRenderSurface(leaf_node1));
- EXPECT_FALSE(GetRenderSurface(leaf_node2));
- 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(GetRenderSurface(root)->is_clipped());
- EXPECT_FALSE(GetRenderSurface(child1)->is_clipped());
- EXPECT_FALSE(GetRenderSurface(grand_child)->is_clipped());
- EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(root)->clip_rect());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- 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(GetRenderSurface(root)->is_clipped());
- EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(root)->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.
- root->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- root->test_properties()->force_render_surface = true;
- child1->test_properties()->force_render_surface = true;
- grand_child->test_properties()->force_render_surface = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_TRUE(GetRenderSurface(root));
- EXPECT_FALSE(GetRenderSurface(parent));
- EXPECT_TRUE(GetRenderSurface(child1));
- EXPECT_FALSE(GetRenderSurface(child2));
- EXPECT_TRUE(GetRenderSurface(grand_child));
- EXPECT_FALSE(GetRenderSurface(leaf_node1));
- EXPECT_FALSE(GetRenderSurface(leaf_node2));
- EXPECT_TRUE(root->is_clipped());
- EXPECT_TRUE(parent->is_clipped());
- EXPECT_FALSE(child1->is_clipped());
- EXPECT_TRUE(GetRenderSurface(child1)->is_clipped());
- EXPECT_TRUE(child2->is_clipped());
- EXPECT_FALSE(grand_child->is_clipped());
- EXPECT_FALSE(GetRenderSurface(grand_child)->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(100, 100), GetRenderSurface(child1)->clip_rect());
- EXPECT_EQ(gfx::Rect(100, 100), child2->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());
- EXPECT_EQ(gfx::Rect(100, 100), child2->clip_rect());
- EXPECT_EQ(gfx::Rect(100, 100), grand_child->clip_rect());
- EXPECT_EQ(gfx::Rect(100, 100), leaf_node1->clip_rect());
- EXPECT_EQ(gfx::Rect(100, 100), leaf_node2->clip_rect());
-
- root->SetMasksToBounds(false);
-
- // Case 3: The parent and child1 are clipped. When surfaces are enabled, the
- // parent clip rect only contributes to the subtree rooted at child2, since
- // the subtree rooted at child1 renders into a separate surface. Similarly,
- // child1's clip rect doesn't contribute to its descendants, since its only
- // child is a render surface. However, without surfaces, these clip rects
- // contribute to all descendants.
- parent->SetMasksToBounds(true);
- child1->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- root->test_properties()->force_render_surface = true;
- child1->test_properties()->force_render_surface = true;
- grand_child->test_properties()->force_render_surface = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_TRUE(GetRenderSurface(root));
- EXPECT_FALSE(GetRenderSurface(parent));
- EXPECT_TRUE(GetRenderSurface(child1));
- EXPECT_FALSE(GetRenderSurface(child2));
- EXPECT_TRUE(GetRenderSurface(grand_child));
- EXPECT_FALSE(GetRenderSurface(leaf_node1));
- EXPECT_FALSE(GetRenderSurface(leaf_node2));
- EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(GetRenderSurface(root)->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(GetRenderSurface(grand_child)->is_clipped());
- EXPECT_FALSE(leaf_node1->is_clipped());
- EXPECT_TRUE(leaf_node2->is_clipped());
- EXPECT_EQ(gfx::Rect(100, 100), GetRenderSurface(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(2, 2, 400, 400), child2->clip_rect());
- EXPECT_EQ(gfx::Rect(800, 800), GetRenderSurface(grand_child)->clip_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_FALSE(root->is_clipped());
- EXPECT_TRUE(GetRenderSurface(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), GetRenderSurface(root)->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());
- EXPECT_EQ(gfx::Rect(6, 6, 396, 396), grand_child->clip_rect());
- EXPECT_EQ(gfx::Rect(6, 6, 396, 396), leaf_node1->clip_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), leaf_node2->clip_rect());
-}
-
-TEST_F(LayerTreeHostCommonTest, HitTestingWhenSurfacesDisabled) {
- LayerImpl* root = root_layer_for_testing();
- LayerImpl* parent = AddChild<LayerImpl>(root);
- LayerImpl* child = AddChild<LayerImpl>(parent);
- LayerImpl* grand_child = AddChild<LayerImpl>(child);
- LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
-
- root->SetBounds(gfx::Size(100, 100));
- parent->SetPosition(gfx::PointF(2.f, 2.f));
- parent->SetBounds(gfx::Size(400, 400));
- parent->SetMasksToBounds(true);
- child->SetPosition(gfx::PointF(4.f, 4.f));
- child->SetBounds(gfx::Size(800, 800));
- child->SetMasksToBounds(true);
- child->test_properties()->force_render_surface = true;
- grand_child->SetPosition(gfx::PointF(8.f, 8.f));
- grand_child->SetBounds(gfx::Size(1500, 1500));
- grand_child->test_properties()->force_render_surface = true;
- leaf_node->SetPosition(gfx::PointF(16.f, 16.f));
- leaf_node->SetBounds(gfx::Size(2000, 2000));
-
- root->SetDrawsContent(true);
- parent->SetDrawsContent(true);
- child->SetDrawsContent(true);
- grand_child->SetDrawsContent(true);
- leaf_node->SetDrawsContent(true);
-
- host_impl()->set_resourceless_software_draw_for_testing();
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- gfx::PointF test_point(90.f, 90.f);
- LayerImpl* result_layer =
- root->layer_tree_impl()->FindLayerThatIsHitByPoint(test_point);
- ASSERT_TRUE(result_layer);
- EXPECT_EQ(leaf_node, result_layer);
-}
-
-TEST_F(LayerTreeHostCommonTest, SurfacesDisabledAndReEnabled) {
- // Tests that draw properties are computed correctly when we disable and then
- // re-enable separate surfaces.
- LayerImpl* root = root_layer_for_testing();
- LayerImpl* parent = AddChild<LayerImpl>(root);
- LayerImpl* child = AddChild<LayerImpl>(parent);
- LayerImpl* grand_child = AddChild<LayerImpl>(child);
- LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child);
-
- root->SetBounds(gfx::Size(100, 100));
- parent->SetPosition(gfx::PointF(2.f, 2.f));
- parent->SetBounds(gfx::Size(400, 400));
- parent->SetMasksToBounds(true);
- child->SetPosition(gfx::PointF(4.f, 4.f));
- child->SetBounds(gfx::Size(800, 800));
- child->SetMasksToBounds(true);
- child->test_properties()->force_render_surface = true;
- grand_child->SetPosition(gfx::PointF(8.f, 8.f));
- grand_child->SetBounds(gfx::Size(1500, 1500));
- grand_child->test_properties()->force_render_surface = true;
- leaf_node->SetPosition(gfx::PointF(16.f, 16.f));
- leaf_node->SetBounds(gfx::Size(2000, 2000));
-
- root->SetDrawsContent(true);
- parent->SetDrawsContent(true);
- child->SetDrawsContent(true);
- grand_child->SetDrawsContent(true);
- leaf_node->SetDrawsContent(true);
-
- gfx::Transform expected_leaf_draw_transform_with_surfaces;
- expected_leaf_draw_transform_with_surfaces.Translate(16.0, 16.0);
-
- gfx::Transform expected_leaf_draw_transform_without_surfaces;
- expected_leaf_draw_transform_without_surfaces.Translate(30.0, 30.0);
-
- ExecuteCalculateDrawProperties(root);
- EXPECT_FALSE(leaf_node->is_clipped());
- EXPECT_TRUE(leaf_node->render_target()->is_clipped());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_leaf_draw_transform_with_surfaces,
- leaf_node->DrawTransform());
-
- 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_TRANSFORMATION_MATRIX_EQ(expected_leaf_draw_transform_without_surfaces,
- leaf_node->DrawTransform());
-
- ExecuteCalculateDrawProperties(root);
- EXPECT_FALSE(leaf_node->is_clipped());
- EXPECT_TRUE(leaf_node->render_target()->is_clipped());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node->drawable_content_rect());
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_leaf_draw_transform_with_surfaces,
- leaf_node->DrawTransform());
-}
-
TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
LayerImpl* root = root_layer_for_testing();
LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>();
@@ -3352,184 +2821,6 @@ TEST_F(LayerTreeHostCommonTest,
}
TEST_F(LayerTreeHostCommonTest,
- DrawableAndVisibleRectsWhenCannotRenderToSeparateSurface) {
- LayerImpl* root = root_layer_for_testing();
- LayerImpl* parent = AddChild<LayerImpl>(root);
- LayerImpl* child1 = AddChild<LayerImpl>(parent);
- LayerImpl* child2 = AddChild<LayerImpl>(parent);
- LayerImpl* grand_child1 = AddChild<LayerImpl>(child1);
- LayerImpl* grand_child2 = AddChild<LayerImpl>(child2);
- LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child1);
- LayerImpl* leaf_node2 = AddChild<LayerImpl>(grand_child2);
-
- root->SetBounds(gfx::Size(100, 100));
- parent->SetPosition(gfx::PointF(2.f, 2.f));
- parent->SetBounds(gfx::Size(400, 400));
- child1->SetPosition(gfx::PointF(4.f, 4.f));
- child1->SetBounds(gfx::Size(800, 800));
- child1->test_properties()->force_render_surface = true;
- child2->SetPosition(gfx::PointF(3.f, 3.f));
- child2->SetBounds(gfx::Size(800, 800));
- child2->test_properties()->force_render_surface = true;
- grand_child1->SetPosition(gfx::PointF(8.f, 8.f));
- grand_child1->SetBounds(gfx::Size(1500, 1500));
- grand_child2->SetPosition(gfx::PointF(7.f, 7.f));
- grand_child2->SetBounds(gfx::Size(1500, 1500));
- leaf_node1->SetPosition(gfx::PointF(16.f, 16.f));
- leaf_node1->SetBounds(gfx::Size(2000, 2000));
- leaf_node2->SetPosition(gfx::PointF(9.f, 9.f));
- leaf_node2->SetBounds(gfx::Size(2000, 2000));
-
- root->SetDrawsContent(true);
- parent->SetDrawsContent(true);
- child1->SetDrawsContent(true);
- child2->SetDrawsContent(true);
- grand_child1->SetDrawsContent(true);
- grand_child2->SetDrawsContent(true);
- leaf_node1->SetDrawsContent(true);
- leaf_node2->SetDrawsContent(true);
-
- // Case 1: No layers clip. Visible rects are clipped by the viewport.
- // Each layer's drawable content rect is its bounds in target space; the only
- // thing that changes with surfaces disabled is that target space is always
- // screen space.
- child1->test_properties()->force_render_surface = true;
- child2->test_properties()->force_render_surface = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
-
- EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(8, 8, 1500, 1500), grand_child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(7, 7, 1500, 1500), grand_child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(24, 24, 2000, 2000), leaf_node1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node2->drawable_content_rect());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
-
- EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(14, 14, 1500, 1500),
- grand_child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(12, 12, 1500, 1500),
- grand_child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(30, 30, 2000, 2000), leaf_node1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(21, 21, 2000, 2000), leaf_node2->drawable_content_rect());
-
- // Case 2: The parent clips. In this case, neither surface is unclipped, so
- // all visible layer rects are clipped by the intersection of all ancestor
- // clips, whether or not surfaces are disabled. However, drawable content
- // rects are clipped only until the next render surface is reached, so
- // descendants of parent have their drawable content rects clipped only when
- // surfaces are disabled.
- parent->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
-
- EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(8, 8, 1500, 1500), grand_child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(7, 7, 1500, 1500), grand_child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(24, 24, 2000, 2000), leaf_node1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(16, 16, 2000, 2000), leaf_node2->drawable_content_rect());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
-
- EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(6, 6, 396, 396), child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(5, 5, 397, 397), child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(14, 14, 388, 388), grand_child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(12, 12, 390, 390), grand_child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(30, 30, 372, 372), leaf_node1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(21, 21, 381, 381), leaf_node2->drawable_content_rect());
-
- parent->SetMasksToBounds(false);
-
- // Case 3: child1 and grand_child2 clip. In this case, descendants of these
- // layers have their visible rects clipped by them; Similarly, descendants of
- // these layers have their drawable content rects clipped by them.
- child1->SetMasksToBounds(true);
- grand_child2->SetMasksToBounds(true);
- host_impl()->active_tree()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
-
- EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(800, 800), child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(8, 8, 792, 792), grand_child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(7, 7, 1500, 1500), grand_child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(24, 24, 776, 776), leaf_node1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(16, 16, 1491, 1491), leaf_node2->drawable_content_rect());
-
- ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces(root);
- EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(98, 98), parent->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect());
- EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect());
-
- EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(2, 2, 400, 400), parent->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(6, 6, 800, 800), child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(5, 5, 800, 800), child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(14, 14, 792, 792), grand_child1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(12, 12, 1500, 1500),
- grand_child2->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(30, 30, 776, 776), leaf_node1->drawable_content_rect());
- EXPECT_EQ(gfx::Rect(21, 21, 1491, 1491), leaf_node2->drawable_content_rect());
-}
-
-TEST_F(LayerTreeHostCommonTest,
VisibleContentRectsForClippedSurfaceWithEmptyClip) {
LayerImpl* root = root_layer_for_testing();
LayerImpl* child1 = AddChild<LayerImpl>(root);
@@ -6140,109 +5431,6 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_FALSE(GetRenderSurface(child3));
}
-TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
- FakeImplTaskRunnerProvider task_runner_provider;
- TestTaskGraphRunner task_graph_runner;
- FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
-
- std::unique_ptr<LayerImpl> root =
- LayerImpl::Create(host_impl.active_tree(), 12345);
- std::unique_ptr<LayerImpl> child1 =
- LayerImpl::Create(host_impl.active_tree(), 123456);
- std::unique_ptr<LayerImpl> child2 =
- LayerImpl::Create(host_impl.active_tree(), 1234567);
- std::unique_ptr<LayerImpl> child3 =
- LayerImpl::Create(host_impl.active_tree(), 12345678);
-
- gfx::Size bounds(100, 100);
-
- root->SetBounds(bounds);
- root->SetDrawsContent(true);
-
- // This layer structure normally forces render surface due to preserves3d
- // behavior.
- child1->SetBounds(bounds);
- child1->SetDrawsContent(true);
- child1->test_properties()->should_flatten_transform = false;
- child1->test_properties()->sorting_context_id = 1;
- child2->SetBounds(bounds);
- child2->SetDrawsContent(true);
- child2->test_properties()->sorting_context_id = 1;
- child3->SetBounds(bounds);
- child3->SetDrawsContent(true);
- child3->test_properties()->sorting_context_id = 1;
-
- child2->test_properties()->AddChild(std::move(child3));
- child1->test_properties()->AddChild(std::move(child2));
- root->test_properties()->AddChild(std::move(child1));
- LayerImpl* root_layer = root.get();
- root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root));
-
- {
- RenderSurfaceList render_surface_list;
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root_layer, root_layer->bounds(), &render_surface_list);
- inputs.can_render_to_separate_surface = true;
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
-
- EXPECT_EQ(2u, render_surface_list.size());
-
- int count_represents_target_render_surface = 0;
- int count_represents_contributing_render_surface = 0;
- int count_represents_itself = 0;
- for (EffectTreeLayerListIterator it(host_impl.active_tree());
- it.state() != EffectTreeLayerListIterator::State::END; ++it) {
- if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
- count_represents_target_render_surface++;
- } else if (it.state() ==
- EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
- count_represents_contributing_render_surface++;
- } else {
- count_represents_itself++;
- }
- }
-
- // Two render surfaces.
- EXPECT_EQ(2, count_represents_target_render_surface);
- // Second render surface contributes to root render surface.
- EXPECT_EQ(1, count_represents_contributing_render_surface);
- // All 4 layers represent itself.
- EXPECT_EQ(4, count_represents_itself);
- }
-
- {
- RenderSurfaceList render_surface_list;
- LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root_layer, root_layer->bounds(), &render_surface_list);
- inputs.can_render_to_separate_surface = false;
- LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
-
- EXPECT_EQ(1u, render_surface_list.size());
-
- int count_represents_target_render_surface = 0;
- int count_represents_contributing_render_surface = 0;
- int count_represents_itself = 0;
- for (EffectTreeLayerListIterator it(host_impl.active_tree());
- it.state() != EffectTreeLayerListIterator::State::END; ++it) {
- if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
- count_represents_target_render_surface++;
- } else if (it.state() ==
- EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
- count_represents_contributing_render_surface++;
- } else {
- count_represents_itself++;
- }
- }
-
- // Only root layer has a render surface.
- EXPECT_EQ(1, count_represents_target_render_surface);
- // No layer contributes a render surface to root render surface.
- EXPECT_EQ(0, count_represents_contributing_render_surface);
- // All 4 layers represent itself.
- EXPECT_EQ(4, count_represents_itself);
- }
-}
-
TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
LayerImpl* root = root_layer_for_testing();
LayerImpl* back_facing = AddChild<LayerImpl>(root);
« no previous file with comments | « cc/trees/layer_tree_host_common_perftest.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698