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

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

Issue 2183923002: Undo scroll snaps in to_parent when NeedsSourceToParentUpdate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit change Created 4 years, 4 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/property_tree_builder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/property_tree.h" 5 #include "cc/trees/property_tree.h"
6 6
7 #include "cc/input/main_thread_scrolling_reason.h" 7 #include "cc/input/main_thread_scrolling_reason.h"
8 #include "cc/proto/property_tree.pb.h" 8 #include "cc/proto/property_tree.pb.h"
9 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
10 #include "cc/trees/clip_node.h" 10 #include "cc/trees/clip_node.h"
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 class PropertyTreeTestNonIntegerTranslationTest : public PropertyTreeTest { 1064 class PropertyTreeTestNonIntegerTranslationTest : public PropertyTreeTest {
1065 protected: 1065 protected:
1066 void StartTest() override { 1066 void StartTest() override {
1067 // This tests that when a node has non-integer translation, the information 1067 // This tests that when a node has non-integer translation, the information
1068 // is propagated to the subtree. 1068 // is propagated to the subtree.
1069 PropertyTrees property_trees; 1069 PropertyTrees property_trees;
1070 TransformTree& tree = property_trees.transform_tree; 1070 TransformTree& tree = property_trees.transform_tree;
1071 1071
1072 int parent = tree.Insert(TransformNode(), 0); 1072 int parent = tree.Insert(TransformNode(), 0);
1073 tree.SetTargetId(parent, parent); 1073 tree.SetTargetId(parent, parent);
1074 tree.Node(parent)->source_node_id = 0;
1074 tree.Node(parent)->local.Translate(1.5f, 1.5f); 1075 tree.Node(parent)->local.Translate(1.5f, 1.5f);
1075 1076
1076 int child = tree.Insert(TransformNode(), parent); 1077 int child = tree.Insert(TransformNode(), parent);
1077 tree.SetTargetId(child, parent); 1078 tree.SetTargetId(child, parent);
1078 tree.Node(child)->local.Translate(1, 1); 1079 tree.Node(child)->local.Translate(1, 1);
1080 tree.Node(child)->source_node_id = parent;
1079 tree.set_needs_update(true); 1081 tree.set_needs_update(true);
1080 SetupTransformTreeForTest(&tree); 1082 SetupTransformTreeForTest(&tree);
1081 draw_property_utils::ComputeTransforms(&tree); 1083 draw_property_utils::ComputeTransforms(&tree);
1082 EXPECT_FALSE( 1084 EXPECT_FALSE(
1083 tree.Node(parent)->node_and_ancestors_have_only_integer_translation); 1085 tree.Node(parent)->node_and_ancestors_have_only_integer_translation);
1084 EXPECT_FALSE( 1086 EXPECT_FALSE(
1085 tree.Node(child)->node_and_ancestors_have_only_integer_translation); 1087 tree.Node(child)->node_and_ancestors_have_only_integer_translation);
1086 1088
1087 tree.Node(parent)->local.Translate(0.5f, 0.5f); 1089 tree.Node(parent)->local.Translate(0.5f, 0.5f);
1088 tree.Node(child)->local.Translate(0.5f, 0.5f); 1090 tree.Node(child)->local.Translate(0.5f, 0.5f);
1091 tree.Node(parent)->needs_local_transform_update = true;
1092 tree.Node(child)->needs_local_transform_update = true;
1089 tree.set_needs_update(true); 1093 tree.set_needs_update(true);
1090 SetupTransformTreeForTest(&tree); 1094 SetupTransformTreeForTest(&tree);
1091 draw_property_utils::ComputeTransforms(&tree); 1095 draw_property_utils::ComputeTransforms(&tree);
1092 EXPECT_TRUE( 1096 EXPECT_TRUE(
1093 tree.Node(parent)->node_and_ancestors_have_only_integer_translation); 1097 tree.Node(parent)->node_and_ancestors_have_only_integer_translation);
1094 EXPECT_FALSE( 1098 EXPECT_FALSE(
1095 tree.Node(child)->node_and_ancestors_have_only_integer_translation); 1099 tree.Node(child)->node_and_ancestors_have_only_integer_translation);
1096 1100
1097 tree.Node(child)->local.Translate(0.5f, 0.5f); 1101 tree.Node(child)->local.Translate(0.5f, 0.5f);
1102 tree.Node(child)->needs_local_transform_update = true;
1098 tree.SetTargetId(child, child); 1103 tree.SetTargetId(child, child);
1099 tree.set_needs_update(true); 1104 tree.set_needs_update(true);
1100 SetupTransformTreeForTest(&tree); 1105 SetupTransformTreeForTest(&tree);
1101 draw_property_utils::ComputeTransforms(&tree); 1106 draw_property_utils::ComputeTransforms(&tree);
1102 EXPECT_TRUE( 1107 EXPECT_TRUE(
1103 tree.Node(parent)->node_and_ancestors_have_only_integer_translation); 1108 tree.Node(parent)->node_and_ancestors_have_only_integer_translation);
1104 EXPECT_TRUE( 1109 EXPECT_TRUE(
1105 tree.Node(child)->node_and_ancestors_have_only_integer_translation); 1110 tree.Node(child)->node_and_ancestors_have_only_integer_translation);
1106 } 1111 }
1107 }; 1112 };
1108 1113
1109 DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( 1114 DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F(
1110 PropertyTreeTestNonIntegerTranslationTest); 1115 PropertyTreeTestNonIntegerTranslationTest);
1111 1116
1112 class PropertyTreeTestSingularTransformSnapTest : public PropertyTreeTest { 1117 class PropertyTreeTestSingularTransformSnapTest : public PropertyTreeTest {
1113 protected: 1118 protected:
1114 void StartTest() override { 1119 void StartTest() override {
1115 // This tests that to_target transform is not snapped when it has a singular 1120 // This tests that to_target transform is not snapped when it has a singular
1116 // transform. 1121 // transform.
1117 PropertyTrees property_trees; 1122 PropertyTrees property_trees;
1118 property_trees.verify_transform_tree_calculations = true; 1123 property_trees.verify_transform_tree_calculations = true;
1119 TransformTree& tree = property_trees.transform_tree; 1124 TransformTree& tree = property_trees.transform_tree;
1120 EffectTree& effect_tree = property_trees.effect_tree; 1125 EffectTree& effect_tree = property_trees.effect_tree;
1121 1126
1122 int parent = tree.Insert(TransformNode(), 0); 1127 int parent = tree.Insert(TransformNode(), 0);
1123 int effect_parent = effect_tree.Insert(EffectNode(), 0); 1128 int effect_parent = effect_tree.Insert(EffectNode(), 0);
1124 effect_tree.Node(effect_parent)->has_render_surface = true; 1129 effect_tree.Node(effect_parent)->has_render_surface = true;
1125 tree.SetTargetId(parent, parent); 1130 tree.SetTargetId(parent, parent);
1126 tree.Node(parent)->scrolls = true; 1131 tree.Node(parent)->scrolls = true;
1132 tree.Node(parent)->source_node_id = 0;
1127 1133
1128 int child = tree.Insert(TransformNode(), parent); 1134 int child = tree.Insert(TransformNode(), parent);
1129 TransformNode* child_node = tree.Node(child); 1135 TransformNode* child_node = tree.Node(child);
1130 tree.SetTargetId(child, parent); 1136 tree.SetTargetId(child, parent);
1131 child_node->scrolls = true; 1137 child_node->scrolls = true;
1132 child_node->local.Scale3d(6.0f, 6.0f, 0.0f); 1138 child_node->local.Scale3d(6.0f, 6.0f, 0.0f);
1133 child_node->local.Translate(1.3f, 1.3f); 1139 child_node->local.Translate(1.3f, 1.3f);
1140 child_node->source_node_id = parent;
1134 tree.set_needs_update(true); 1141 tree.set_needs_update(true);
1135 1142
1136 SetupTransformTreeForTest(&tree); 1143 SetupTransformTreeForTest(&tree);
1137 draw_property_utils::ComputeTransforms(&tree); 1144 draw_property_utils::ComputeTransforms(&tree);
1138 property_trees.ResetCachedData(); 1145 property_trees.ResetCachedData();
1139 1146
1140 gfx::Transform from_target; 1147 gfx::Transform from_target;
1141 EXPECT_FALSE(tree.ToTarget(child, effect_parent).GetInverse(&from_target)); 1148 EXPECT_FALSE(tree.ToTarget(child, effect_parent).GetInverse(&from_target));
1142 // The following checks are to ensure that snapping is skipped because of 1149 // The following checks are to ensure that snapping is skipped because of
1143 // singular transform (and not because of other reasons which also cause 1150 // singular transform (and not because of other reasons which also cause
(...skipping 11 matching lines...) Expand all
1155 1162
1156 DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( 1163 DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F(
1157 PropertyTreeTestSingularTransformSnapTest); 1164 PropertyTreeTestSingularTransformSnapTest);
1158 1165
1159 #undef DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F 1166 #undef DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F
1160 #undef SERIALIZED_PROPERTY_TREE_TEST_F 1167 #undef SERIALIZED_PROPERTY_TREE_TEST_F
1161 #undef DIRECT_PROPERTY_TREE_TEST_F 1168 #undef DIRECT_PROPERTY_TREE_TEST_F
1162 1169
1163 } // namespace 1170 } // namespace
1164 } // namespace cc 1171 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698