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