| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 CombineTransformsBetween(source_id, dest_id, transform); | 154 CombineTransformsBetween(source_id, dest_id, transform); |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 return CombineInversesBetween(source_id, dest_id, transform); | 158 return CombineInversesBetween(source_id, dest_id, transform); |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool TransformTree::ComputeTranslation(int source_id, | 161 bool TransformTree::ComputeTranslation(int source_id, |
| 162 int dest_id, | 162 int dest_id, |
| 163 gfx::Transform* transform) const { | 163 gfx::Transform* transform) const { |
| 164 bool success = ComputeTransform(source_id, dest_id, transform); | 164 // Since the transform between source and destination is at most translation, |
| 165 // flattenning will not affect the result and we can use the screen space |
| 166 // transforms. |
| 167 transform->MakeIdentity(); |
| 168 if (source_id == dest_id) |
| 169 return true; |
| 170 |
| 171 const TransformNode* dest = Node(dest_id); |
| 172 if (dest->ancestors_are_invertible) { |
| 173 if (source_id != kInvalidNodeId) |
| 174 transform->ConcatTransform(ToScreen(source_id)); |
| 175 if (dest_id != kInvalidNodeId) |
| 176 transform->ConcatTransform(FromScreen(dest_id)); |
| 177 } else { |
| 178 return false; |
| 179 } |
| 165 DCHECK( | 180 DCHECK( |
| 166 transform->IsApproximatelyIdentityOrTranslation(SkDoubleToMScalar(1e-4))); | 181 transform->IsApproximatelyIdentityOrTranslation(SkDoubleToMScalar(1e-4))); |
| 167 return success; | 182 return true; |
| 168 } | 183 } |
| 169 | 184 |
| 170 bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) { | 185 bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) { |
| 171 return (source_to_parent_updates_allowed() && | 186 return (source_to_parent_updates_allowed() && |
| 172 node->parent_id != node->source_node_id); | 187 node->parent_id != node->source_node_id); |
| 173 } | 188 } |
| 174 | 189 |
| 175 void TransformTree::ResetChangeTracking() { | 190 void TransformTree::ResetChangeTracking() { |
| 176 for (int id = 1; id < static_cast<int>(size()); ++id) { | 191 for (int id = 1; id < static_cast<int>(size()); ++id) { |
| 177 TransformNode* node = Node(id); | 192 TransformNode* node = Node(id); |
| (...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 DCHECK(effect_node->has_render_surface || | 2019 DCHECK(effect_node->has_render_surface || |
| 2005 effect_node->id == EffectTree::kRootNodeId); | 2020 effect_node->id == EffectTree::kRootNodeId); |
| 2006 target_transform_id = effect_node->transform_id; | 2021 target_transform_id = effect_node->transform_id; |
| 2007 } | 2022 } |
| 2008 | 2023 |
| 2009 return transform_tree.ComputeTransform(target_transform_id, transform_id, | 2024 return transform_tree.ComputeTransform(target_transform_id, transform_id, |
| 2010 transform); | 2025 transform); |
| 2011 } | 2026 } |
| 2012 | 2027 |
| 2013 } // namespace cc | 2028 } // namespace cc |
| OLD | NEW |