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

Unified Diff: cc/trees/property_tree_unittest.cc

Issue 2032213002: cc: Put to_target and to_screen behind an accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put target_id behind accessor Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/property_tree_unittest.cc
diff --git a/cc/trees/property_tree_unittest.cc b/cc/trees/property_tree_unittest.cc
index 08bcd5e16fa67e8256adbe43d6ebf5e1f584609b..86e73de612720d68e965ba414db11d9ff88b257f 100644
--- a/cc/trees/property_tree_unittest.cc
+++ b/cc/trees/property_tree_unittest.cc
@@ -635,8 +635,8 @@ class PropertyTreeTestTransformsWithFlattening : public PropertyTreeTest {
TransformTree& tree = property_trees.transform_tree;
int grand_parent = tree.Insert(TransformNode(), 0);
- tree.Node(grand_parent)->data.content_target_id = grand_parent;
- tree.Node(grand_parent)->data.target_id = grand_parent;
+ tree.SetContentTargetId(grand_parent, grand_parent);
+ tree.SetTargetId(grand_parent, grand_parent);
tree.Node(grand_parent)->data.source_node_id = 0;
gfx::Transform rotation_about_x;
@@ -644,21 +644,21 @@ class PropertyTreeTestTransformsWithFlattening : public PropertyTreeTest {
int parent = tree.Insert(TransformNode(), grand_parent);
tree.Node(parent)->data.needs_sublayer_scale = true;
- tree.Node(parent)->data.target_id = grand_parent;
- tree.Node(parent)->data.content_target_id = parent;
+ tree.SetTargetId(parent, grand_parent);
+ tree.SetContentTargetId(parent, parent);
tree.Node(parent)->data.source_node_id = grand_parent;
tree.Node(parent)->data.local = rotation_about_x;
int child = tree.Insert(TransformNode(), parent);
- tree.Node(child)->data.target_id = parent;
- tree.Node(child)->data.content_target_id = parent;
+ tree.SetTargetId(child, parent);
+ tree.SetContentTargetId(child, parent);
tree.Node(child)->data.source_node_id = parent;
tree.Node(child)->data.flattens_inherited_transform = true;
tree.Node(child)->data.local = rotation_about_x;
int grand_child = tree.Insert(TransformNode(), child);
- tree.Node(grand_child)->data.target_id = parent;
- tree.Node(grand_child)->data.content_target_id = parent;
+ tree.SetTargetId(grand_child, parent);
+ tree.SetContentTargetId(grand_child, parent);
tree.Node(grand_child)->data.source_node_id = child;
tree.Node(grand_child)->data.flattens_inherited_transform = true;
tree.Node(grand_child)->data.local = rotation_about_x;
@@ -670,21 +670,19 @@ class PropertyTreeTestTransformsWithFlattening : public PropertyTreeTest {
gfx::Transform flattened_rotation_about_x = rotation_about_x;
flattened_rotation_about_x.FlattenTo2d();
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x,
- tree.Node(child)->data.to_target);
+ EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x, tree.ToTarget(child));
EXPECT_TRANSFORMATION_MATRIX_EQ(
- flattened_rotation_about_x * rotation_about_x,
- tree.Node(child)->data.to_screen);
+ flattened_rotation_about_x * rotation_about_x, tree.ToScreen(child));
EXPECT_TRANSFORMATION_MATRIX_EQ(
flattened_rotation_about_x * rotation_about_x,
- tree.Node(grand_child)->data.to_target);
+ tree.ToTarget(grand_child));
EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_x *
flattened_rotation_about_x *
rotation_about_x,
- tree.Node(grand_child)->data.to_screen);
+ tree.ToScreen(grand_child));
gfx::Transform grand_child_to_child;
bool success =
@@ -699,11 +697,11 @@ class PropertyTreeTestTransformsWithFlattening : public PropertyTreeTest {
draw_property_utils::ComputeTransforms(&tree);
EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x * rotation_about_x,
- tree.Node(grand_child)->data.to_target);
+ tree.ToTarget(grand_child));
EXPECT_TRANSFORMATION_MATRIX_EQ(
flattened_rotation_about_x * rotation_about_x * rotation_about_x,
- tree.Node(grand_child)->data.to_screen);
+ tree.ToScreen(grand_child));
success = tree.ComputeTransform(grand_child, child, &grand_child_to_child);
EXPECT_TRUE(success);
@@ -996,8 +994,8 @@ class PropertyTreeTestFlatteningWhenDestinationHasOnlyFlatAncestors
TransformTree& tree = property_trees.transform_tree;
int parent = tree.Insert(TransformNode(), 0);
- tree.Node(parent)->data.content_target_id = parent;
- tree.Node(parent)->data.target_id = parent;
+ tree.SetContentTargetId(parent, parent);
+ tree.SetTargetId(parent, parent);
tree.Node(parent)->data.source_node_id = 0;
tree.Node(parent)->data.local.Translate(2, 2);
@@ -1005,14 +1003,14 @@ class PropertyTreeTestFlatteningWhenDestinationHasOnlyFlatAncestors
rotation_about_x.RotateAboutXAxis(15);
int child = tree.Insert(TransformNode(), parent);
- tree.Node(child)->data.content_target_id = child;
- tree.Node(child)->data.target_id = child;
+ tree.SetContentTargetId(child, child);
+ tree.SetTargetId(child, child);
tree.Node(child)->data.source_node_id = parent;
tree.Node(child)->data.local = rotation_about_x;
int grand_child = tree.Insert(TransformNode(), child);
- tree.Node(grand_child)->data.content_target_id = grand_child;
- tree.Node(grand_child)->data.target_id = grand_child;
+ tree.SetContentTargetId(grand_child, grand_child);
+ tree.SetTargetId(grand_child, grand_child);
tree.Node(grand_child)->data.source_node_id = child;
tree.Node(grand_child)->data.flattens_inherited_transform = true;
@@ -1073,11 +1071,11 @@ class PropertyTreeTestNonIntegerTranslationTest : public PropertyTreeTest {
TransformTree& tree = property_trees.transform_tree;
int parent = tree.Insert(TransformNode(), 0);
- tree.Node(parent)->data.target_id = parent;
+ tree.SetTargetId(parent, parent);
tree.Node(parent)->data.local.Translate(1.5f, 1.5f);
int child = tree.Insert(TransformNode(), parent);
- tree.Node(child)->data.target_id = parent;
+ tree.SetTargetId(child, parent);
tree.Node(child)->data.local.Translate(1, 1);
tree.set_needs_update(true);
SetupTransformTreeForTest(&tree);
@@ -1098,7 +1096,7 @@ class PropertyTreeTestNonIntegerTranslationTest : public PropertyTreeTest {
->data.node_and_ancestors_have_only_integer_translation);
tree.Node(child)->data.local.Translate(0.5f, 0.5f);
- tree.Node(child)->data.target_id = child;
+ tree.SetTargetId(child, child);
tree.set_needs_update(true);
SetupTransformTreeForTest(&tree);
draw_property_utils::ComputeTransforms(&tree);
@@ -1121,12 +1119,12 @@ class PropertyTreeTestSingularTransformSnapTest : public PropertyTreeTest {
TransformTree& tree = property_trees.transform_tree;
int parent = tree.Insert(TransformNode(), 0);
- tree.Node(parent)->data.target_id = parent;
+ tree.SetTargetId(parent, parent);
tree.Node(parent)->data.scrolls = true;
int child = tree.Insert(TransformNode(), parent);
TransformNode* child_node = tree.Node(child);
- child_node->data.target_id = parent;
+ tree.SetTargetId(child, parent);
child_node->data.scrolls = true;
child_node->data.local.Scale3d(6.0f, 6.0f, 0.0f);
child_node->data.local.Translate(1.3f, 1.3f);
@@ -1136,18 +1134,18 @@ class PropertyTreeTestSingularTransformSnapTest : public PropertyTreeTest {
draw_property_utils::ComputeTransforms(&tree);
gfx::Transform from_target;
- EXPECT_FALSE(child_node->data.to_target.GetInverse(&from_target));
+ EXPECT_FALSE(tree.ToTarget(child).GetInverse(&from_target));
// The following checks are to ensure that snapping is skipped because of
// singular transform (and not because of other reasons which also cause
// snapping to be skipped).
EXPECT_TRUE(child_node->data.scrolls);
- EXPECT_TRUE(child_node->data.to_target.IsScaleOrTranslation());
+ EXPECT_TRUE(tree.ToTarget(child).IsScaleOrTranslation());
EXPECT_FALSE(child_node->data.to_screen_is_potentially_animated);
EXPECT_FALSE(child_node->data.ancestors_are_invertible);
- gfx::Transform rounded = child_node->data.to_target;
+ gfx::Transform rounded = tree.ToTarget(child);
rounded.RoundTranslationComponents();
- EXPECT_NE(child_node->data.to_target, rounded);
+ EXPECT_NE(tree.ToTarget(child), rounded);
}
};

Powered by Google App Engine
This is Rietveld 408576698