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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 if (layer->IsContainerForFixedPositionLayers() || is_root) | 167 if (layer->IsContainerForFixedPositionLayers() || is_root) |
168 data_for_children->transform_fixed_parent = layer; | 168 data_for_children->transform_fixed_parent = layer; |
169 data_for_children->transform_tree_parent = layer; | 169 data_for_children->transform_tree_parent = layer; |
170 | 170 |
171 if (!requires_node) { | 171 if (!requires_node) { |
172 data_for_children->should_flatten |= layer->should_flatten_transform(); | 172 data_for_children->should_flatten |= layer->should_flatten_transform(); |
173 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + | 173 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + |
174 layer->transform().To2dTranslation(); | 174 layer->transform().To2dTranslation(); |
175 layer->set_offset_to_transform_parent(parent_offset + local_offset); | 175 layer->set_offset_to_transform_parent(parent_offset + local_offset); |
| 176 layer->set_should_flatten_transform_from_property_tree( |
| 177 data_from_ancestor.should_flatten); |
176 layer->set_transform_tree_index(transform_parent->transform_tree_index()); | 178 layer->set_transform_tree_index(transform_parent->transform_tree_index()); |
177 return; | 179 return; |
178 } | 180 } |
179 | 181 |
180 int parent_index = 0; | 182 int parent_index = 0; |
181 if (transform_parent) | 183 if (transform_parent) |
182 parent_index = transform_parent->transform_tree_index(); | 184 parent_index = transform_parent->transform_tree_index(); |
183 | 185 |
184 data_for_children->transform_tree->Insert(TransformNode(), parent_index); | 186 data_for_children->transform_tree->Insert(TransformNode(), parent_index); |
185 | 187 |
186 TransformNode* node = data_for_children->transform_tree->back(); | 188 TransformNode* node = data_for_children->transform_tree->back(); |
187 layer->set_transform_tree_index(node->id); | 189 layer->set_transform_tree_index(node->id); |
188 | 190 |
189 node->data.scrolls = is_scrollable; | 191 node->data.scrolls = is_scrollable; |
190 node->data.flattens_inherited_transform = data_for_children->should_flatten; | 192 node->data.flattens_inherited_transform = data_for_children->should_flatten; |
191 node->data.flattens_local_transform = layer->should_flatten_transform(); | 193 |
192 data_for_children->should_flatten = false; | 194 // Surfaces inherently flatten transforms. |
| 195 data_for_children->should_flatten = |
| 196 layer->should_flatten_transform() || has_surface; |
193 node->data.target_id = | 197 node->data.target_id = |
194 data_from_ancestor.render_target->transform_tree_index(); | 198 data_from_ancestor.render_target->transform_tree_index(); |
195 node->data.content_target_id = | 199 node->data.content_target_id = |
196 data_for_children->render_target->transform_tree_index(); | 200 data_for_children->render_target->transform_tree_index(); |
197 DCHECK_NE(node->data.target_id, -1); | 201 DCHECK_NE(node->data.target_id, -1); |
198 node->data.is_animated = layer->TransformIsAnimating(); | 202 node->data.is_animated = layer->TransformIsAnimating(); |
199 | 203 |
200 float scale_factors = 1.0f; | 204 float scale_factors = 1.0f; |
201 if (is_root) { | 205 if (is_root) { |
202 node->data.post_local = *data_from_ancestor.device_transform; | 206 node->data.post_local = *data_from_ancestor.device_transform; |
(...skipping 23 matching lines...) Expand all Loading... |
226 | 230 |
227 node->data.local = layer->transform(); | 231 node->data.local = layer->transform(); |
228 node->data.pre_local.Translate3d(-layer->transform_origin().x(), | 232 node->data.pre_local.Translate3d(-layer->transform_origin().x(), |
229 -layer->transform_origin().y(), | 233 -layer->transform_origin().y(), |
230 -layer->transform_origin().z()); | 234 -layer->transform_origin().z()); |
231 | 235 |
232 node->data.needs_local_transform_update = true; | 236 node->data.needs_local_transform_update = true; |
233 data_from_ancestor.transform_tree->UpdateTransforms(node->id); | 237 data_from_ancestor.transform_tree->UpdateTransforms(node->id); |
234 | 238 |
235 layer->set_offset_to_transform_parent(gfx::Vector2dF()); | 239 layer->set_offset_to_transform_parent(gfx::Vector2dF()); |
| 240 |
| 241 // Flattening (if needed) will be handled by |node|. |
| 242 layer->set_should_flatten_transform_from_property_tree(false); |
236 } | 243 } |
237 | 244 |
238 void AddOpacityNodeIfNeeded(const DataForRecursion& data_from_ancestor, | 245 void AddOpacityNodeIfNeeded(const DataForRecursion& data_from_ancestor, |
239 Layer* layer, | 246 Layer* layer, |
240 DataForRecursion* data_for_children) { | 247 DataForRecursion* data_for_children) { |
241 const bool is_root = !layer->parent(); | 248 const bool is_root = !layer->parent(); |
242 const bool has_transparency = layer->opacity() != 1.f; | 249 const bool has_transparency = layer->opacity() != 1.f; |
243 const bool has_animated_opacity = | 250 const bool has_animated_opacity = |
244 layer->layer_animation_controller()->IsAnimatingProperty( | 251 layer->layer_animation_controller()->IsAnimatingProperty( |
245 Animation::OPACITY) || | 252 Animation::OPACITY) || |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 data_for_recursion.device_transform = &device_transform; | 327 data_for_recursion.device_transform = &device_transform; |
321 | 328 |
322 ClipNode root_clip; | 329 ClipNode root_clip; |
323 root_clip.data.clip = viewport; | 330 root_clip.data.clip = viewport; |
324 root_clip.data.transform_id = 0; | 331 root_clip.data.transform_id = 0; |
325 data_for_recursion.clip_tree_parent = clip_tree->Insert(root_clip, 0); | 332 data_for_recursion.clip_tree_parent = clip_tree->Insert(root_clip, 0); |
326 BuildPropertyTreesInternal(root_layer, data_for_recursion); | 333 BuildPropertyTreesInternal(root_layer, data_for_recursion); |
327 } | 334 } |
328 | 335 |
329 } // namespace cc | 336 } // namespace cc |
OLD | NEW |