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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 10430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10441 child->SetBounds(gfx::Size(20, 20)); | 10441 child->SetBounds(gfx::Size(20, 20)); |
10442 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10442 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
10443 | 10443 |
10444 // Changing the opacity from 1 to non-1 value should trigger rebuild of | 10444 // Changing the opacity from 1 to non-1 value should trigger rebuild of |
10445 // property trees as a new effect node will be created. | 10445 // property trees as a new effect node will be created. |
10446 child->SetOpacity(0.5f); | 10446 child->SetOpacity(0.5f); |
10447 PropertyTrees* property_trees = host()->property_trees(); | 10447 PropertyTrees* property_trees = host()->property_trees(); |
10448 EXPECT_TRUE(property_trees->needs_rebuild); | 10448 EXPECT_TRUE(property_trees->needs_rebuild); |
10449 | 10449 |
10450 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10450 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
10451 EXPECT_NE(property_trees->layer_id_to_effect_node_index.find(child->id()), | 10451 EXPECT_NE(property_trees->effect_tree.FindNodeFromId(child->id()), nullptr); |
10452 property_trees->layer_id_to_effect_node_index.end()); | |
10453 | 10452 |
10454 // child already has an effect node. Changing its opacity shouldn't trigger | 10453 // child already has an effect node. Changing its opacity shouldn't trigger |
10455 // a property trees rebuild. | 10454 // a property trees rebuild. |
10456 child->SetOpacity(0.8f); | 10455 child->SetOpacity(0.8f); |
10457 property_trees = host()->property_trees(); | 10456 property_trees = host()->property_trees(); |
10458 EXPECT_FALSE(property_trees->needs_rebuild); | 10457 EXPECT_FALSE(property_trees->needs_rebuild); |
10459 | 10458 |
10460 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10459 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
10461 EXPECT_NE(property_trees->layer_id_to_effect_node_index.find(child->id()), | 10460 EXPECT_NE(property_trees->effect_tree.FindNodeFromId(child->id()), nullptr); |
10462 property_trees->layer_id_to_effect_node_index.end()); | |
10463 | 10461 |
10464 // Changing the opacity from non-1 value to 1 should trigger a rebuild of | 10462 // Changing the opacity from non-1 value to 1 should trigger a rebuild of |
10465 // property trees as the effect node may no longer be needed. | 10463 // property trees as the effect node may no longer be needed. |
10466 child->SetOpacity(1.f); | 10464 child->SetOpacity(1.f); |
10467 property_trees = host()->property_trees(); | 10465 property_trees = host()->property_trees(); |
10468 EXPECT_TRUE(property_trees->needs_rebuild); | 10466 EXPECT_TRUE(property_trees->needs_rebuild); |
10469 | 10467 |
10470 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 10468 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
10471 EXPECT_EQ(property_trees->layer_id_to_effect_node_index.find(child->id()), | 10469 EXPECT_EQ(property_trees->effect_tree.FindNodeFromId(child->id()), nullptr); |
10472 property_trees->layer_id_to_effect_node_index.end()); | |
10473 } | 10470 } |
10474 | 10471 |
10475 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 10472 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
10476 scoped_refptr<Layer> root = Layer::Create(); | 10473 scoped_refptr<Layer> root = Layer::Create(); |
10477 scoped_refptr<LayerWithForcedDrawsContent> animated = | 10474 scoped_refptr<LayerWithForcedDrawsContent> animated = |
10478 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 10475 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
10479 root->AddChild(animated); | 10476 root->AddChild(animated); |
10480 host()->SetRootLayer(root); | 10477 host()->SetRootLayer(root); |
10481 host()->SetElementIdsForTesting(); | 10478 host()->SetElementIdsForTesting(); |
10482 | 10479 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10683 property_tree_root->transform_id = kRootPropertyTreeNodeId; | 10680 property_tree_root->transform_id = kRootPropertyTreeNodeId; |
10684 | 10681 |
10685 // The node owned by root1 | 10682 // The node owned by root1 |
10686 ScrollNode scroll_root1; | 10683 ScrollNode scroll_root1; |
10687 scroll_root1.id = 1; | 10684 scroll_root1.id = 1; |
10688 scroll_root1.owning_layer_id = root1->id(); | 10685 scroll_root1.owning_layer_id = root1->id(); |
10689 scroll_root1.user_scrollable_horizontal = true; | 10686 scroll_root1.user_scrollable_horizontal = true; |
10690 scroll_root1.user_scrollable_vertical = true; | 10687 scroll_root1.user_scrollable_vertical = true; |
10691 scroll_root1.transform_id = root1->transform_tree_index(); | 10688 scroll_root1.transform_id = root1->transform_tree_index(); |
10692 expected_scroll_tree.Insert(scroll_root1, 0); | 10689 expected_scroll_tree.Insert(scroll_root1, 0); |
| 10690 expected_scroll_tree.InsertOwningIdForNode(expected_scroll_tree.back(), |
| 10691 root1->id()); |
10693 | 10692 |
10694 // The node owned by parent2 | 10693 // The node owned by parent2 |
10695 ScrollNode scroll_parent2; | 10694 ScrollNode scroll_parent2; |
10696 scroll_parent2.id = 2; | 10695 scroll_parent2.id = 2; |
10697 scroll_parent2.owning_layer_id = parent2->id(); | 10696 scroll_parent2.owning_layer_id = parent2->id(); |
10698 scroll_parent2.scrollable = true; | 10697 scroll_parent2.scrollable = true; |
10699 scroll_parent2.main_thread_scrolling_reasons = | 10698 scroll_parent2.main_thread_scrolling_reasons = |
10700 parent2->main_thread_scrolling_reasons(); | 10699 parent2->main_thread_scrolling_reasons(); |
10701 scroll_parent2.scroll_clip_layer_bounds = root1->bounds(); | 10700 scroll_parent2.scroll_clip_layer_bounds = root1->bounds(); |
10702 scroll_parent2.bounds = parent2->bounds(); | 10701 scroll_parent2.bounds = parent2->bounds(); |
10703 scroll_parent2.max_scroll_offset_affected_by_page_scale = true; | 10702 scroll_parent2.max_scroll_offset_affected_by_page_scale = true; |
10704 scroll_parent2.scrolls_inner_viewport = true; | 10703 scroll_parent2.scrolls_inner_viewport = true; |
10705 scroll_parent2.user_scrollable_horizontal = true; | 10704 scroll_parent2.user_scrollable_horizontal = true; |
10706 scroll_parent2.user_scrollable_vertical = true; | 10705 scroll_parent2.user_scrollable_vertical = true; |
10707 scroll_parent2.transform_id = parent2->transform_tree_index(); | 10706 scroll_parent2.transform_id = parent2->transform_tree_index(); |
10708 expected_scroll_tree.Insert(scroll_parent2, 1); | 10707 expected_scroll_tree.Insert(scroll_parent2, 1); |
| 10708 expected_scroll_tree.InsertOwningIdForNode(expected_scroll_tree.back(), |
| 10709 parent2->id()); |
10709 | 10710 |
10710 // The node owned by child6 | 10711 // The node owned by child6 |
10711 ScrollNode scroll_child6; | 10712 ScrollNode scroll_child6; |
10712 scroll_child6.id = 3; | 10713 scroll_child6.id = 3; |
10713 scroll_child6.owning_layer_id = child6->id(); | 10714 scroll_child6.owning_layer_id = child6->id(); |
10714 scroll_child6.main_thread_scrolling_reasons = | 10715 scroll_child6.main_thread_scrolling_reasons = |
10715 child6->main_thread_scrolling_reasons(); | 10716 child6->main_thread_scrolling_reasons(); |
10716 scroll_child6.should_flatten = true; | 10717 scroll_child6.should_flatten = true; |
10717 scroll_child6.user_scrollable_horizontal = true; | 10718 scroll_child6.user_scrollable_horizontal = true; |
10718 scroll_child6.user_scrollable_vertical = true; | 10719 scroll_child6.user_scrollable_vertical = true; |
10719 scroll_child6.transform_id = child6->transform_tree_index(); | 10720 scroll_child6.transform_id = child6->transform_tree_index(); |
10720 expected_scroll_tree.Insert(scroll_child6, 2); | 10721 expected_scroll_tree.Insert(scroll_child6, 2); |
| 10722 expected_scroll_tree.InsertOwningIdForNode(expected_scroll_tree.back(), |
| 10723 child6->id()); |
10721 | 10724 |
10722 // The node owned by child7, child7 also owns a transform node | 10725 // The node owned by child7, child7 also owns a transform node |
10723 ScrollNode scroll_child7; | 10726 ScrollNode scroll_child7; |
10724 scroll_child7.id = 4; | 10727 scroll_child7.id = 4; |
10725 scroll_child7.owning_layer_id = child7->id(); | 10728 scroll_child7.owning_layer_id = child7->id(); |
10726 scroll_child7.scrollable = true; | 10729 scroll_child7.scrollable = true; |
10727 scroll_child7.scroll_clip_layer_bounds = parent3->bounds(); | 10730 scroll_child7.scroll_clip_layer_bounds = parent3->bounds(); |
10728 scroll_child7.bounds = child7->bounds(); | 10731 scroll_child7.bounds = child7->bounds(); |
10729 scroll_child7.user_scrollable_horizontal = true; | 10732 scroll_child7.user_scrollable_horizontal = true; |
10730 scroll_child7.user_scrollable_vertical = true; | 10733 scroll_child7.user_scrollable_vertical = true; |
10731 scroll_child7.transform_id = child7->transform_tree_index(); | 10734 scroll_child7.transform_id = child7->transform_tree_index(); |
10732 expected_scroll_tree.Insert(scroll_child7, 1); | 10735 expected_scroll_tree.Insert(scroll_child7, 1); |
| 10736 expected_scroll_tree.InsertOwningIdForNode(expected_scroll_tree.back(), |
| 10737 child7->id()); |
10733 | 10738 |
10734 // The node owned by grand_child11, grand_child11 also owns a transform node | 10739 // The node owned by grand_child11, grand_child11 also owns a transform node |
10735 ScrollNode scroll_grand_child11; | 10740 ScrollNode scroll_grand_child11; |
10736 scroll_grand_child11.id = 5; | 10741 scroll_grand_child11.id = 5; |
10737 scroll_grand_child11.owning_layer_id = grand_child11->id(); | 10742 scroll_grand_child11.owning_layer_id = grand_child11->id(); |
10738 scroll_grand_child11.scrollable = true; | 10743 scroll_grand_child11.scrollable = true; |
10739 scroll_grand_child11.user_scrollable_horizontal = true; | 10744 scroll_grand_child11.user_scrollable_horizontal = true; |
10740 scroll_grand_child11.user_scrollable_vertical = true; | 10745 scroll_grand_child11.user_scrollable_vertical = true; |
10741 scroll_grand_child11.transform_id = grand_child11->transform_tree_index(); | 10746 scroll_grand_child11.transform_id = grand_child11->transform_tree_index(); |
10742 expected_scroll_tree.Insert(scroll_grand_child11, 4); | 10747 expected_scroll_tree.Insert(scroll_grand_child11, 4); |
| 10748 expected_scroll_tree.InsertOwningIdForNode(expected_scroll_tree.back(), |
| 10749 grand_child11->id()); |
10743 | 10750 |
10744 // The node owned by parent5 | 10751 // The node owned by parent5 |
10745 ScrollNode scroll_parent5; | 10752 ScrollNode scroll_parent5; |
10746 scroll_parent5.id = 8; | 10753 scroll_parent5.id = 8; |
10747 scroll_parent5.owning_layer_id = parent5->id(); | 10754 scroll_parent5.owning_layer_id = parent5->id(); |
10748 scroll_parent5.non_fast_scrollable_region = gfx::Rect(0, 0, 50, 50); | 10755 scroll_parent5.non_fast_scrollable_region = gfx::Rect(0, 0, 50, 50); |
10749 scroll_parent5.bounds = gfx::Size(10, 10); | 10756 scroll_parent5.bounds = gfx::Size(10, 10); |
10750 scroll_parent5.should_flatten = true; | 10757 scroll_parent5.should_flatten = true; |
10751 scroll_parent5.user_scrollable_horizontal = true; | 10758 scroll_parent5.user_scrollable_horizontal = true; |
10752 scroll_parent5.user_scrollable_vertical = true; | 10759 scroll_parent5.user_scrollable_vertical = true; |
10753 scroll_parent5.transform_id = parent5->transform_tree_index(); | 10760 scroll_parent5.transform_id = parent5->transform_tree_index(); |
10754 expected_scroll_tree.Insert(scroll_parent5, 1); | 10761 expected_scroll_tree.Insert(scroll_parent5, 1); |
| 10762 expected_scroll_tree.InsertOwningIdForNode(expected_scroll_tree.back(), |
| 10763 parent5->id()); |
10755 | 10764 |
10756 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); | 10765 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); |
10757 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); | 10766 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); |
10758 expected_scroll_tree.SetScrollOffset(grand_child11->id(), | 10767 expected_scroll_tree.SetScrollOffset(grand_child11->id(), |
10759 gfx::ScrollOffset(0, 0)); | 10768 gfx::ScrollOffset(0, 0)); |
10760 expected_scroll_tree.set_needs_update(false); | 10769 expected_scroll_tree.set_needs_update(false); |
10761 | 10770 |
10762 EXPECT_EQ(expected_scroll_tree, scroll_tree); | 10771 EXPECT_EQ(expected_scroll_tree, scroll_tree); |
10763 | 10772 |
10764 // Check other layers' scroll_tree_index | 10773 // Check other layers' scroll_tree_index |
10765 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); | 10774 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); |
10766 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10775 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10767 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10776 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10768 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10777 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10769 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10778 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10770 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10779 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10771 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10780 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10772 } | 10781 } |
10773 | 10782 |
10774 } // namespace | 10783 } // namespace |
10775 } // namespace cc | 10784 } // namespace cc |
OLD | NEW |