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

Unified Diff: cc/trees/property_tree.cc

Issue 1070133002: Only allow change-of-basis between transform nodes on the same ancestor chain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2nd DCHECK added Created 5 years, 8 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
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/property_tree.cc
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index b1fd5e4e7ce0ca5eaa0044fca364f527a59b6b91..23e0587cd15444ba97da8aaf9b83cb49464fecd5 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -65,21 +65,13 @@ bool TransformTree::ComputeTransform(int source_id,
if (source_id == dest_id)
return true;
- if (source_id > dest_id && IsDescendant(source_id, dest_id))
+ if (source_id > dest_id) {
+ DCHECK(IsDescendant(source_id, dest_id));
return CombineTransformsBetween(source_id, dest_id, transform);
+ }
- if (dest_id > source_id && IsDescendant(dest_id, source_id))
- return CombineInversesBetween(source_id, dest_id, transform);
-
- int lca = LowestCommonAncestor(source_id, dest_id);
-
- bool no_singular_matrices_to_lca =
- CombineTransformsBetween(source_id, lca, transform);
-
- bool no_singular_matrices_from_lca =
- CombineInversesBetween(lca, dest_id, transform);
-
- return no_singular_matrices_to_lca && no_singular_matrices_from_lca;
+ DCHECK(IsDescendant(dest_id, source_id));
+ return CombineInversesBetween(source_id, dest_id, transform);
}
bool TransformTree::Are2DAxisAligned(int source_id, int dest_id) const {
@@ -110,27 +102,6 @@ bool TransformTree::IsDescendant(int desc_id, int source_id) const {
return true;
}
-int TransformTree::LowestCommonAncestor(int a, int b) const {
- std::set<int> chain_a;
- std::set<int> chain_b;
- while (a || b) {
- if (a) {
- a = Node(a)->parent_id;
- if (a > -1 && chain_b.find(a) != chain_b.end())
- return a;
- chain_a.insert(a);
- }
- if (b) {
- b = Node(b)->parent_id;
- if (b > -1 && chain_a.find(b) != chain_a.end())
- return b;
- chain_b.insert(b);
- }
- }
- NOTREACHED();
- return 0;
-}
-
bool TransformTree::CombineTransformsBetween(int source_id,
int dest_id,
gfx::Transform* transform) const {
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698