Index: cc/trees/property_tree_unittest.cc |
diff --git a/cc/trees/property_tree_unittest.cc b/cc/trees/property_tree_unittest.cc |
index 6cc8866e866540d0cf9eaf9a7dee8aca33ae4f94..db26de34bf81f65c3482cf79786e707ccb207972 100644 |
--- a/cc/trees/property_tree_unittest.cc |
+++ b/cc/trees/property_tree_unittest.cc |
@@ -391,646 +391,15 @@ class PropertyTreeTest : public testing::Test { |
DIRECT_PROPERTY_TREE_TEST_F(TEST_FIXTURE_NAME); \ |
SERIALIZED_PROPERTY_TREE_TEST_F(TEST_FIXTURE_NAME) |
-class PropertyTreeTestComputeTransformRoot : public PropertyTreeTest { |
+class PropertyTreeTestGetDrawTransformsTest : public PropertyTreeTest { |
protected: |
void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- root.id = 0; |
- root.local.Translate(2, 2); |
- tree.SetTargetId(root.id, 0); |
- SetupTransformTreeForTest(&tree); |
- tree.UpdateTransforms(0); |
- |
- gfx::Transform expected; |
- gfx::Transform transform; |
- bool success = tree.ComputeTransform(0, 0, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.Translate(2, 2); |
- success = tree.ComputeTransform(0, -1, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.MakeIdentity(); |
- expected.Translate(-2, -2); |
- success = tree.ComputeTransform(-1, 0, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformRoot); |
- |
-class PropertyTreeTestComputeTransformChild : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- root.local.Translate(2, 2); |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode child; |
- child.local.Translate(3, 3); |
- child.source_node_id = 0; |
- child.id = tree.Insert(child, 0); |
- tree.SetTargetId(child.id, 0); |
- |
- SetupTransformTreeForTest(&tree); |
- tree.UpdateTransforms(1); |
- |
- gfx::Transform expected; |
- gfx::Transform transform; |
- |
- expected.Translate(3, 3); |
- bool success = tree.ComputeTransform(1, 0, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.MakeIdentity(); |
- expected.Translate(-3, -3); |
- success = tree.ComputeTransform(0, 1, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.MakeIdentity(); |
- expected.Translate(5, 5); |
- success = tree.ComputeTransform(1, -1, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.MakeIdentity(); |
- expected.Translate(-5, -5); |
- success = tree.ComputeTransform(-1, 1, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformChild); |
- |
-class PropertyTreeTestComputeTransformSibling : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- root.local.Translate(2, 2); |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode child; |
- child.local.Translate(3, 3); |
- child.source_node_id = 0; |
- child.id = tree.Insert(child, 0); |
- tree.SetTargetId(child.id, 0); |
- |
- TransformNode sibling; |
- sibling.local.Translate(7, 7); |
- sibling.source_node_id = 0; |
- sibling.id = tree.Insert(sibling, 0); |
- tree.SetTargetId(sibling.id, 0); |
- |
- SetupTransformTreeForTest(&tree); |
- |
- tree.UpdateTransforms(1); |
- tree.UpdateTransforms(2); |
- |
- gfx::Transform expected; |
- gfx::Transform transform; |
- |
- expected.Translate(4, 4); |
- bool success = tree.ComputeTransform(2, 1, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.MakeIdentity(); |
- expected.Translate(-4, -4); |
- success = tree.ComputeTransform(1, 2, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformSibling); |
- |
-class PropertyTreeTestComputeTransformSiblingSingularAncestor |
- : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- // In this test, we have the following tree: |
- // root |
- // + singular |
- // + child |
- // + sibling |
- // Since the lowest common ancestor of |child| and |sibling| has a singular |
- // transform, we cannot use screen space transforms to compute change of |
- // basis |
- // transforms between these nodes. |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- root.local.Translate(2, 2); |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode singular; |
- singular.local.matrix().set(2, 2, 0.0); |
- singular.source_node_id = 0; |
- singular.id = tree.Insert(singular, 0); |
- tree.SetTargetId(singular.id, 0); |
- |
- TransformNode child; |
- child.local.Translate(3, 3); |
- child.source_node_id = 1; |
- child.id = tree.Insert(child, 1); |
- tree.SetTargetId(child.id, 0); |
- |
- TransformNode sibling; |
- sibling.local.Translate(7, 7); |
- sibling.source_node_id = 1; |
- sibling.id = tree.Insert(sibling, 1); |
- tree.SetTargetId(sibling.id, 0); |
- |
- SetupTransformTreeForTest(&tree); |
- |
- tree.UpdateTransforms(1); |
- tree.UpdateTransforms(2); |
- tree.UpdateTransforms(3); |
- |
- gfx::Transform expected; |
- gfx::Transform transform; |
- |
- expected.Translate(4, 4); |
- bool success = tree.ComputeTransform(3, 2, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- transform.MakeIdentity(); |
- expected.MakeIdentity(); |
- expected.Translate(-4, -4); |
- success = tree.ComputeTransform(2, 3, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformSiblingSingularAncestor); |
- |
-class PropertyTreeTestTransformsWithFlattening : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- property_trees.verify_transform_tree_calculations = true; |
- TransformTree& tree = property_trees.transform_tree; |
- EffectTree& effect_tree = property_trees.effect_tree; |
- |
- int grand_parent = tree.Insert(TransformNode(), 0); |
- int effect_grand_parent = effect_tree.Insert(EffectNode(), 0); |
- effect_tree.Node(effect_grand_parent)->has_render_surface = true; |
- effect_tree.Node(effect_grand_parent)->transform_id = grand_parent; |
- effect_tree.Node(effect_grand_parent)->surface_contents_scale = |
- gfx::Vector2dF(1.f, 1.f); |
- tree.SetContentTargetId(grand_parent, grand_parent); |
- tree.SetTargetId(grand_parent, grand_parent); |
- tree.Node(grand_parent)->source_node_id = 0; |
- |
- gfx::Transform rotation_about_x; |
- rotation_about_x.RotateAboutXAxis(15); |
- |
- int parent = tree.Insert(TransformNode(), grand_parent); |
- int effect_parent = effect_tree.Insert(EffectNode(), effect_grand_parent); |
- effect_tree.Node(effect_parent)->transform_id = parent; |
- effect_tree.Node(effect_parent)->has_render_surface = true; |
- effect_tree.Node(effect_parent)->surface_contents_scale = |
- gfx::Vector2dF(1.f, 1.f); |
- tree.Node(parent)->needs_surface_contents_scale = true; |
- tree.SetTargetId(parent, grand_parent); |
- tree.SetContentTargetId(parent, parent); |
- tree.Node(parent)->source_node_id = grand_parent; |
- tree.Node(parent)->local = rotation_about_x; |
- |
- int child = tree.Insert(TransformNode(), parent); |
- tree.SetTargetId(child, parent); |
- tree.SetContentTargetId(child, parent); |
- tree.Node(child)->source_node_id = parent; |
- tree.Node(child)->flattens_inherited_transform = true; |
- tree.Node(child)->local = rotation_about_x; |
- |
- int grand_child = tree.Insert(TransformNode(), child); |
- tree.SetTargetId(grand_child, parent); |
- tree.SetContentTargetId(grand_child, parent); |
- tree.Node(grand_child)->source_node_id = child; |
- tree.Node(grand_child)->flattens_inherited_transform = true; |
- tree.Node(grand_child)->local = rotation_about_x; |
- |
- tree.set_needs_update(true); |
- SetupTransformTreeForTest(&tree); |
- draw_property_utils::ComputeTransforms(&tree); |
- property_trees.ResetCachedData(); |
- |
- gfx::Transform flattened_rotation_about_x = rotation_about_x; |
- flattened_rotation_about_x.FlattenTo2d(); |
- |
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x, |
- tree.ToTarget(child, effect_parent)); |
- |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- flattened_rotation_about_x * rotation_about_x, tree.ToScreen(child)); |
- |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- flattened_rotation_about_x * rotation_about_x, |
- tree.ToTarget(grand_child, effect_parent)); |
- |
- EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_x * |
- flattened_rotation_about_x * |
- rotation_about_x, |
- tree.ToScreen(grand_child)); |
- |
- gfx::Transform grand_child_to_child; |
- bool success = |
- tree.ComputeTransform(grand_child, child, &grand_child_to_child); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x, grand_child_to_child); |
- |
- // Remove flattening at grand_child, and recompute transforms. |
- tree.Node(grand_child)->flattens_inherited_transform = false; |
- tree.set_needs_update(true); |
- SetupTransformTreeForTest(&tree); |
- draw_property_utils::ComputeTransforms(&tree); |
- |
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x * rotation_about_x, |
- tree.ToTarget(grand_child, effect_parent)); |
- |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- flattened_rotation_about_x * rotation_about_x * rotation_about_x, |
- tree.ToScreen(grand_child)); |
- |
- success = tree.ComputeTransform(grand_child, child, &grand_child_to_child); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(rotation_about_x, grand_child_to_child); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestTransformsWithFlattening); |
- |
-class PropertyTreeTestMultiplicationOrder : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- root.local.Translate(2, 2); |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode child; |
- child.local.Scale(2, 2); |
- child.source_node_id = 0; |
- child.id = tree.Insert(child, 0); |
- tree.SetTargetId(child.id, 0); |
- |
- SetupTransformTreeForTest(&tree); |
- tree.UpdateTransforms(1); |
- |
- gfx::Transform expected; |
- expected.Translate(2, 2); |
- expected.Scale(2, 2); |
- |
- gfx::Transform transform; |
- gfx::Transform inverse; |
- |
- bool success = tree.ComputeTransform(1, -1, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- success = tree.ComputeTransform(-1, 1, &inverse); |
- EXPECT_TRUE(success); |
- |
- transform = transform * inverse; |
- expected.MakeIdentity(); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F(PropertyTreeTestMultiplicationOrder); |
- |
-class PropertyTreeTestComputeTransformWithUninvertibleTransform |
- : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode child; |
- child.local.Scale(0, 0); |
- child.source_node_id = 0; |
- child.id = tree.Insert(child, 0); |
- tree.SetTargetId(child.id, 0); |
- |
- SetupTransformTreeForTest(&tree); |
- tree.UpdateTransforms(1); |
- |
- gfx::Transform expected; |
- expected.Scale(0, 0); |
- |
- gfx::Transform transform; |
- gfx::Transform inverse; |
- |
- bool success = tree.ComputeTransform(1, 0, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected, transform); |
- |
- // To compute this would require inverting the 0 matrix, so we cannot |
- // succeed. |
- success = tree.ComputeTransform(0, 1, &inverse); |
- EXPECT_FALSE(success); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformWithUninvertibleTransform); |
- |
-class PropertyTreeTestComputeTransformWithSurfaceContentsScale |
- : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- root.id = 0; |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode grand_parent; |
- grand_parent.local.Scale(2.f, 2.f); |
- grand_parent.source_node_id = 0; |
- grand_parent.needs_surface_contents_scale = true; |
- int grand_parent_id = tree.Insert(grand_parent, 0); |
- tree.SetTargetId(grand_parent_id, 0); |
- tree.UpdateTransforms(grand_parent_id); |
- |
- TransformNode parent; |
- parent.local.Translate(15.f, 15.f); |
- parent.source_node_id = grand_parent_id; |
- int parent_id = tree.Insert(parent, grand_parent_id); |
- tree.SetTargetId(parent_id, grand_parent_id); |
- tree.UpdateTransforms(parent_id); |
- |
- TransformNode child; |
- child.local.Scale(3.f, 3.f); |
- child.source_node_id = parent_id; |
- int child_id = tree.Insert(child, parent_id); |
- tree.SetTargetId(child_id, grand_parent_id); |
- tree.UpdateTransforms(child_id); |
- |
- TransformNode grand_child; |
- grand_child.local.Scale(5.f, 5.f); |
- grand_child.source_node_id = child_id; |
- grand_child.needs_surface_contents_scale = true; |
- int grand_child_id = tree.Insert(grand_child, child_id); |
- tree.SetTargetId(grand_child_id, grand_parent_id); |
- SetupTransformTreeForTest(&tree); |
- tree.UpdateTransforms(grand_child_id); |
- |
- EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), |
- tree.Node(grand_parent_id)->surface_contents_scale); |
- EXPECT_EQ(gfx::Vector2dF(30.f, 30.f), |
- tree.Node(grand_child_id)->surface_contents_scale); |
- |
- // Compute transform from grand_parent to grand_child. |
- gfx::Transform expected_transform_without_surface_contents_scale; |
- expected_transform_without_surface_contents_scale.Scale(1.f / 15.f, |
- 1.f / 15.f); |
- expected_transform_without_surface_contents_scale.Translate(-15.f, -15.f); |
- |
- gfx::Transform expected_transform_with_dest_surface_contents_scale; |
- expected_transform_with_dest_surface_contents_scale.Scale(30.f, 30.f); |
- expected_transform_with_dest_surface_contents_scale.Scale(1.f / 15.f, |
- 1.f / 15.f); |
- expected_transform_with_dest_surface_contents_scale.Translate(-15.f, -15.f); |
- |
- gfx::Transform expected_transform_with_source_surface_contents_scale; |
- expected_transform_with_source_surface_contents_scale.Scale(1.f / 15.f, |
- 1.f / 15.f); |
- expected_transform_with_source_surface_contents_scale.Translate(-15.f, |
- -15.f); |
- expected_transform_with_source_surface_contents_scale.Scale(0.5f, 0.5f); |
- |
- gfx::Transform transform; |
- bool success = |
- tree.ComputeTransform(grand_parent_id, grand_child_id, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- expected_transform_without_surface_contents_scale, transform); |
- |
- success = |
- tree.ComputeTransform(grand_parent_id, grand_child_id, &transform); |
- const TransformNode* grand_child_node = tree.Node(grand_child_id); |
- transform.matrix().postScale(grand_child_node->surface_contents_scale.x(), |
- grand_child_node->surface_contents_scale.y(), |
- 1.f); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- expected_transform_with_dest_surface_contents_scale, transform); |
- |
- success = |
- tree.ComputeTransform(grand_parent_id, grand_child_id, &transform); |
- const TransformNode* grand_parent_node = tree.Node(grand_parent_id); |
- EXPECT_NE(grand_parent_node->surface_contents_scale.x(), 0.f); |
- EXPECT_NE(grand_parent_node->surface_contents_scale.y(), 0.f); |
- transform.Scale(1.0 / grand_parent_node->surface_contents_scale.x(), |
- 1.0 / grand_parent_node->surface_contents_scale.y()); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- expected_transform_with_source_surface_contents_scale, transform); |
- |
- // Now compute transform from grand_child to grand_parent. |
- expected_transform_without_surface_contents_scale.MakeIdentity(); |
- expected_transform_without_surface_contents_scale.Translate(15.f, 15.f); |
- expected_transform_without_surface_contents_scale.Scale(15.f, 15.f); |
- |
- expected_transform_with_dest_surface_contents_scale.MakeIdentity(); |
- expected_transform_with_dest_surface_contents_scale.Scale(2.f, 2.f); |
- expected_transform_with_dest_surface_contents_scale.Translate(15.f, 15.f); |
- expected_transform_with_dest_surface_contents_scale.Scale(15.f, 15.f); |
- |
- expected_transform_with_source_surface_contents_scale.MakeIdentity(); |
- expected_transform_with_source_surface_contents_scale.Translate(15.f, 15.f); |
- expected_transform_with_source_surface_contents_scale.Scale(15.f, 15.f); |
- expected_transform_with_source_surface_contents_scale.Scale(1.f / 30.f, |
- 1.f / 30.f); |
- |
- success = |
- tree.ComputeTransform(grand_child_id, grand_parent_id, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- expected_transform_without_surface_contents_scale, transform); |
- |
- success = |
- tree.ComputeTransform(grand_child_id, grand_parent_id, &transform); |
- transform.matrix().postScale(grand_parent_node->surface_contents_scale.x(), |
- grand_parent_node->surface_contents_scale.y(), |
- 1.f); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- expected_transform_with_dest_surface_contents_scale, transform); |
- |
- success = |
- tree.ComputeTransform(grand_child_id, grand_parent_id, &transform); |
- EXPECT_NE(grand_child_node->surface_contents_scale.x(), 0.f); |
- EXPECT_NE(grand_child_node->surface_contents_scale.y(), 0.f); |
- transform.Scale(1.0 / grand_child_node->surface_contents_scale.x(), |
- 1.0 / grand_child_node->surface_contents_scale.y()); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ( |
- expected_transform_with_source_surface_contents_scale, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformWithSurfaceContentsScale); |
- |
-class PropertyTreeTestComputeTransformToTargetWithZeroSurfaceContentsScale |
- : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- TransformNode& root = *tree.Node(0); |
- tree.SetTargetId(root.id, 0); |
- tree.UpdateTransforms(0); |
- |
- TransformNode grand_parent; |
- grand_parent.local.Scale(2.f, 0.f); |
- grand_parent.source_node_id = 0; |
- grand_parent.needs_surface_contents_scale = true; |
- int grand_parent_id = tree.Insert(grand_parent, 0); |
- tree.SetTargetId(grand_parent_id, 0); |
- tree.SetContentTargetId(grand_parent_id, grand_parent_id); |
- tree.UpdateTransforms(grand_parent_id); |
- |
- TransformNode parent; |
- parent.local.Translate(1.f, 1.f); |
- parent.source_node_id = grand_parent_id; |
- int parent_id = tree.Insert(parent, grand_parent_id); |
- tree.SetTargetId(parent_id, grand_parent_id); |
- tree.SetContentTargetId(parent_id, grand_parent_id); |
- tree.UpdateTransforms(parent_id); |
- |
- TransformNode child; |
- child.local.Translate(3.f, 4.f); |
- child.source_node_id = parent_id; |
- int child_id = tree.Insert(child, parent_id); |
- tree.SetTargetId(child_id, grand_parent_id); |
- tree.SetContentTargetId(child_id, grand_parent_id); |
- SetupTransformTreeForTest(&tree); |
- tree.UpdateTransforms(child_id); |
- |
- gfx::Transform expected_transform; |
- expected_transform.Translate(4.f, 5.f); |
- |
- gfx::Transform transform; |
- bool success = tree.ComputeTransform(child_id, grand_parent_id, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, transform); |
- |
- tree.Node(grand_parent_id)->local.MakeIdentity(); |
- tree.Node(grand_parent_id)->local.Scale(0.f, 2.f); |
- tree.Node(grand_parent_id)->needs_local_transform_update = true; |
- tree.set_needs_update(true); |
- SetupTransformTreeForTest(&tree); |
- |
- draw_property_utils::ComputeTransforms(&tree); |
- |
- success = tree.ComputeTransform(child_id, grand_parent_id, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, transform); |
- |
- tree.Node(grand_parent_id)->local.MakeIdentity(); |
- tree.Node(grand_parent_id)->local.Scale(0.f, 0.f); |
- tree.Node(grand_parent_id)->needs_local_transform_update = true; |
- tree.set_needs_update(true); |
- SetupTransformTreeForTest(&tree); |
- |
- draw_property_utils::ComputeTransforms(&tree); |
- |
- success = tree.ComputeTransform(child_id, grand_parent_id, &transform); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, transform); |
- } |
-}; |
- |
-DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestComputeTransformToTargetWithZeroSurfaceContentsScale); |
- |
-class PropertyTreeTestFlatteningWhenDestinationHasOnlyFlatAncestors |
- : public PropertyTreeTest { |
- protected: |
- void StartTest() override { |
- // This tests that flattening is performed correctly when |
- // destination and its ancestors are flat, but there are 3d transforms |
- // and flattening between the source and destination. |
- PropertyTrees property_trees; |
- TransformTree& tree = property_trees.transform_tree; |
- |
- int parent = tree.Insert(TransformNode(), 0); |
- tree.SetContentTargetId(parent, parent); |
- tree.SetTargetId(parent, parent); |
- tree.Node(parent)->source_node_id = 0; |
- tree.Node(parent)->local.Translate(2, 2); |
- |
- gfx::Transform rotation_about_x; |
- rotation_about_x.RotateAboutXAxis(15); |
- |
- int child = tree.Insert(TransformNode(), parent); |
- tree.SetContentTargetId(child, child); |
- tree.SetTargetId(child, child); |
- tree.Node(child)->source_node_id = parent; |
- tree.Node(child)->local = rotation_about_x; |
- |
- int grand_child = tree.Insert(TransformNode(), child); |
- tree.SetContentTargetId(grand_child, grand_child); |
- tree.SetTargetId(grand_child, grand_child); |
- tree.Node(grand_child)->source_node_id = child; |
- tree.Node(grand_child)->flattens_inherited_transform = true; |
- |
- tree.set_needs_update(true); |
- SetupTransformTreeForTest(&tree); |
- draw_property_utils::ComputeTransforms(&tree); |
- |
- gfx::Transform flattened_rotation_about_x = rotation_about_x; |
- flattened_rotation_about_x.FlattenTo2d(); |
- |
- gfx::Transform grand_child_to_parent; |
- bool success = |
- tree.ComputeTransform(grand_child, parent, &grand_child_to_parent); |
- EXPECT_TRUE(success); |
- EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_x, |
- grand_child_to_parent); |
+ // TODO(sunxd): Add GetDrawTransforms tests. |
} |
}; |
DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F( |
- PropertyTreeTestFlatteningWhenDestinationHasOnlyFlatAncestors); |
+ PropertyTreeTestGetDrawTransformsTest); |
class PropertyTreeTestScreenSpaceOpacityUpdateTest : public PropertyTreeTest { |
protected: |
@@ -1120,7 +489,6 @@ class PropertyTreeTestSingularTransformSnapTest : public PropertyTreeTest { |
// This tests that to_target transform is not snapped when it has a singular |
// transform. |
PropertyTrees property_trees; |
- property_trees.verify_transform_tree_calculations = true; |
TransformTree& tree = property_trees.transform_tree; |
EffectTree& effect_tree = property_trees.effect_tree; |