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

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

Issue 998023002: Revert of Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 AddAnimatedTransformToLayer( 2968 AddAnimatedTransformToLayer(
2969 root.get(), 10.0, start_transform_operations, end_transform_operations); 2969 root.get(), 10.0, start_transform_operations, end_transform_operations);
2970 2970
2971 EXPECT_TRUE(root->TransformIsAnimating()); 2971 EXPECT_TRUE(root->TransformIsAnimating());
2972 2972
2973 ExecuteCalculateDrawProperties(root.get()); 2973 ExecuteCalculateDrawProperties(root.get());
2974 2974
2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion); 2975 EXPECT_FALSE(child->draw_properties().sorted_for_recursion);
2976 } 2976 }
2977 2977
2978 TEST_F(LayerTreeHostCommonTest, WillSortAtContextBoundary) {
2979 // Creates a layer tree that looks as follows:
2980 // * root (sorting-context-id1)
2981 // * parent (sorting-context-id2)
2982 // * child1 (sorting-context-id2)
2983 // * child2 (sorting-context-id2)
2984 //
2985 // This test ensures that we sort at |parent| even though both it and root are
2986 // set to be 3d sorted.
2987 FakeImplProxy proxy;
2988 TestSharedBitmapManager shared_bitmap_manager;
2989 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
2990
2991 scoped_ptr<LayerImpl> root_ptr(LayerImpl::Create(host_impl.active_tree(), 1));
2992 LayerImpl* root = root_ptr.get();
2993 scoped_ptr<LayerImpl> parent_ptr(
2994 LayerImpl::Create(host_impl.active_tree(), 2));
2995 LayerImpl* parent = parent_ptr.get();
2996 scoped_ptr<LayerImpl> child1_ptr(
2997 LayerImpl::Create(host_impl.active_tree(), 3));
2998 LayerImpl* child1 = child1_ptr.get();
2999 scoped_ptr<LayerImpl> child2_ptr(
3000 LayerImpl::Create(host_impl.active_tree(), 4));
3001 LayerImpl* child2 = child2_ptr.get();
3002
3003 gfx::Transform identity_matrix;
3004 gfx::Transform below_matrix;
3005 below_matrix.Translate3d(0.f, 0.f, -10.f);
3006 gfx::Transform above_matrix;
3007 above_matrix.Translate3d(0.f, 0.f, 10.f);
3008
3009 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
3010 gfx::PointF(), gfx::Size(100, 100), true, true,
3011 true);
3012 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
3013 gfx::PointF(), gfx::Size(50, 50), true, true,
3014 true);
3015 SetLayerPropertiesForTesting(child1, above_matrix, gfx::Point3F(),
3016 gfx::PointF(), gfx::Size(50, 50), true, true,
3017 false);
3018 SetLayerPropertiesForTesting(child2, below_matrix, gfx::Point3F(),
3019 gfx::PointF(), gfx::Size(50, 50), true, true,
3020 false);
3021
3022 root->Set3dSortingContextId(3);
3023 root->SetDrawsContent(true);
3024 parent->Set3dSortingContextId(7);
3025 parent->SetDrawsContent(true);
3026 child1->Set3dSortingContextId(7);
3027 child1->SetDrawsContent(true);
3028 child2->Set3dSortingContextId(7);
3029 child2->SetDrawsContent(true);
3030
3031 parent->AddChild(child1_ptr.Pass());
3032 parent->AddChild(child2_ptr.Pass());
3033 root->AddChild(parent_ptr.Pass());
3034
3035 LayerImplList render_surface_layer_list;
3036 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
3037 root_ptr.get(), root->bounds(), &render_surface_layer_list);
3038 inputs.can_adjust_raster_scales = true;
3039 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
3040
3041 EXPECT_TRUE(root->render_surface());
3042 EXPECT_EQ(2u, render_surface_layer_list.size());
3043
3044 EXPECT_EQ(3u, parent->render_surface()->layer_list().size());
3045 EXPECT_EQ(child2->id(), parent->render_surface()->layer_list().at(0)->id());
3046 EXPECT_EQ(parent->id(), parent->render_surface()->layer_list().at(1)->id());
3047 EXPECT_EQ(child1->id(), parent->render_surface()->layer_list().at(2)->id());
3048 }
3049
2978 TEST_F(LayerTreeHostCommonTest, 3050 TEST_F(LayerTreeHostCommonTest,
2979 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) { 3051 SingularNonAnimatingTransformDoesNotPreventClearingDrawProperties) {
2980 scoped_refptr<Layer> root = Layer::Create(); 3052 scoped_refptr<Layer> root = Layer::Create();
2981 3053
2982 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); 3054 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
2983 host->SetRootLayer(root); 3055 host->SetRootLayer(root);
2984 3056
2985 gfx::Transform identity_matrix; 3057 gfx::Transform identity_matrix;
2986 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); 3058 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
2987 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); 3059 ASSERT_FALSE(uninvertible_matrix.IsInvertible());
(...skipping 4525 matching lines...) Expand 10 before | Expand all | Expand 10 after
7513 // right clip, our render_surface_layer_list's order should be unaffected. 7585 // right clip, our render_surface_layer_list's order should be unaffected.
7514 EXPECT_EQ(3u, render_surface_layer_list.size()); 7586 EXPECT_EQ(3u, render_surface_layer_list.size());
7515 EXPECT_EQ(root.get(), render_surface_layer_list.at(0)); 7587 EXPECT_EQ(root.get(), render_surface_layer_list.at(0));
7516 EXPECT_EQ(render_surface2.get(), render_surface_layer_list.at(1)); 7588 EXPECT_EQ(render_surface2.get(), render_surface_layer_list.at(1));
7517 EXPECT_EQ(render_surface1.get(), render_surface_layer_list.at(2)); 7589 EXPECT_EQ(render_surface1.get(), render_surface_layer_list.at(2));
7518 EXPECT_TRUE(render_surface_layer_list.at(0)->render_surface()); 7590 EXPECT_TRUE(render_surface_layer_list.at(0)->render_surface());
7519 EXPECT_TRUE(render_surface_layer_list.at(1)->render_surface()); 7591 EXPECT_TRUE(render_surface_layer_list.at(1)->render_surface());
7520 EXPECT_TRUE(render_surface_layer_list.at(2)->render_surface()); 7592 EXPECT_TRUE(render_surface_layer_list.at(2)->render_surface());
7521 } 7593 }
7522 7594
7595 TEST_F(LayerTreeHostCommonTest, DoNotClobberSorting) {
7596 // We rearrange layer list contributions if we have to visit children out of
7597 // order, but it should be a 'stable' rearrangement. That is, the layer list
7598 // additions for a single layer should not be reordered, though their position
7599 // wrt to the contributions due to a sibling may vary.
7600 //
7601 // + root
7602 // + scroll_child
7603 // + top_content
7604 // + bottom_content
7605 // + scroll_parent_border
7606 // + scroll_parent_clip
7607 // + scroll_parent
7608 //
7609 FakeImplProxy proxy;
7610 TestSharedBitmapManager shared_bitmap_manager;
7611 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
7612 host_impl.CreatePendingTree();
7613 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
7614 scoped_ptr<LayerImpl> scroll_parent_border =
7615 LayerImpl::Create(host_impl.active_tree(), 2);
7616 scoped_ptr<LayerImpl> scroll_parent_clip =
7617 LayerImpl::Create(host_impl.active_tree(), 3);
7618 scoped_ptr<LayerImpl> scroll_parent =
7619 LayerImpl::Create(host_impl.active_tree(), 4);
7620 scoped_ptr<LayerImpl> scroll_child =
7621 LayerImpl::Create(host_impl.active_tree(), 5);
7622 scoped_ptr<LayerImpl> bottom_content =
7623 LayerImpl::Create(host_impl.active_tree(), 6);
7624 scoped_ptr<LayerImpl> top_content =
7625 LayerImpl::Create(host_impl.active_tree(), 7);
7626
7627 scroll_parent_clip->SetMasksToBounds(true);
7628
7629 scroll_child->SetScrollParent(scroll_parent.get());
7630 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>);
7631 scroll_children->insert(scroll_child.get());
7632 scroll_parent->SetScrollChildren(scroll_children.release());
7633
7634 scroll_child->SetDrawsContent(true);
7635 scroll_parent->SetDrawsContent(true);
7636 top_content->SetDrawsContent(true);
7637 bottom_content->SetDrawsContent(true);
7638
7639 gfx::Transform identity_transform;
7640 gfx::Transform top_transform;
7641 top_transform.Translate3d(0.0, 0.0, 5.0);
7642 gfx::Transform bottom_transform;
7643 bottom_transform.Translate3d(0.0, 0.0, 3.0);
7644
7645 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
7646 gfx::PointF(), gfx::Size(50, 50), true, false,
7647 true);
7648 SetLayerPropertiesForTesting(scroll_parent_border.get(), identity_transform,
7649 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
7650 true, false, false);
7651 SetLayerPropertiesForTesting(scroll_parent_clip.get(), identity_transform,
7652 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30),
7653 true, false, false);
7654 SetLayerPropertiesForTesting(scroll_parent.get(), identity_transform,
7655 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
7656 true, false, false);
7657 SetLayerPropertiesForTesting(scroll_child.get(), identity_transform,
7658 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
7659 true, false, false);
7660 SetLayerPropertiesForTesting(top_content.get(), top_transform, gfx::Point3F(),
7661 gfx::PointF(), gfx::Size(50, 50), false, true,
7662 true);
7663 SetLayerPropertiesForTesting(bottom_content.get(), bottom_transform,
7664 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
7665 false, true, true);
7666
7667 scroll_child->SetShouldFlattenTransform(false);
7668 scroll_child->Set3dSortingContextId(1);
7669
7670 scroll_child->AddChild(top_content.Pass());
7671 scroll_child->AddChild(bottom_content.Pass());
7672 root->AddChild(scroll_child.Pass());
7673
7674 scroll_parent_clip->AddChild(scroll_parent.Pass());
7675 scroll_parent_border->AddChild(scroll_parent_clip.Pass());
7676 root->AddChild(scroll_parent_border.Pass());
7677
7678 LayerImplList render_surface_layer_list;
7679 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7680 root.get(), root->bounds(), &render_surface_layer_list);
7681
7682 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7683
7684 EXPECT_TRUE(root->render_surface());
7685
7686 // If we don't sort by depth and let the layers get added in the order they
7687 // would normally be visited in, then layers 6 and 7 will be out of order. In
7688 // other words, although we've had to shift 5, 6, and 7 to appear before 4
7689 // in the list (because of the scroll parent relationship), this should not
7690 // have an effect on the the order of 5, 6, and 7 (which had been reordered
7691 // due to layer sorting).
7692 EXPECT_EQ(4u, root->render_surface()->layer_list().size());
7693 EXPECT_EQ(5, root->render_surface()->layer_list().at(0)->id());
7694 EXPECT_EQ(6, root->render_surface()->layer_list().at(1)->id());
7695 EXPECT_EQ(7, root->render_surface()->layer_list().at(2)->id());
7696 EXPECT_EQ(4, root->render_surface()->layer_list().at(3)->id());
7697 }
7698
7523 TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) { 7699 TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) {
7524 // This test verifies that a scrolling layer that gets snapped to 7700 // This test verifies that a scrolling layer that gets snapped to
7525 // integer coordinates doesn't move a fixed position child. 7701 // integer coordinates doesn't move a fixed position child.
7526 // 7702 //
7527 // + root 7703 // + root
7528 // + container 7704 // + container
7529 // + scroller 7705 // + scroller
7530 // + fixed 7706 // + fixed
7531 // 7707 //
7532 FakeImplProxy proxy; 7708 FakeImplProxy proxy;
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after
8669 host->SetRootLayer(root); 8845 host->SetRootLayer(root);
8670 8846
8671 ExecuteCalculateDrawProperties(root.get()); 8847 ExecuteCalculateDrawProperties(root.get());
8672 8848
8673 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), 8849 EXPECT_EQ(gfx::Rect(0, 0, 50, 50),
8674 grandchild->visible_rect_from_property_trees()); 8850 grandchild->visible_rect_from_property_trees());
8675 } 8851 }
8676 8852
8677 } // namespace 8853 } // namespace
8678 } // namespace cc 8854 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_perftest.cc ('k') | cc/trees/layer_tree_host_pixeltest_filters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698