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

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

Issue 2655233006: cc : Clean up cc clip tree (Closed)
Patch Set: blink_tests 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
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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 root_->AddChild(child_); 796 root_->AddChild(child_);
797 layer_tree_host()->SetRootLayer(root_); 797 layer_tree_host()->SetRootLayer(root_);
798 LayerTreeHostTest::SetupTree(); 798 LayerTreeHostTest::SetupTree();
799 } 799 }
800 800
801 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 801 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
802 802
803 void DidCommit() override { 803 void DidCommit() override {
804 switch (layer_tree_host()->SourceFrameNumber()) { 804 switch (layer_tree_host()->SourceFrameNumber()) {
805 case 1: 805 case 1:
806 // child_ should create transform, effect, clip node. 806 // child_ should create transform, effect node.
807 child_->SetForceRenderSurfaceForTesting(true); 807 child_->SetForceRenderSurfaceForTesting(true);
808 break; 808 break;
809 case 2: 809 case 2:
810 // child_ should create a scroll node. 810 // child_ should create a scroll node.
811 child_->SetScrollClipLayerId(root_->id()); 811 child_->SetScrollClipLayerId(root_->id());
812 break; 812 break;
813 case 3: 813 case 3:
814 // child_ should create a clip node.
815 child_->SetMasksToBounds(true);
816 break;
817 case 4:
814 // child_ should not create any property tree node. 818 // child_ should not create any property tree node.
819 child_->SetMasksToBounds(false);
815 child_->SetForceRenderSurfaceForTesting(false); 820 child_->SetForceRenderSurfaceForTesting(false);
816 child_->SetScrollClipLayerId(Layer::INVALID_ID); 821 child_->SetScrollClipLayerId(Layer::INVALID_ID);
817 } 822 }
818 } 823 }
819 824
820 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { 825 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
821 PropertyTrees* property_trees = impl->sync_tree()->property_trees(); 826 PropertyTrees* property_trees = impl->sync_tree()->property_trees();
822 auto root_transform_id_to_index = 827 auto root_transform_id_to_index =
823 property_trees->layer_id_to_transform_node_index.find(root_->id()); 828 property_trees->layer_id_to_transform_node_index.find(root_->id());
824 auto child_transform_id_to_index = 829 auto child_transform_id_to_index =
825 property_trees->layer_id_to_transform_node_index.find(child_->id()); 830 property_trees->layer_id_to_transform_node_index.find(child_->id());
826 auto root_effect_id_to_index = 831 auto root_effect_id_to_index =
827 property_trees->layer_id_to_effect_node_index.find(root_->id()); 832 property_trees->layer_id_to_effect_node_index.find(root_->id());
828 auto child_effect_id_to_index = 833 auto child_effect_id_to_index =
829 property_trees->layer_id_to_effect_node_index.find(child_->id()); 834 property_trees->layer_id_to_effect_node_index.find(child_->id());
830 auto root_clip_id_to_index = 835 auto root_clip_id_to_index =
831 property_trees->layer_id_to_clip_node_index.find(root_->id()); 836 property_trees->layer_id_to_clip_node_index.find(root_->id());
832 auto child_clip_id_to_index = 837 auto child_clip_id_to_index =
833 property_trees->layer_id_to_clip_node_index.find(child_->id()); 838 property_trees->layer_id_to_clip_node_index.find(child_->id());
834 auto root_scroll_id_to_index = 839 auto root_scroll_id_to_index =
835 property_trees->layer_id_to_scroll_node_index.find(root_->id()); 840 property_trees->layer_id_to_scroll_node_index.find(root_->id());
836 auto child_scroll_id_to_index = 841 auto child_scroll_id_to_index =
837 property_trees->layer_id_to_scroll_node_index.find(child_->id()); 842 property_trees->layer_id_to_scroll_node_index.find(child_->id());
838 switch (impl->sync_tree()->source_frame_number()) { 843 switch (impl->sync_tree()->source_frame_number()) {
839 case 0: 844 case 0:
840 // root_ should create every property tree node and child_ should not 845 // root_ should create transform, scroll and effect tree nodes but not
841 // create any. 846 // a clip node.
842 EXPECT_NE(root_transform_id_to_index, 847 EXPECT_NE(root_transform_id_to_index,
843 property_trees->layer_id_to_transform_node_index.end()); 848 property_trees->layer_id_to_transform_node_index.end());
844 EXPECT_EQ(root_transform_id_to_index->second, 849 EXPECT_EQ(root_transform_id_to_index->second,
845 root_->transform_tree_index()); 850 root_->transform_tree_index());
846 EXPECT_NE(root_effect_id_to_index, 851 EXPECT_NE(root_effect_id_to_index,
847 property_trees->layer_id_to_effect_node_index.end()); 852 property_trees->layer_id_to_effect_node_index.end());
848 EXPECT_EQ(root_effect_id_to_index->second, root_->effect_tree_index()); 853 EXPECT_EQ(root_effect_id_to_index->second, root_->effect_tree_index());
849 EXPECT_NE(root_clip_id_to_index,
850 property_trees->layer_id_to_clip_node_index.end());
851 EXPECT_EQ(root_clip_id_to_index->second, root_->clip_tree_index());
852 EXPECT_NE(root_scroll_id_to_index, 854 EXPECT_NE(root_scroll_id_to_index,
853 property_trees->layer_id_to_scroll_node_index.end()); 855 property_trees->layer_id_to_scroll_node_index.end());
854 EXPECT_EQ(root_scroll_id_to_index->second, root_->scroll_tree_index()); 856 EXPECT_EQ(root_scroll_id_to_index->second, root_->scroll_tree_index());
857 EXPECT_EQ(root_clip_id_to_index,
858 property_trees->layer_id_to_clip_node_index.end());
855 EXPECT_EQ(child_transform_id_to_index, 859 EXPECT_EQ(child_transform_id_to_index,
856 property_trees->layer_id_to_transform_node_index.end()); 860 property_trees->layer_id_to_transform_node_index.end());
857 EXPECT_EQ(child_effect_id_to_index, 861 EXPECT_EQ(child_effect_id_to_index,
858 property_trees->layer_id_to_effect_node_index.end()); 862 property_trees->layer_id_to_effect_node_index.end());
859 EXPECT_EQ(child_clip_id_to_index, 863 EXPECT_EQ(child_clip_id_to_index,
860 property_trees->layer_id_to_clip_node_index.end()); 864 property_trees->layer_id_to_clip_node_index.end());
861 EXPECT_EQ(child_scroll_id_to_index, 865 EXPECT_EQ(child_scroll_id_to_index,
862 property_trees->layer_id_to_scroll_node_index.end()); 866 property_trees->layer_id_to_scroll_node_index.end());
863 break; 867 break;
864 case 1: 868 case 1:
865 // child_ should create a transfrom, clip, effect nodes but not a scroll 869 // child_ should create a transfrom, effect nodes but not a scroll, clip
866 // node. 870 // node.
867 EXPECT_NE( 871 EXPECT_NE(
868 property_trees->layer_id_to_transform_node_index.find(child_->id()), 872 property_trees->layer_id_to_transform_node_index.find(child_->id()),
869 property_trees->layer_id_to_transform_node_index.end()); 873 property_trees->layer_id_to_transform_node_index.end());
870 EXPECT_EQ(child_transform_id_to_index->second, 874 EXPECT_EQ(child_transform_id_to_index->second,
871 child_->transform_tree_index()); 875 child_->transform_tree_index());
872 EXPECT_NE( 876 EXPECT_NE(
873 property_trees->layer_id_to_effect_node_index.find(child_->id()), 877 property_trees->layer_id_to_effect_node_index.find(child_->id()),
874 property_trees->layer_id_to_effect_node_index.end()); 878 property_trees->layer_id_to_effect_node_index.end());
875 EXPECT_EQ(child_effect_id_to_index->second, 879 EXPECT_EQ(child_effect_id_to_index->second,
876 child_->effect_tree_index()); 880 child_->effect_tree_index());
877 EXPECT_NE( 881 EXPECT_EQ(
878 property_trees->layer_id_to_clip_node_index.find(child_->id()), 882 property_trees->layer_id_to_clip_node_index.find(child_->id()),
879 property_trees->layer_id_to_clip_node_index.end()); 883 property_trees->layer_id_to_clip_node_index.end());
880 EXPECT_EQ(child_clip_id_to_index->second, child_->clip_tree_index());
881 EXPECT_EQ( 884 EXPECT_EQ(
882 property_trees->layer_id_to_scroll_node_index.find(child_->id()), 885 property_trees->layer_id_to_scroll_node_index.find(child_->id()),
883 property_trees->layer_id_to_scroll_node_index.end()); 886 property_trees->layer_id_to_scroll_node_index.end());
884 break; 887 break;
885 case 2: 888 case 2:
886 // child_ should create a scroll node. 889 // child_ should create a scroll node.
887 EXPECT_NE( 890 EXPECT_NE(
888 property_trees->layer_id_to_scroll_node_index.find(child_->id()), 891 property_trees->layer_id_to_scroll_node_index.find(child_->id()),
889 property_trees->layer_id_to_scroll_node_index.end()); 892 property_trees->layer_id_to_scroll_node_index.end());
890 EXPECT_EQ(child_scroll_id_to_index->second, 893 EXPECT_EQ(child_scroll_id_to_index->second,
891 child_->scroll_tree_index()); 894 child_->scroll_tree_index());
892 break; 895 break;
893 case 3: 896 case 3:
897 // child_ should create a clip node.
898 EXPECT_NE(
899 property_trees->layer_id_to_clip_node_index.find(child_->id()),
900 property_trees->layer_id_to_clip_node_index.end());
901 EXPECT_EQ(child_clip_id_to_index->second, child_->clip_tree_index());
902 break;
903 case 4:
894 // child_ should not create any property tree nodes. 904 // child_ should not create any property tree nodes.
895 EXPECT_EQ( 905 EXPECT_EQ(
896 property_trees->layer_id_to_transform_node_index.find(child_->id()), 906 property_trees->layer_id_to_transform_node_index.find(child_->id()),
897 property_trees->layer_id_to_transform_node_index.end()); 907 property_trees->layer_id_to_transform_node_index.end());
898 EXPECT_EQ( 908 EXPECT_EQ(
899 property_trees->layer_id_to_effect_node_index.find(child_->id()), 909 property_trees->layer_id_to_effect_node_index.find(child_->id()),
900 property_trees->layer_id_to_effect_node_index.end()); 910 property_trees->layer_id_to_effect_node_index.end());
901 EXPECT_EQ( 911 EXPECT_EQ(
902 property_trees->layer_id_to_clip_node_index.find(child_->id()), 912 property_trees->layer_id_to_clip_node_index.find(child_->id()),
903 property_trees->layer_id_to_clip_node_index.end()); 913 property_trees->layer_id_to_clip_node_index.end());
(...skipping 6272 matching lines...) Expand 10 before | Expand all | Expand 10 after
7176 7186
7177 private: 7187 private:
7178 bool first_ = true; 7188 bool first_ = true;
7179 SkBitmap bitmap_; 7189 SkBitmap bitmap_;
7180 }; 7190 };
7181 7191
7182 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestQueueImageDecodeNonLazy); 7192 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestQueueImageDecodeNonLazy);
7183 7193
7184 } // namespace 7194 } // namespace
7185 } // namespace cc 7195 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698