OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/trees/property_tree.h" | 10 #include "cc/trees/property_tree.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // is a non-linear operation, we cannot use this approach when there is | 141 // is a non-linear operation, we cannot use this approach when there is |
142 // non-trivial flattening between the source and destination nodes. For | 142 // non-trivial flattening between the source and destination nodes. For |
143 // example, consider the tree R->A->B->C, where B flattens its inherited | 143 // example, consider the tree R->A->B->C, where B flattens its inherited |
144 // transform, and A has a non-flat transform. Suppose C is the source and A is | 144 // transform, and A has a non-flat transform. Suppose C is the source and A is |
145 // the destination. The expected result is C * B. But C's to_screen | 145 // the destination. The expected result is C * B. But C's to_screen |
146 // transform is C * B * flattened(A * R), and A's from_screen transform is | 146 // transform is C * B * flattened(A * R), and A's from_screen transform is |
147 // R^{-1} * A^{-1}. If at least one of A and R isn't flat, the inverse of | 147 // R^{-1} * A^{-1}. If at least one of A and R isn't flat, the inverse of |
148 // flattened(A * R) won't be R^{-1} * A{-1}, so multiplying C's to_screen and | 148 // flattened(A * R) won't be R^{-1} * A{-1}, so multiplying C's to_screen and |
149 // A's from_screen will not produce the correct result. | 149 // A's from_screen will not produce the correct result. |
150 if (!dest || (dest->data.ancestors_are_invertible && | 150 if (!dest || (dest->data.ancestors_are_invertible && |
151 current->data.node_and_ancestors_are_flat)) { | 151 dest->data.node_and_ancestors_are_flat)) { |
152 transform->ConcatTransform(current->data.to_screen); | 152 transform->ConcatTransform(current->data.to_screen); |
153 if (dest) | 153 if (dest) |
154 transform->ConcatTransform(dest->data.from_screen); | 154 transform->ConcatTransform(dest->data.from_screen); |
155 return true; | 155 return true; |
156 } | 156 } |
157 | 157 |
158 // Flattening is defined in a way that requires it to be applied while | 158 // Flattening is defined in a way that requires it to be applied while |
159 // traversing downward in the tree. We first identify nodes that are on the | 159 // traversing downward in the tree. We first identify nodes that are on the |
160 // path from the source to the destination (this is traversing upward), and | 160 // path from the source to the destination (this is traversing upward), and |
161 // then we visit these nodes in reverse order, flattening as needed. We | 161 // then we visit these nodes in reverse order, flattening as needed. We |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 node->data.from_target.matrix().postTranslate(-translation.x(), | 319 node->data.from_target.matrix().postTranslate(-translation.x(), |
320 -translation.y(), 0); | 320 -translation.y(), 0); |
321 node->data.to_screen.Translate(translation.x(), translation.y()); | 321 node->data.to_screen.Translate(translation.x(), translation.y()); |
322 node->data.from_screen.matrix().postTranslate(-translation.x(), | 322 node->data.from_screen.matrix().postTranslate(-translation.x(), |
323 -translation.y(), 0); | 323 -translation.y(), 0); |
324 | 324 |
325 node->data.scroll_snap = translation; | 325 node->data.scroll_snap = translation; |
326 } | 326 } |
327 | 327 |
328 } // namespace cc | 328 } // namespace cc |
OLD | NEW |