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

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 1697613002: cc :: Move tracking of layer_property_changed to main thread (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/layers/layer_impl_unittest.cc ('k') | cc/layers/picture_layer_impl_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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 886 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
887 887
888 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); 888 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
889 test_layer->SetLayerTreeHost(nullptr); 889 test_layer->SetLayerTreeHost(nullptr);
890 } 890 }
891 891
892 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { 892 TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
893 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); 893 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1));
894 scoped_refptr<Layer> root = Layer::Create(layer_settings_); 894 scoped_refptr<Layer> root = Layer::Create(layer_settings_);
895 scoped_refptr<Layer> child = Layer::Create(layer_settings_); 895 scoped_refptr<Layer> child = Layer::Create(layer_settings_);
896 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_);
896 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings_); 897 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings_);
897 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); 898 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_);
898 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); 899 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_);
899 900
900 layer_tree_host_->SetRootLayer(root); 901 layer_tree_host_->SetRootLayer(root);
901 root->AddChild(child); 902 root->AddChild(child);
903 root->AddChild(child2);
902 child->AddChild(grand_child); 904 child->AddChild(grand_child);
905 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
906 child->SetForceRenderSurface(true);
907 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1));
908 child2->SetScrollParent(grand_child.get());
903 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; 909 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode;
904 scoped_ptr<LayerImpl> root_impl = 910 scoped_ptr<LayerImpl> root_impl =
905 LayerImpl::Create(host_impl_.active_tree(), 1); 911 LayerImpl::Create(host_impl_.active_tree(), 1);
906 scoped_ptr<LayerImpl> child_impl = 912 scoped_ptr<LayerImpl> child_impl =
907 LayerImpl::Create(host_impl_.active_tree(), 2); 913 LayerImpl::Create(host_impl_.active_tree(), 2);
914 scoped_ptr<LayerImpl> child2_impl =
915 LayerImpl::Create(host_impl_.active_tree(), 3);
908 scoped_ptr<LayerImpl> grand_child_impl = 916 scoped_ptr<LayerImpl> grand_child_impl =
909 LayerImpl::Create(host_impl_.active_tree(), 3); 917 LayerImpl::Create(host_impl_.active_tree(), 4);
910 scoped_ptr<LayerImpl> dummy_layer1_impl = 918 scoped_ptr<LayerImpl> dummy_layer1_impl =
911 LayerImpl::Create(host_impl_.active_tree(), 4); 919 LayerImpl::Create(host_impl_.active_tree(), 5);
912 scoped_ptr<LayerImpl> dummy_layer2_impl = 920 scoped_ptr<LayerImpl> dummy_layer2_impl =
913 LayerImpl::Create(host_impl_.active_tree(), 5); 921 LayerImpl::Create(host_impl_.active_tree(), 6);
914 922
915 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); 923 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1);
916 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); 924 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get()));
917 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 925 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
918 root->PushPropertiesTo(root_impl.get()); 926 root->PushPropertiesTo(root_impl.get());
919 child->PushPropertiesTo(child_impl.get()); 927 child->PushPropertiesTo(child_impl.get());
928 child2->PushPropertiesTo(child2_impl.get());
920 grand_child->PushPropertiesTo(grand_child_impl.get()); 929 grand_child->PushPropertiesTo(grand_child_impl.get());
921 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); 930 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get()));
922 931
923 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 932 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
924 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); 933 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true));
925 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 934 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
926 root->PushPropertiesTo(root_impl.get()); 935 root->PushPropertiesTo(root_impl.get());
927 child->PushPropertiesTo(child_impl.get()); 936 child->PushPropertiesTo(child_impl.get());
937 child2->PushPropertiesTo(child2_impl.get());
928 grand_child->PushPropertiesTo(grand_child_impl.get())); 938 grand_child->PushPropertiesTo(grand_child_impl.get()));
929 939
930 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 940 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
931 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); 941 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true));
932 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 942 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
933 root->PushPropertiesTo(root_impl.get()); 943 root->PushPropertiesTo(root_impl.get());
934 child->PushPropertiesTo(child_impl.get()); 944 child->PushPropertiesTo(child_impl.get());
945 child2->PushPropertiesTo(child2_impl.get());
935 grand_child->PushPropertiesTo(grand_child_impl.get())); 946 grand_child->PushPropertiesTo(grand_child_impl.get()));
936 947
937 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); 948 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1);
938 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get())); 949 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get()));
939 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 950 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
940 root->PushPropertiesTo(root_impl.get()); 951 root->PushPropertiesTo(root_impl.get());
941 child->PushPropertiesTo(child_impl.get()); 952 child->PushPropertiesTo(child_impl.get());
953 child2->PushPropertiesTo(child2_impl.get());
942 grand_child->PushPropertiesTo(grand_child_impl.get()); 954 grand_child->PushPropertiesTo(grand_child_impl.get());
943 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get())); 955 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get()));
944 956
945 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 957 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
946 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); 958 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false));
947 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 959 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
948 root->PushPropertiesTo(root_impl.get()); 960 root->PushPropertiesTo(root_impl.get());
949 child->PushPropertiesTo(child_impl.get()); 961 child->PushPropertiesTo(child_impl.get());
962 child2->PushPropertiesTo(child2_impl.get());
950 grand_child->PushPropertiesTo(grand_child_impl.get())); 963 grand_child->PushPropertiesTo(grand_child_impl.get()));
951 964
952 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 965 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
953 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->Set3dSortingContextId(1)); 966 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->Set3dSortingContextId(1));
954 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 967 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
955 root->PushPropertiesTo(root_impl.get()); 968 root->PushPropertiesTo(root_impl.get());
956 child->PushPropertiesTo(child_impl.get()); 969 child->PushPropertiesTo(child_impl.get());
970 child2->PushPropertiesTo(child2_impl.get());
957 grand_child->PushPropertiesTo(grand_child_impl.get()); 971 grand_child->PushPropertiesTo(grand_child_impl.get());
958 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get())); 972 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get()));
959 973
960 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 974 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
961 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetDoubleSided(false)); 975 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetDoubleSided(false));
962 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 976 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
963 root->PushPropertiesTo(root_impl.get()); 977 root->PushPropertiesTo(root_impl.get());
964 child->PushPropertiesTo(child_impl.get()); 978 child->PushPropertiesTo(child_impl.get());
979 child2->PushPropertiesTo(child2_impl.get());
965 grand_child->PushPropertiesTo(grand_child_impl.get())); 980 grand_child->PushPropertiesTo(grand_child_impl.get()));
966 981
967 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 982 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
968 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetHideLayerAndSubtree(true)); 983 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetHideLayerAndSubtree(true));
969 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( 984 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
970 root->PushPropertiesTo(root_impl.get()); 985 root->PushPropertiesTo(root_impl.get());
971 child->PushPropertiesTo(child_impl.get()); 986 child->PushPropertiesTo(child_impl.get());
987 child2->PushPropertiesTo(child2_impl.get());
972 grand_child->PushPropertiesTo(grand_child_impl.get())); 988 grand_child->PushPropertiesTo(grand_child_impl.get()));
973 989
974 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); 990 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
975 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBlendMode(arbitrary_blend_mode)); 991 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBlendMode(arbitrary_blend_mode));
992 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
993 root->PushPropertiesTo(root_impl.get());
994 child->PushPropertiesTo(child_impl.get());
995 child2->PushPropertiesTo(child2_impl.get());
996 grand_child->PushPropertiesTo(grand_child_impl.get()));
997
998 // Should be a different size than previous call, to ensure it marks tree
999 // changed.
1000 gfx::Size arbitrary_size = gfx::Size(111, 222);
1001 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1002 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBounds(arbitrary_size));
1003 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1004 root->PushPropertiesTo(root_impl.get());
1005 child->PushPropertiesTo(child_impl.get());
1006 child2->PushPropertiesTo(child2_impl.get());
1007 grand_child->PushPropertiesTo(grand_child_impl.get()));
1008
1009 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
1010 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1011 root->SetPosition(arbitrary_point_f);
1012 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node(
1013 root->transform_tree_index());
1014 EXPECT_TRUE(node->data.transform_changed);
1015 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1016 root->PushPropertiesTo(root_impl.get());
1017 child->PushPropertiesTo(child_impl.get());
1018 child2->PushPropertiesTo(child2_impl.get());
1019 grand_child->PushPropertiesTo(grand_child_impl.get());
1020 layer_tree_host_->property_trees()->transform_tree.ResetChangeTracking());
1021 EXPECT_FALSE(node->data.transform_changed);
1022
1023 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1024 child->SetPosition(arbitrary_point_f);
1025 node = layer_tree_host_->property_trees()->transform_tree.Node(
1026 child->transform_tree_index());
1027 EXPECT_TRUE(node->data.transform_changed);
1028 // child2 is not in the subtree of child, but its scroll parent is. So, its
1029 // to_screen will be effected by change in position of child2.
1030 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms(
1031 child2->transform_tree_index());
1032 node = layer_tree_host_->property_trees()->transform_tree.Node(
1033 child2->transform_tree_index());
1034 EXPECT_TRUE(node->data.transform_changed);
1035 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
1036 child->PushPropertiesTo(child_impl.get());
1037 grand_child->PushPropertiesTo(grand_child_impl.get());
1038 layer_tree_host_->property_trees()->transform_tree.ResetChangeTracking());
1039 node = layer_tree_host_->property_trees()->transform_tree.Node(
1040 child->transform_tree_index());
1041 EXPECT_FALSE(node->data.transform_changed);
1042
1043 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
1044 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1045 root->SetTransformOrigin(arbitrary_point_3f);
1046 node = layer_tree_host_->property_trees()->transform_tree.Node(
1047 root->transform_tree_index());
1048 EXPECT_TRUE(node->data.transform_changed);
976 } 1049 }
977 1050
978 TEST_F(LayerTest, AddAndRemoveChild) { 1051 TEST_F(LayerTest, AddAndRemoveChild) {
979 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); 1052 scoped_refptr<Layer> parent = Layer::Create(layer_settings_);
980 scoped_refptr<Layer> child = Layer::Create(layer_settings_); 1053 scoped_refptr<Layer> child = Layer::Create(layer_settings_);
981 1054
982 // Upon creation, layers should not have children or parent. 1055 // Upon creation, layers should not have children or parent.
983 ASSERT_EQ(0U, parent->children().size()); 1056 ASSERT_EQ(0U, parent->children().size());
984 EXPECT_FALSE(child->parent()); 1057 EXPECT_FALSE(child->parent());
985 1058
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2691 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2619 2692
2620 test_layer->PushPropertiesTo(impl_layer.get()); 2693 test_layer->PushPropertiesTo(impl_layer.get());
2621 2694
2622 EXPECT_EQ(2lu, impl_layer->element_id()); 2695 EXPECT_EQ(2lu, impl_layer->element_id());
2623 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2696 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2624 } 2697 }
2625 2698
2626 } // namespace 2699 } // namespace
2627 } // namespace cc 2700 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl_unittest.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698