summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authorjaydasika <jaydasika@chromium.org>2015-12-14 23:56:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-15 07:57:35 +0000
commit807ea406fc4b99506d5f05e1c830f57bcd8c385c (patch)
tree8826b02adbc9d2b7b39c0b403b4c37002baa2aae /cc/trees
parent692e0d473622a8502f436e9543dc5356b3a03183 (diff)
downloadchromium_src-807ea406fc4b99506d5f05e1c830f57bcd8c385c.zip
chromium_src-807ea406fc4b99506d5f05e1c830f57bcd8c385c.tar.gz
chromium_src-807ea406fc4b99506d5f05e1c830f57bcd8c385c.tar.bz2
cc: Don't update snapping when we have singular transforms
In property trees, the snapping update code relies on inverse of the target space transform. So, when there is some ancestor with a singular transform, we should skip the snapping update. BUG=561624 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1522863003 Cr-Commit-Position: refs/heads/master@{#365204}
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/property_tree.cc3
-rw-r--r--cc/trees/property_tree_unittest.cc41
2 files changed, 43 insertions, 1 deletions
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index a6b72e6..e66ff55 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -844,7 +844,8 @@ void TransformTree::UndoSnapping(TransformNode* node) {
void TransformTree::UpdateSnapping(TransformNode* node) {
if (!node->data.scrolls || node->data.to_screen_is_animated ||
- !node->data.to_target.IsScaleOrTranslation()) {
+ !node->data.to_target.IsScaleOrTranslation() ||
+ !node->data.ancestors_are_invertible) {
return;
}
diff --git a/cc/trees/property_tree_unittest.cc b/cc/trees/property_tree_unittest.cc
index e9b8c2d..65cb414 100644
--- a/cc/trees/property_tree_unittest.cc
+++ b/cc/trees/property_tree_unittest.cc
@@ -972,6 +972,47 @@ class PropertyTreeTestNonIntegerTranslationTest : public PropertyTreeTest {
DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F(
PropertyTreeTestNonIntegerTranslationTest);
+class PropertyTreeTestSingularTransformSnapTest : public PropertyTreeTest {
+ protected:
+ void StartTest() override {
+ // This tests that to_target transform is not snapped when it has a singular
+ // transform.
+ TransformTree tree;
+
+ int parent = tree.Insert(TransformNode(), 0);
+ tree.Node(parent)->data.target_id = 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;
+ 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);
+ tree.set_needs_update(true);
+
+ tree = TransformTreeForTest(tree);
+ ComputeTransforms(&tree);
+
+ gfx::Transform from_target;
+ EXPECT_FALSE(child_node->data.to_target.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_FALSE(child_node->data.to_screen_is_animated);
+ EXPECT_FALSE(child_node->data.ancestors_are_invertible);
+
+ gfx::Transform rounded = child_node->data.to_target;
+ rounded.RoundTranslationComponents();
+ EXPECT_NE(child_node->data.to_target, rounded);
+ }
+};
+
+DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F(
+ PropertyTreeTestSingularTransformSnapTest);
+
#undef DIRECT_AND_SERIALIZED_PROPERTY_TREE_TEST_F
#undef SERIALIZED_PROPERTY_TREE_TEST_F
#undef DIRECT_PROPERTY_TREE_TEST_F