Chromium Code Reviews| 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 <set> | 10 #include <set> |
| (...skipping 9775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9786 scroll_and_scale_set.top_controls_delta = 0.9f; | 9786 scroll_and_scale_set.top_controls_delta = 0.9f; |
| 9787 | 9787 |
| 9788 proto::ScrollAndScaleSet proto; | 9788 proto::ScrollAndScaleSet proto; |
| 9789 scroll_and_scale_set.ToProtobuf(&proto); | 9789 scroll_and_scale_set.ToProtobuf(&proto); |
| 9790 ScrollAndScaleSet new_scroll_and_scale_set; | 9790 ScrollAndScaleSet new_scroll_and_scale_set; |
| 9791 new_scroll_and_scale_set.FromProtobuf(proto); | 9791 new_scroll_and_scale_set.FromProtobuf(proto); |
| 9792 | 9792 |
| 9793 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); | 9793 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); |
| 9794 } | 9794 } |
| 9795 | 9795 |
| 9796 TEST_F(LayerTreeHostCommonTest, ScrollTreeBuilderTest) { | |
| 9797 // Test the behavior of scroll tree builder | |
| 9798 // Topology: | |
| 9799 // +root1(1) | |
| 9800 // +--parent2(2)[should_scroll_on_main_thread & scroll_blocks_on] | |
| 9801 // +----child6(6)[should_scroll_on_main_thread] | |
| 9802 // +------grand_child10(10)[should_scroll_on_main_thread] | |
| 9803 // +--parent3(3) | |
| 9804 // +----child7(7)[scrollable] | |
| 9805 // +----child8(8)[scroll_parent=7] | |
| 9806 // +------grand_child11(11)[scrollable] | |
| 9807 // +--parent4(4)[SCROLL_BLOCKS_ON_START_TOUCH] | |
| 9808 // +----child9(9)[SCROLL_BLOCKS_ON_WHEEL_EVENT] | |
| 9809 // +------grand_child12(12) | |
| 9810 // +--parent5(5)[contains_non_fast_scrollable_region] | |
| 9811 // | |
| 9812 // Expected scroll tree topology: | |
| 9813 // +property_tree_root---owner:-1 | |
| 9814 // +--root---owner:1 | |
| 9815 // +----node---owner:2 | |
| 9816 // +------node---owner:6 | |
| 9817 // +----node---owner:7 | |
| 9818 // +------node---owner:11 | |
| 9819 // +----node---owner:4 | |
| 9820 // +------node---owner:9 | |
| 9821 // +----node---owner:5 | |
| 9822 // | |
| 9823 // Extra check: | |
| 9824 // grand_child12.scroll_blocks_on = SCROLL_BLOCKS_ON_START_TOUCH | | |
| 9825 // SCROLL_BLOCKS_ON_WHEEL_EVENT | |
| 9826 scoped_refptr<Layer> root1 = Layer::Create(layer_settings()); | |
| 9827 scoped_refptr<Layer> parent2 = Layer::Create(layer_settings()); | |
| 9828 scoped_refptr<Layer> parent3 = Layer::Create(layer_settings()); | |
| 9829 scoped_refptr<Layer> parent4 = Layer::Create(layer_settings()); | |
| 9830 scoped_refptr<Layer> parent5 = Layer::Create(layer_settings()); | |
| 9831 scoped_refptr<Layer> child6 = Layer::Create(layer_settings()); | |
| 9832 scoped_refptr<Layer> child7 = Layer::Create(layer_settings()); | |
| 9833 scoped_refptr<Layer> child8 = Layer::Create(layer_settings()); | |
| 9834 scoped_refptr<Layer> child9 = Layer::Create(layer_settings()); | |
| 9835 scoped_refptr<Layer> grand_child10 = Layer::Create(layer_settings()); | |
| 9836 scoped_refptr<Layer> grand_child11 = Layer::Create(layer_settings()); | |
| 9837 scoped_refptr<Layer> grand_child12 = Layer::Create(layer_settings()); | |
| 9838 | |
| 9839 root1->AddChild(parent2); | |
| 9840 root1->AddChild(parent3); | |
| 9841 root1->AddChild(parent4); | |
| 9842 root1->AddChild(parent5); | |
| 9843 parent2->AddChild(child6); | |
| 9844 parent3->AddChild(child7); | |
| 9845 parent3->AddChild(child8); | |
| 9846 parent4->AddChild(child9); | |
| 9847 child6->AddChild(grand_child10); | |
| 9848 child8->AddChild(grand_child11); | |
| 9849 child9->AddChild(grand_child12); | |
| 9850 host()->SetRootLayer(root1); | |
| 9851 | |
| 9852 parent2->AddMainThreadScrollingReasons( | |
| 9853 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | |
| 9854 parent2->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); | |
| 9855 child6->AddMainThreadScrollingReasons( | |
| 9856 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | |
| 9857 grand_child10->AddMainThreadScrollingReasons( | |
| 9858 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | |
| 9859 | |
| 9860 child7->SetScrollClipLayerId(root1->id()); | |
| 9861 child8->SetScrollParent(child7.get()); | |
| 9862 grand_child11->SetScrollClipLayerId(root1->id()); | |
| 9863 | |
| 9864 parent4->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH); | |
| 9865 child9->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT); | |
| 9866 | |
| 9867 parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | |
| 9868 | |
| 9869 ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get()); | |
| 9870 | |
| 9871 // Property tree root | |
| 9872 ScrollTree scroll_tree = host()->property_trees()->scroll_tree; | |
| 9873 ScrollTree expected_scroll_tree; | |
| 9874 ScrollNode property_tree_root = *expected_scroll_tree.Node(0); | |
| 9875 property_tree_root.id = 0; | |
| 9876 property_tree_root.parent_id = -1; | |
| 9877 property_tree_root.owner_id = -1; | |
| 9878 property_tree_root.data.scrollable = false; | |
| 9879 property_tree_root.data.should_scroll_on_main_thread = false; | |
| 9880 property_tree_root.data.scroll_blocks_on = SCROLL_BLOCKS_ON_NONE; | |
| 9881 property_tree_root.data.contains_non_fast_scrollable_region = false; | |
| 9882 property_tree_root.data.transform_id = 0; | |
|
jaydasika
2016/01/22 22:28:28
Can you change this to root->transform_tree_index(
| |
| 9883 | |
| 9884 // The node owned by root1 | |
| 9885 ScrollNode scroll_root1; | |
| 9886 scroll_root1.id = 1; | |
| 9887 scroll_root1.owner_id = root1->id(); | |
| 9888 scroll_root1.data.transform_id = 1; | |
| 9889 expected_scroll_tree.Insert(scroll_root1, 0); | |
| 9890 | |
| 9891 // The node owned by parent2 | |
| 9892 ScrollNode scroll_parent2; | |
| 9893 scroll_parent2.id = 2; | |
| 9894 scroll_parent2.owner_id = parent2->id(); | |
| 9895 scroll_parent2.data.should_scroll_on_main_thread = true; | |
| 9896 scroll_parent2.data.scroll_blocks_on = SCROLL_BLOCKS_ON_SCROLL_EVENT; | |
| 9897 scroll_parent2.data.transform_id = 1; | |
| 9898 expected_scroll_tree.Insert(scroll_parent2, 1); | |
| 9899 | |
| 9900 // The node owned by child6 | |
| 9901 ScrollNode scroll_child6; | |
| 9902 scroll_child6.id = 3; | |
| 9903 scroll_child6.owner_id = child6->id(); | |
| 9904 scroll_child6.data.should_scroll_on_main_thread = true; | |
| 9905 scroll_child6.data.scroll_blocks_on = SCROLL_BLOCKS_ON_SCROLL_EVENT; | |
| 9906 scroll_child6.data.transform_id = 1; | |
| 9907 expected_scroll_tree.Insert(scroll_child6, 2); | |
| 9908 | |
| 9909 // The node owned by child7, child7 also owns a transform node | |
| 9910 ScrollNode scroll_child7; | |
| 9911 scroll_child7.id = 4; | |
| 9912 scroll_child7.owner_id = child7->id(); | |
| 9913 scroll_child7.data.scrollable = true; | |
| 9914 scroll_child7.data.transform_id = 2; | |
| 9915 expected_scroll_tree.Insert(scroll_child7, 1); | |
| 9916 | |
| 9917 // The node owned by grand_child11, grand_child11 also owns a transform node | |
| 9918 ScrollNode scroll_grand_child11; | |
| 9919 scroll_grand_child11.id = 5; | |
| 9920 scroll_grand_child11.owner_id = grand_child11->id(); | |
| 9921 scroll_grand_child11.data.scrollable = true; | |
| 9922 scroll_grand_child11.data.transform_id = 3; | |
| 9923 expected_scroll_tree.Insert(scroll_grand_child11, 4); | |
| 9924 | |
| 9925 // The node owned by parent4 | |
| 9926 ScrollNode scroll_parent4; | |
| 9927 scroll_parent4.id = 6; | |
| 9928 scroll_parent4.owner_id = parent4->id(); | |
| 9929 scroll_parent4.data.scroll_blocks_on = SCROLL_BLOCKS_ON_START_TOUCH; | |
| 9930 scroll_parent4.data.transform_id = 1; | |
| 9931 expected_scroll_tree.Insert(scroll_parent4, 1); | |
| 9932 | |
| 9933 // The node owned by child9 | |
| 9934 ScrollNode scroll_child9; | |
| 9935 scroll_child9.id = 7; | |
| 9936 scroll_child9.owner_id = child9->id(); | |
| 9937 scroll_child9.data.scroll_blocks_on = | |
| 9938 SCROLL_BLOCKS_ON_START_TOUCH | SCROLL_BLOCKS_ON_WHEEL_EVENT; | |
| 9939 scroll_child9.data.transform_id = 1; | |
| 9940 expected_scroll_tree.Insert(scroll_child9, 6); | |
| 9941 | |
| 9942 // The node owned by parent5 | |
| 9943 ScrollNode scroll_parent5; | |
| 9944 scroll_parent5.id = 8; | |
| 9945 scroll_parent5.owner_id = parent5->id(); | |
| 9946 scroll_parent5.data.contains_non_fast_scrollable_region = true; | |
| 9947 scroll_parent5.data.transform_id = 1; | |
| 9948 expected_scroll_tree.Insert(scroll_parent5, 1); | |
| 9949 | |
| 9950 expected_scroll_tree.set_needs_update(false); | |
| 9951 | |
| 9952 EXPECT_EQ(expected_scroll_tree, scroll_tree); | |
| 9953 } | |
| 9954 | |
| 9796 } // namespace | 9955 } // namespace |
| 9797 } // namespace cc | 9956 } // namespace cc |
| OLD | NEW |