OLD | NEW |
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 #include <tuple> |
9 | 10 |
10 #include "cc/animation/layer_animation_controller.h" | 11 #include "cc/animation/layer_animation_controller.h" |
11 #include "cc/animation/transform_operations.h" | 12 #include "cc/animation/transform_operations.h" |
12 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
13 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
14 #include "cc/layers/content_layer_client.h" | 15 #include "cc/layers/content_layer_client.h" |
15 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
16 #include "cc/layers/layer_client.h" | 17 #include "cc/layers/layer_client.h" |
17 #include "cc/layers/layer_impl.h" | 18 #include "cc/layers/layer_impl.h" |
18 #include "cc/layers/layer_iterator.h" | 19 #include "cc/layers/layer_iterator.h" |
(...skipping 7484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7503 // right clip, our render_surface_layer_list's order should be unaffected. | 7504 // right clip, our render_surface_layer_list's order should be unaffected. |
7504 EXPECT_EQ(3u, render_surface_layer_list.size()); | 7505 EXPECT_EQ(3u, render_surface_layer_list.size()); |
7505 EXPECT_EQ(root.get(), render_surface_layer_list.at(0)); | 7506 EXPECT_EQ(root.get(), render_surface_layer_list.at(0)); |
7506 EXPECT_EQ(render_surface2.get(), render_surface_layer_list.at(1)); | 7507 EXPECT_EQ(render_surface2.get(), render_surface_layer_list.at(1)); |
7507 EXPECT_EQ(render_surface1.get(), render_surface_layer_list.at(2)); | 7508 EXPECT_EQ(render_surface1.get(), render_surface_layer_list.at(2)); |
7508 EXPECT_TRUE(render_surface_layer_list.at(0)->render_surface()); | 7509 EXPECT_TRUE(render_surface_layer_list.at(0)->render_surface()); |
7509 EXPECT_TRUE(render_surface_layer_list.at(1)->render_surface()); | 7510 EXPECT_TRUE(render_surface_layer_list.at(1)->render_surface()); |
7510 EXPECT_TRUE(render_surface_layer_list.at(2)->render_surface()); | 7511 EXPECT_TRUE(render_surface_layer_list.at(2)->render_surface()); |
7511 } | 7512 } |
7512 | 7513 |
7513 TEST_F(LayerTreeHostCommonTest, DoNotClobberSorting) { | |
7514 // We rearrange layer list contributions if we have to visit children out of | |
7515 // order, but it should be a 'stable' rearrangement. That is, the layer list | |
7516 // additions for a single layer should not be reordered, though their position | |
7517 // wrt to the contributions due to a sibling may vary. | |
7518 // | |
7519 // + root | |
7520 // + scroll_child | |
7521 // + top_content | |
7522 // + bottom_content | |
7523 // + scroll_parent_border | |
7524 // + scroll_parent_clip | |
7525 // + scroll_parent | |
7526 // | |
7527 FakeImplProxy proxy; | |
7528 TestSharedBitmapManager shared_bitmap_manager; | |
7529 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | |
7530 host_impl.CreatePendingTree(); | |
7531 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | |
7532 scoped_ptr<LayerImpl> scroll_parent_border = | |
7533 LayerImpl::Create(host_impl.active_tree(), 2); | |
7534 scoped_ptr<LayerImpl> scroll_parent_clip = | |
7535 LayerImpl::Create(host_impl.active_tree(), 3); | |
7536 scoped_ptr<LayerImpl> scroll_parent = | |
7537 LayerImpl::Create(host_impl.active_tree(), 4); | |
7538 scoped_ptr<LayerImpl> scroll_child = | |
7539 LayerImpl::Create(host_impl.active_tree(), 5); | |
7540 scoped_ptr<LayerImpl> bottom_content = | |
7541 LayerImpl::Create(host_impl.active_tree(), 6); | |
7542 scoped_ptr<LayerImpl> top_content = | |
7543 LayerImpl::Create(host_impl.active_tree(), 7); | |
7544 | |
7545 scroll_parent_clip->SetMasksToBounds(true); | |
7546 | |
7547 scroll_child->SetScrollParent(scroll_parent.get()); | |
7548 scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); | |
7549 scroll_children->insert(scroll_child.get()); | |
7550 scroll_parent->SetScrollChildren(scroll_children.release()); | |
7551 | |
7552 scroll_child->SetDrawsContent(true); | |
7553 scroll_parent->SetDrawsContent(true); | |
7554 top_content->SetDrawsContent(true); | |
7555 bottom_content->SetDrawsContent(true); | |
7556 | |
7557 gfx::Transform identity_transform; | |
7558 gfx::Transform top_transform; | |
7559 top_transform.Translate3d(0.0, 0.0, 5.0); | |
7560 gfx::Transform bottom_transform; | |
7561 bottom_transform.Translate3d(0.0, 0.0, 3.0); | |
7562 | |
7563 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), | |
7564 gfx::PointF(), gfx::Size(50, 50), true, false, | |
7565 true); | |
7566 SetLayerPropertiesForTesting(scroll_parent_border.get(), identity_transform, | |
7567 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | |
7568 true, false, false); | |
7569 SetLayerPropertiesForTesting(scroll_parent_clip.get(), identity_transform, | |
7570 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
7571 true, false, false); | |
7572 SetLayerPropertiesForTesting(scroll_parent.get(), identity_transform, | |
7573 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
7574 true, false, false); | |
7575 SetLayerPropertiesForTesting(scroll_child.get(), identity_transform, | |
7576 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
7577 true, false, false); | |
7578 SetLayerPropertiesForTesting(top_content.get(), top_transform, gfx::Point3F(), | |
7579 gfx::PointF(), gfx::Size(50, 50), false, true, | |
7580 true); | |
7581 SetLayerPropertiesForTesting(bottom_content.get(), bottom_transform, | |
7582 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
7583 false, true, true); | |
7584 | |
7585 scroll_child->SetShouldFlattenTransform(false); | |
7586 scroll_child->Set3dSortingContextId(1); | |
7587 | |
7588 scroll_child->AddChild(top_content.Pass()); | |
7589 scroll_child->AddChild(bottom_content.Pass()); | |
7590 root->AddChild(scroll_child.Pass()); | |
7591 | |
7592 scroll_parent_clip->AddChild(scroll_parent.Pass()); | |
7593 scroll_parent_border->AddChild(scroll_parent_clip.Pass()); | |
7594 root->AddChild(scroll_parent_border.Pass()); | |
7595 | |
7596 LayerImplList render_surface_layer_list; | |
7597 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | |
7598 root.get(), root->bounds(), &render_surface_layer_list); | |
7599 | |
7600 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
7601 | |
7602 EXPECT_TRUE(root->render_surface()); | |
7603 | |
7604 // If we don't sort by depth and let the layers get added in the order they | |
7605 // would normally be visited in, then layers 6 and 7 will be out of order. In | |
7606 // other words, although we've had to shift 5, 6, and 7 to appear before 4 | |
7607 // in the list (because of the scroll parent relationship), this should not | |
7608 // have an effect on the the order of 5, 6, and 7 (which had been reordered | |
7609 // due to layer sorting). | |
7610 EXPECT_EQ(4u, root->render_surface()->layer_list().size()); | |
7611 EXPECT_EQ(5, root->render_surface()->layer_list().at(0)->id()); | |
7612 EXPECT_EQ(6, root->render_surface()->layer_list().at(1)->id()); | |
7613 EXPECT_EQ(7, root->render_surface()->layer_list().at(2)->id()); | |
7614 EXPECT_EQ(4, root->render_surface()->layer_list().at(3)->id()); | |
7615 } | |
7616 | |
7617 TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) { | 7514 TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) { |
7618 // This test verifies that a scrolling layer that gets snapped to | 7515 // This test verifies that a scrolling layer that gets snapped to |
7619 // integer coordinates doesn't move a fixed position child. | 7516 // integer coordinates doesn't move a fixed position child. |
7620 // | 7517 // |
7621 // + root | 7518 // + root |
7622 // + container | 7519 // + container |
7623 // + scroller | 7520 // + scroller |
7624 // + fixed | 7521 // + fixed |
7625 // | 7522 // |
7626 FakeImplProxy proxy; | 7523 FakeImplProxy proxy; |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8576 | 8473 |
8577 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 8474 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
8578 | 8475 |
8579 gfx::Rect affected_by_delta(0, 0, root_size.width(), | 8476 gfx::Rect affected_by_delta(0, 0, root_size.width(), |
8580 root_size.height() + 50); | 8477 root_size.height() + 50); |
8581 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); | 8478 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); |
8582 } | 8479 } |
8583 | 8480 |
8584 } // namespace | 8481 } // namespace |
8585 } // namespace cc | 8482 } // namespace cc |
OLD | NEW |