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

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

Issue 2753933005: cc: Move Layer Id to Node Map to Individual Property Tree Private (Closed)
Patch Set: renaming clean up Created 3 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
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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.FindNodeFromOwningLayerId(child->id()),
10452 property_trees->layer_id_to_effect_node_index.end()); 10452 nullptr);
10453 10453
10454 // child already has an effect node. Changing its opacity shouldn't trigger 10454 // child already has an effect node. Changing its opacity shouldn't trigger
10455 // a property trees rebuild. 10455 // a property trees rebuild.
10456 child->SetOpacity(0.8f); 10456 child->SetOpacity(0.8f);
10457 property_trees = host()->property_trees(); 10457 property_trees = host()->property_trees();
10458 EXPECT_FALSE(property_trees->needs_rebuild); 10458 EXPECT_FALSE(property_trees->needs_rebuild);
10459 10459
10460 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 10460 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
10461 EXPECT_NE(property_trees->layer_id_to_effect_node_index.find(child->id()), 10461 EXPECT_NE(property_trees->effect_tree.FindNodeFromOwningLayerId(child->id()),
10462 property_trees->layer_id_to_effect_node_index.end()); 10462 nullptr);
10463 10463
10464 // Changing the opacity from non-1 value to 1 should trigger a rebuild of 10464 // 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. 10465 // property trees as the effect node may no longer be needed.
10466 child->SetOpacity(1.f); 10466 child->SetOpacity(1.f);
10467 property_trees = host()->property_trees(); 10467 property_trees = host()->property_trees();
10468 EXPECT_TRUE(property_trees->needs_rebuild); 10468 EXPECT_TRUE(property_trees->needs_rebuild);
10469 10469
10470 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 10470 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
10471 EXPECT_EQ(property_trees->layer_id_to_effect_node_index.find(child->id()), 10471 EXPECT_EQ(property_trees->effect_tree.FindNodeFromOwningLayerId(child->id()),
10472 property_trees->layer_id_to_effect_node_index.end()); 10472 nullptr);
10473 } 10473 }
10474 10474
10475 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { 10475 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) {
10476 scoped_refptr<Layer> root = Layer::Create(); 10476 scoped_refptr<Layer> root = Layer::Create();
10477 scoped_refptr<LayerWithForcedDrawsContent> animated = 10477 scoped_refptr<LayerWithForcedDrawsContent> animated =
10478 make_scoped_refptr(new LayerWithForcedDrawsContent()); 10478 make_scoped_refptr(new LayerWithForcedDrawsContent());
10479 root->AddChild(animated); 10479 root->AddChild(animated);
10480 host()->SetRootLayer(root); 10480 host()->SetRootLayer(root);
10481 host()->SetElementIdsForTesting(); 10481 host()->SetElementIdsForTesting();
10482 10482
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
10683 property_tree_root->transform_id = kRootPropertyTreeNodeId; 10683 property_tree_root->transform_id = kRootPropertyTreeNodeId;
10684 10684
10685 // The node owned by root1 10685 // The node owned by root1
10686 ScrollNode scroll_root1; 10686 ScrollNode scroll_root1;
10687 scroll_root1.id = 1; 10687 scroll_root1.id = 1;
10688 scroll_root1.owning_layer_id = root1->id(); 10688 scroll_root1.owning_layer_id = root1->id();
10689 scroll_root1.user_scrollable_horizontal = true; 10689 scroll_root1.user_scrollable_horizontal = true;
10690 scroll_root1.user_scrollable_vertical = true; 10690 scroll_root1.user_scrollable_vertical = true;
10691 scroll_root1.transform_id = root1->transform_tree_index(); 10691 scroll_root1.transform_id = root1->transform_tree_index();
10692 expected_scroll_tree.Insert(scroll_root1, 0); 10692 expected_scroll_tree.Insert(scroll_root1, 0);
10693 expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
10694 root1->id());
10693 10695
10694 // The node owned by parent2 10696 // The node owned by parent2
10695 ScrollNode scroll_parent2; 10697 ScrollNode scroll_parent2;
10696 scroll_parent2.id = 2; 10698 scroll_parent2.id = 2;
10697 scroll_parent2.owning_layer_id = parent2->id(); 10699 scroll_parent2.owning_layer_id = parent2->id();
10698 scroll_parent2.scrollable = true; 10700 scroll_parent2.scrollable = true;
10699 scroll_parent2.main_thread_scrolling_reasons = 10701 scroll_parent2.main_thread_scrolling_reasons =
10700 parent2->main_thread_scrolling_reasons(); 10702 parent2->main_thread_scrolling_reasons();
10701 scroll_parent2.scroll_clip_layer_bounds = root1->bounds(); 10703 scroll_parent2.scroll_clip_layer_bounds = root1->bounds();
10702 scroll_parent2.bounds = parent2->bounds(); 10704 scroll_parent2.bounds = parent2->bounds();
10703 scroll_parent2.max_scroll_offset_affected_by_page_scale = true; 10705 scroll_parent2.max_scroll_offset_affected_by_page_scale = true;
10704 scroll_parent2.scrolls_inner_viewport = true; 10706 scroll_parent2.scrolls_inner_viewport = true;
10705 scroll_parent2.user_scrollable_horizontal = true; 10707 scroll_parent2.user_scrollable_horizontal = true;
10706 scroll_parent2.user_scrollable_vertical = true; 10708 scroll_parent2.user_scrollable_vertical = true;
10707 scroll_parent2.transform_id = parent2->transform_tree_index(); 10709 scroll_parent2.transform_id = parent2->transform_tree_index();
10708 expected_scroll_tree.Insert(scroll_parent2, 1); 10710 expected_scroll_tree.Insert(scroll_parent2, 1);
10711 expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
10712 parent2->id());
10709 10713
10710 // The node owned by child6 10714 // The node owned by child6
10711 ScrollNode scroll_child6; 10715 ScrollNode scroll_child6;
10712 scroll_child6.id = 3; 10716 scroll_child6.id = 3;
10713 scroll_child6.owning_layer_id = child6->id(); 10717 scroll_child6.owning_layer_id = child6->id();
10714 scroll_child6.main_thread_scrolling_reasons = 10718 scroll_child6.main_thread_scrolling_reasons =
10715 child6->main_thread_scrolling_reasons(); 10719 child6->main_thread_scrolling_reasons();
10716 scroll_child6.should_flatten = true; 10720 scroll_child6.should_flatten = true;
10717 scroll_child6.user_scrollable_horizontal = true; 10721 scroll_child6.user_scrollable_horizontal = true;
10718 scroll_child6.user_scrollable_vertical = true; 10722 scroll_child6.user_scrollable_vertical = true;
10719 scroll_child6.transform_id = child6->transform_tree_index(); 10723 scroll_child6.transform_id = child6->transform_tree_index();
10720 expected_scroll_tree.Insert(scroll_child6, 2); 10724 expected_scroll_tree.Insert(scroll_child6, 2);
10725 expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
10726 child6->id());
10721 10727
10722 // The node owned by child7, child7 also owns a transform node 10728 // The node owned by child7, child7 also owns a transform node
10723 ScrollNode scroll_child7; 10729 ScrollNode scroll_child7;
10724 scroll_child7.id = 4; 10730 scroll_child7.id = 4;
10725 scroll_child7.owning_layer_id = child7->id(); 10731 scroll_child7.owning_layer_id = child7->id();
10726 scroll_child7.scrollable = true; 10732 scroll_child7.scrollable = true;
10727 scroll_child7.scroll_clip_layer_bounds = parent3->bounds(); 10733 scroll_child7.scroll_clip_layer_bounds = parent3->bounds();
10728 scroll_child7.bounds = child7->bounds(); 10734 scroll_child7.bounds = child7->bounds();
10729 scroll_child7.user_scrollable_horizontal = true; 10735 scroll_child7.user_scrollable_horizontal = true;
10730 scroll_child7.user_scrollable_vertical = true; 10736 scroll_child7.user_scrollable_vertical = true;
10731 scroll_child7.transform_id = child7->transform_tree_index(); 10737 scroll_child7.transform_id = child7->transform_tree_index();
10732 expected_scroll_tree.Insert(scroll_child7, 1); 10738 expected_scroll_tree.Insert(scroll_child7, 1);
10739 expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
10740 child7->id());
10733 10741
10734 // The node owned by grand_child11, grand_child11 also owns a transform node 10742 // The node owned by grand_child11, grand_child11 also owns a transform node
10735 ScrollNode scroll_grand_child11; 10743 ScrollNode scroll_grand_child11;
10736 scroll_grand_child11.id = 5; 10744 scroll_grand_child11.id = 5;
10737 scroll_grand_child11.owning_layer_id = grand_child11->id(); 10745 scroll_grand_child11.owning_layer_id = grand_child11->id();
10738 scroll_grand_child11.scrollable = true; 10746 scroll_grand_child11.scrollable = true;
10739 scroll_grand_child11.user_scrollable_horizontal = true; 10747 scroll_grand_child11.user_scrollable_horizontal = true;
10740 scroll_grand_child11.user_scrollable_vertical = true; 10748 scroll_grand_child11.user_scrollable_vertical = true;
10741 scroll_grand_child11.transform_id = grand_child11->transform_tree_index(); 10749 scroll_grand_child11.transform_id = grand_child11->transform_tree_index();
10742 expected_scroll_tree.Insert(scroll_grand_child11, 4); 10750 expected_scroll_tree.Insert(scroll_grand_child11, 4);
10751 expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
10752 grand_child11->id());
10743 10753
10744 // The node owned by parent5 10754 // The node owned by parent5
10745 ScrollNode scroll_parent5; 10755 ScrollNode scroll_parent5;
10746 scroll_parent5.id = 8; 10756 scroll_parent5.id = 8;
10747 scroll_parent5.owning_layer_id = parent5->id(); 10757 scroll_parent5.owning_layer_id = parent5->id();
10748 scroll_parent5.non_fast_scrollable_region = gfx::Rect(0, 0, 50, 50); 10758 scroll_parent5.non_fast_scrollable_region = gfx::Rect(0, 0, 50, 50);
10749 scroll_parent5.bounds = gfx::Size(10, 10); 10759 scroll_parent5.bounds = gfx::Size(10, 10);
10750 scroll_parent5.should_flatten = true; 10760 scroll_parent5.should_flatten = true;
10751 scroll_parent5.user_scrollable_horizontal = true; 10761 scroll_parent5.user_scrollable_horizontal = true;
10752 scroll_parent5.user_scrollable_vertical = true; 10762 scroll_parent5.user_scrollable_vertical = true;
10753 scroll_parent5.transform_id = parent5->transform_tree_index(); 10763 scroll_parent5.transform_id = parent5->transform_tree_index();
10754 expected_scroll_tree.Insert(scroll_parent5, 1); 10764 expected_scroll_tree.Insert(scroll_parent5, 1);
10765 expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
10766 parent5->id());
10755 10767
10756 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0)); 10768 expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0));
10757 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0)); 10769 expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0));
10758 expected_scroll_tree.SetScrollOffset(grand_child11->id(), 10770 expected_scroll_tree.SetScrollOffset(grand_child11->id(),
10759 gfx::ScrollOffset(0, 0)); 10771 gfx::ScrollOffset(0, 0));
10760 expected_scroll_tree.set_needs_update(false); 10772 expected_scroll_tree.set_needs_update(false);
10761 10773
10762 EXPECT_EQ(expected_scroll_tree, scroll_tree); 10774 EXPECT_EQ(expected_scroll_tree, scroll_tree);
10763 10775
10764 // Check other layers' scroll_tree_index 10776 // Check other layers' scroll_tree_index
10765 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); 10777 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index());
10766 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10778 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10767 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10779 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10768 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10780 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10769 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10781 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10770 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10782 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10771 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10783 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10772 } 10784 }
10773 10785
10774 } // namespace 10786 } // namespace
10775 } // namespace cc 10787 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698