| 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 "cc/trees/property_tree_builder.h" | 5 #include "cc/trees/property_tree_builder.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 bool requires_node = is_root || is_scrollable || has_significant_transform || | 128 bool requires_node = is_root || is_scrollable || has_significant_transform || |
| 129 has_animated_transform || has_surface || | 129 has_animated_transform || has_surface || |
| 130 is_page_scale_application_layer; | 130 is_page_scale_application_layer; |
| 131 | 131 |
| 132 Layer* transform_parent = GetTransformParent(data_from_ancestor, layer); | 132 Layer* transform_parent = GetTransformParent(data_from_ancestor, layer); |
| 133 | 133 |
| 134 // May be non-zero if layer is fixed or has a scroll parent. | 134 // May be non-zero if layer is fixed or has a scroll parent. |
| 135 gfx::Vector2dF parent_offset; | 135 gfx::Vector2dF parent_offset; |
| 136 if (transform_parent) { | 136 if (transform_parent) { |
| 137 // TODO(vollick): This is to mimic existing bugs (crbug.com/441447). | 137 if (layer->scroll_parent()) { |
| 138 if (!is_fixed) { | 138 gfx::Transform to_parent; |
| 139 Layer* source = layer->parent(); |
| 140 parent_offset += source->offset_to_transform_parent(); |
| 141 data_from_ancestor.transform_tree->ComputeTransform( |
| 142 source->transform_tree_index(), |
| 143 transform_parent->transform_tree_index(), &to_parent); |
| 144 parent_offset += to_parent.To2dTranslation(); |
| 145 } else if (!is_fixed) { |
| 139 parent_offset = transform_parent->offset_to_transform_parent(); | 146 parent_offset = transform_parent->offset_to_transform_parent(); |
| 140 } else if (data_from_ancestor.transform_tree_parent != | 147 } else if (data_from_ancestor.transform_tree_parent != |
| 141 data_from_ancestor.transform_fixed_parent) { | 148 data_from_ancestor.transform_fixed_parent) { |
| 142 gfx::Vector2dF fixed_offset = data_from_ancestor.transform_tree_parent | 149 gfx::Vector2dF fixed_offset = data_from_ancestor.transform_tree_parent |
| 143 ->offset_to_transform_parent(); | 150 ->offset_to_transform_parent(); |
| 144 gfx::Transform parent_to_parent; | 151 gfx::Transform parent_to_parent; |
| 145 data_from_ancestor.transform_tree->ComputeTransform( | 152 data_from_ancestor.transform_tree->ComputeTransform( |
| 146 data_from_ancestor.transform_tree_parent->transform_tree_index(), | 153 data_from_ancestor.transform_tree_parent->transform_tree_index(), |
| 147 data_from_ancestor.transform_fixed_parent->transform_tree_index(), | 154 data_from_ancestor.transform_fixed_parent->transform_tree_index(), |
| 148 &parent_to_parent); | 155 &parent_to_parent); |
| 149 | 156 |
| 150 fixed_offset += parent_to_parent.To2dTranslation(); | 157 fixed_offset += parent_to_parent.To2dTranslation(); |
| 151 parent_offset += fixed_offset; | 158 parent_offset += fixed_offset; |
| 152 } | 159 } |
| 153 | |
| 154 gfx::Transform to_parent; | |
| 155 Layer* source = data_from_ancestor.transform_tree_parent; | |
| 156 if (layer->scroll_parent()) { | |
| 157 source = layer->parent(); | |
| 158 parent_offset += layer->parent()->offset_to_transform_parent(); | |
| 159 } | |
| 160 data_from_ancestor.transform_tree->ComputeTransform( | |
| 161 source->transform_tree_index(), | |
| 162 transform_parent->transform_tree_index(), &to_parent); | |
| 163 | |
| 164 parent_offset += to_parent.To2dTranslation(); | |
| 165 } | 160 } |
| 166 | 161 |
| 167 if (layer->IsContainerForFixedPositionLayers() || is_root) | 162 if (layer->IsContainerForFixedPositionLayers() || is_root) |
| 168 data_for_children->transform_fixed_parent = layer; | 163 data_for_children->transform_fixed_parent = layer; |
| 169 data_for_children->transform_tree_parent = layer; | 164 data_for_children->transform_tree_parent = layer; |
| 170 | 165 |
| 171 if (!requires_node) { | 166 if (!requires_node) { |
| 172 data_for_children->should_flatten |= layer->should_flatten_transform(); | 167 data_for_children->should_flatten |= layer->should_flatten_transform(); |
| 173 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + | 168 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + |
| 174 layer->transform().To2dTranslation(); | 169 layer->transform().To2dTranslation(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 data_for_recursion.device_transform = &device_transform; | 315 data_for_recursion.device_transform = &device_transform; |
| 321 | 316 |
| 322 ClipNode root_clip; | 317 ClipNode root_clip; |
| 323 root_clip.data.clip = viewport; | 318 root_clip.data.clip = viewport; |
| 324 root_clip.data.transform_id = 0; | 319 root_clip.data.transform_id = 0; |
| 325 data_for_recursion.clip_tree_parent = clip_tree->Insert(root_clip, 0); | 320 data_for_recursion.clip_tree_parent = clip_tree->Insert(root_clip, 0); |
| 326 BuildPropertyTreesInternal(root_layer, data_for_recursion); | 321 BuildPropertyTreesInternal(root_layer, data_for_recursion); |
| 327 } | 322 } |
| 328 | 323 |
| 329 } // namespace cc | 324 } // namespace cc |
| OLD | NEW |