Commit fc88422b authored by jaydasika's avatar jaydasika Committed by Commit bot

Make TransformTree::CombineTransformsBetween run faster

TransformTree::CombineTransformsBetween is modified to compute the
combined transform between source and destination directly (without
walking the path) when the destination and all its ancestors are
flat. A unit test is added to validate the patch.

BUG=475636
TEST=passes all the unit tests along with the one added to validate the
patch. Telemetry test on poster circle page shows improvement in
performance. The draw_properties.tough_compositor:CDP_reduction percentage
improved from -287.82% to -149.36%.

Review URL: https://codereview.chromium.org/1096493002

Cr-Commit-Position: refs/heads/master@{#325503}
parent 28ae8a04
......@@ -148,7 +148,7 @@ bool TransformTree::CombineTransformsBetween(int source_id,
// flattened(A * R) won't be R^{-1} * A{-1}, so multiplying C's to_screen and
// A's from_screen will not produce the correct result.
if (!dest || (dest->data.ancestors_are_invertible &&
current->data.node_and_ancestors_are_flat)) {
dest->data.node_and_ancestors_are_flat)) {
transform->ConcatTransform(current->data.to_screen);
if (dest)
transform->ConcatTransform(dest->data.from_screen);
......
......@@ -316,4 +316,42 @@ TEST(PropertyTreeTest, ComputeTransformWithSublayerScale) {
transform);
}
TEST(PropertyTreeTest, FlatteningWhenDestinationHasOnlyFlatAncestors) {
// 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.
TransformTree tree;
int parent = tree.Insert(TransformNode(), 0);
tree.Node(parent)->data.content_target_id = parent;
tree.Node(parent)->data.target_id = parent;
tree.Node(parent)->data.local.Translate(2, 2);
gfx::Transform rotation_about_x;
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.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.Node(grand_child)->data.flattens_inherited_transform = true;
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);
}
} // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment