| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 struct DataForRecursionFromChild { | 65 struct DataForRecursionFromChild { |
| 66 int num_copy_requests_in_subtree; | 66 int num_copy_requests_in_subtree; |
| 67 | 67 |
| 68 DataForRecursionFromChild() : num_copy_requests_in_subtree(0) {} | 68 DataForRecursionFromChild() : num_copy_requests_in_subtree(0) {} |
| 69 | 69 |
| 70 void Merge(const DataForRecursionFromChild& data) { | 70 void Merge(const DataForRecursionFromChild& data) { |
| 71 num_copy_requests_in_subtree += data.num_copy_requests_in_subtree; | 71 num_copy_requests_in_subtree += data.num_copy_requests_in_subtree; |
| 72 } | 72 } |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 static LayerPositionConstraint PositionConstraint(Layer* layer) { |
| 76 return layer->position_constraint(); |
| 77 } |
| 78 |
| 79 static LayerPositionConstraint PositionConstraint(LayerImpl* layer) { |
| 80 return layer->test_properties()->position_constraint; |
| 81 } |
| 82 |
| 75 template <typename LayerType> | 83 template <typename LayerType> |
| 76 static LayerType* GetTransformParent(const DataForRecursion<LayerType>& data, | 84 static LayerType* GetTransformParent(const DataForRecursion<LayerType>& data, |
| 77 LayerType* layer) { | 85 LayerType* layer) { |
| 78 return layer->position_constraint().is_fixed_position() | 86 return PositionConstraint(layer).is_fixed_position() |
| 79 ? data.transform_fixed_parent | 87 ? data.transform_fixed_parent |
| 80 : data.transform_tree_parent; | 88 : data.transform_tree_parent; |
| 81 } | 89 } |
| 82 | 90 |
| 83 template <typename LayerType> | 91 template <typename LayerType> |
| 84 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, | 92 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, |
| 85 LayerType* layer) { | 93 LayerType* layer) { |
| 86 const bool inherits_clip = !layer->clip_parent(); | 94 const bool inherits_clip = !layer->clip_parent(); |
| 87 const int id = inherits_clip ? data.clip_tree_parent | 95 const int id = inherits_clip ? data.clip_tree_parent |
| 88 : layer->clip_parent()->clip_tree_index(); | 96 : layer->clip_parent()->clip_tree_index(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // a clip node for every render surface. | 170 // a clip node for every render surface. |
| 163 bool requires_node = layer_clips_subtree || created_render_surface; | 171 bool requires_node = layer_clips_subtree || created_render_surface; |
| 164 | 172 |
| 165 if (!requires_node) { | 173 if (!requires_node) { |
| 166 data_for_children->clip_tree_parent = parent_id; | 174 data_for_children->clip_tree_parent = parent_id; |
| 167 DCHECK_EQ(layers_are_clipped, parent->data.layers_are_clipped); | 175 DCHECK_EQ(layers_are_clipped, parent->data.layers_are_clipped); |
| 168 DCHECK_EQ(layers_are_clipped_when_surfaces_disabled, | 176 DCHECK_EQ(layers_are_clipped_when_surfaces_disabled, |
| 169 parent->data.layers_are_clipped_when_surfaces_disabled); | 177 parent->data.layers_are_clipped_when_surfaces_disabled); |
| 170 } else { | 178 } else { |
| 171 LayerType* transform_parent = data_for_children->transform_tree_parent; | 179 LayerType* transform_parent = data_for_children->transform_tree_parent; |
| 172 if (layer->position_constraint().is_fixed_position() && | 180 if (PositionConstraint(layer).is_fixed_position() && |
| 173 !created_transform_node) { | 181 !created_transform_node) { |
| 174 transform_parent = data_for_children->transform_fixed_parent; | 182 transform_parent = data_for_children->transform_fixed_parent; |
| 175 } | 183 } |
| 176 ClipNode node; | 184 ClipNode node; |
| 177 node.data.clip = | 185 node.data.clip = |
| 178 gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), | 186 gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), |
| 179 gfx::SizeF(layer->bounds())); | 187 gfx::SizeF(layer->bounds())); |
| 180 node.data.transform_id = transform_parent->transform_tree_index(); | 188 node.data.transform_id = transform_parent->transform_tree_index(); |
| 181 node.data.target_id = | 189 node.data.target_id = |
| 182 data_for_children->effect_tree->Node(data_for_children->render_target) | 190 data_for_children->effect_tree->Node(data_for_children->render_target) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 229 } |
| 222 | 230 |
| 223 static inline gfx::Point3F TransformOrigin(Layer* layer) { | 231 static inline gfx::Point3F TransformOrigin(Layer* layer) { |
| 224 return layer->transform_origin(); | 232 return layer->transform_origin(); |
| 225 } | 233 } |
| 226 | 234 |
| 227 static inline gfx::Point3F TransformOrigin(LayerImpl* layer) { | 235 static inline gfx::Point3F TransformOrigin(LayerImpl* layer) { |
| 228 return layer->test_properties()->transform_origin; | 236 return layer->test_properties()->transform_origin; |
| 229 } | 237 } |
| 230 | 238 |
| 239 static inline bool IsContainerForFixedPositionLayers(Layer* layer) { |
| 240 return layer->IsContainerForFixedPositionLayers(); |
| 241 } |
| 242 |
| 243 static inline bool IsContainerForFixedPositionLayers(LayerImpl* layer) { |
| 244 return layer->test_properties()->is_container_for_fixed_position_layers; |
| 245 } |
| 246 |
| 247 static inline bool ShouldFlattenTransform(Layer* layer) { |
| 248 return layer->should_flatten_transform(); |
| 249 } |
| 250 |
| 251 static inline bool ShouldFlattenTransform(LayerImpl* layer) { |
| 252 return layer->test_properties()->should_flatten_transform; |
| 253 } |
| 254 |
| 231 template <typename LayerType> | 255 template <typename LayerType> |
| 232 bool AddTransformNodeIfNeeded( | 256 bool AddTransformNodeIfNeeded( |
| 233 const DataForRecursion<LayerType>& data_from_ancestor, | 257 const DataForRecursion<LayerType>& data_from_ancestor, |
| 234 LayerType* layer, | 258 LayerType* layer, |
| 235 bool created_render_surface, | 259 bool created_render_surface, |
| 236 DataForRecursion<LayerType>* data_for_children) { | 260 DataForRecursion<LayerType>* data_for_children) { |
| 237 const bool is_root = !layer->parent(); | 261 const bool is_root = !layer->parent(); |
| 238 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; | 262 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; |
| 239 const bool is_overscroll_elasticity_layer = | 263 const bool is_overscroll_elasticity_layer = |
| 240 layer == data_from_ancestor.overscroll_elasticity_layer; | 264 layer == data_from_ancestor.overscroll_elasticity_layer; |
| 241 const bool is_scrollable = layer->scrollable(); | 265 const bool is_scrollable = layer->scrollable(); |
| 242 const bool is_fixed = layer->position_constraint().is_fixed_position(); | 266 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); |
| 243 | 267 |
| 244 const bool has_significant_transform = | 268 const bool has_significant_transform = |
| 245 !layer->transform().IsIdentityOr2DTranslation(); | 269 !layer->transform().IsIdentityOr2DTranslation(); |
| 246 | 270 |
| 247 const bool has_potentially_animated_transform = | 271 const bool has_potentially_animated_transform = |
| 248 layer->HasPotentiallyRunningTransformAnimation(); | 272 layer->HasPotentiallyRunningTransformAnimation(); |
| 249 | 273 |
| 250 // A transform node is needed even for a finished animation, since differences | 274 // A transform node is needed even for a finished animation, since differences |
| 251 // in the timing of animation state updates can mean that an animation that's | 275 // in the timing of animation state updates can mean that an animation that's |
| 252 // in the Finished state at tree-building time on the main thread is still in | 276 // in the Finished state at tree-building time on the main thread is still in |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 source_offset = transform_parent->offset_to_transform_parent(); | 316 source_offset = transform_parent->offset_to_transform_parent(); |
| 293 } else { | 317 } else { |
| 294 source_offset = data_from_ancestor.transform_tree_parent | 318 source_offset = data_from_ancestor.transform_tree_parent |
| 295 ->offset_to_transform_parent(); | 319 ->offset_to_transform_parent(); |
| 296 source_index = | 320 source_index = |
| 297 data_from_ancestor.transform_tree_parent->transform_tree_index(); | 321 data_from_ancestor.transform_tree_parent->transform_tree_index(); |
| 298 source_offset -= data_from_ancestor.scroll_snap; | 322 source_offset -= data_from_ancestor.scroll_snap; |
| 299 } | 323 } |
| 300 } | 324 } |
| 301 | 325 |
| 302 if (layer->IsContainerForFixedPositionLayers() || is_root) { | 326 if (IsContainerForFixedPositionLayers(layer) || is_root) { |
| 303 data_for_children->affected_by_inner_viewport_bounds_delta = | 327 data_for_children->affected_by_inner_viewport_bounds_delta = |
| 304 layer == data_from_ancestor.inner_viewport_scroll_layer; | 328 layer == data_from_ancestor.inner_viewport_scroll_layer; |
| 305 data_for_children->affected_by_outer_viewport_bounds_delta = | 329 data_for_children->affected_by_outer_viewport_bounds_delta = |
| 306 layer == data_from_ancestor.outer_viewport_scroll_layer; | 330 layer == data_from_ancestor.outer_viewport_scroll_layer; |
| 307 if (is_scrollable) { | 331 if (is_scrollable) { |
| 308 DCHECK(!is_root); | 332 DCHECK(!is_root); |
| 309 DCHECK(layer->transform().IsIdentity()); | 333 DCHECK(layer->transform().IsIdentity()); |
| 310 data_for_children->transform_fixed_parent = layer->parent(); | 334 data_for_children->transform_fixed_parent = layer->parent(); |
| 311 } else { | 335 } else { |
| 312 data_for_children->transform_fixed_parent = layer; | 336 data_for_children->transform_fixed_parent = layer; |
| 313 } | 337 } |
| 314 } | 338 } |
| 315 data_for_children->transform_tree_parent = layer; | 339 data_for_children->transform_tree_parent = layer; |
| 316 | 340 |
| 317 if (layer->IsContainerForFixedPositionLayers() || is_fixed) | 341 if (IsContainerForFixedPositionLayers(layer) || is_fixed) |
| 318 data_for_children->scroll_snap = gfx::Vector2dF(); | 342 data_for_children->scroll_snap = gfx::Vector2dF(); |
| 319 | 343 |
| 320 if (!requires_node) { | 344 if (!requires_node) { |
| 321 data_for_children->should_flatten |= layer->should_flatten_transform(); | 345 data_for_children->should_flatten |= ShouldFlattenTransform(layer); |
| 322 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + | 346 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + |
| 323 layer->transform().To2dTranslation(); | 347 layer->transform().To2dTranslation(); |
| 324 gfx::Vector2dF source_to_parent; | 348 gfx::Vector2dF source_to_parent; |
| 325 if (source_index != parent_index) { | 349 if (source_index != parent_index) { |
| 326 gfx::Transform to_parent; | 350 gfx::Transform to_parent; |
| 327 data_from_ancestor.transform_tree->ComputeTransform( | 351 data_from_ancestor.transform_tree->ComputeTransform( |
| 328 source_index, parent_index, &to_parent); | 352 source_index, parent_index, &to_parent); |
| 329 source_to_parent = to_parent.To2dTranslation(); | 353 source_to_parent = to_parent.To2dTranslation(); |
| 330 } | 354 } |
| 331 layer->set_offset_to_transform_parent(source_offset + source_to_parent + | 355 layer->set_offset_to_transform_parent(source_offset + source_to_parent + |
| (...skipping 18 matching lines...) Expand all Loading... |
| 350 | 374 |
| 351 node->data.sorting_context_id = layer->sorting_context_id(); | 375 node->data.sorting_context_id = layer->sorting_context_id(); |
| 352 | 376 |
| 353 if (layer == data_from_ancestor.page_scale_layer) | 377 if (layer == data_from_ancestor.page_scale_layer) |
| 354 data_for_children->in_subtree_of_page_scale_layer = true; | 378 data_for_children->in_subtree_of_page_scale_layer = true; |
| 355 node->data.in_subtree_of_page_scale_layer = | 379 node->data.in_subtree_of_page_scale_layer = |
| 356 data_for_children->in_subtree_of_page_scale_layer; | 380 data_for_children->in_subtree_of_page_scale_layer; |
| 357 | 381 |
| 358 // Surfaces inherently flatten transforms. | 382 // Surfaces inherently flatten transforms. |
| 359 data_for_children->should_flatten = | 383 data_for_children->should_flatten = |
| 360 layer->should_flatten_transform() || has_surface; | 384 ShouldFlattenTransform(layer) || has_surface; |
| 361 DCHECK_GT(data_from_ancestor.effect_tree->size(), 0u); | 385 DCHECK_GT(data_from_ancestor.effect_tree->size(), 0u); |
| 362 | 386 |
| 363 node->data.target_id = | 387 node->data.target_id = |
| 364 data_for_children->effect_tree->Node(data_from_ancestor.render_target) | 388 data_for_children->effect_tree->Node(data_from_ancestor.render_target) |
| 365 ->data.transform_id; | 389 ->data.transform_id; |
| 366 node->data.content_target_id = | 390 node->data.content_target_id = |
| 367 data_for_children->effect_tree->Node(data_for_children->render_target) | 391 data_for_children->effect_tree->Node(data_for_children->render_target) |
| 368 ->data.transform_id; | 392 ->data.transform_id; |
| 369 DCHECK_NE(node->data.target_id, kInvalidPropertyTreeNodeId); | 393 DCHECK_NE(node->data.target_id, kInvalidPropertyTreeNodeId); |
| 370 | 394 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 DCHECK(!is_scrollable); | 440 DCHECK(!is_scrollable); |
| 417 node->data.scroll_offset = | 441 node->data.scroll_offset = |
| 418 gfx::ScrollOffset(data_from_ancestor.elastic_overscroll); | 442 gfx::ScrollOffset(data_from_ancestor.elastic_overscroll); |
| 419 } else if (!layer->scroll_parent()) { | 443 } else if (!layer->scroll_parent()) { |
| 420 node->data.scroll_offset = layer->CurrentScrollOffset(); | 444 node->data.scroll_offset = layer->CurrentScrollOffset(); |
| 421 } | 445 } |
| 422 | 446 |
| 423 if (is_fixed) { | 447 if (is_fixed) { |
| 424 if (data_from_ancestor.affected_by_inner_viewport_bounds_delta) { | 448 if (data_from_ancestor.affected_by_inner_viewport_bounds_delta) { |
| 425 node->data.affected_by_inner_viewport_bounds_delta_x = | 449 node->data.affected_by_inner_viewport_bounds_delta_x = |
| 426 layer->position_constraint().is_fixed_to_right_edge(); | 450 PositionConstraint(layer).is_fixed_to_right_edge(); |
| 427 node->data.affected_by_inner_viewport_bounds_delta_y = | 451 node->data.affected_by_inner_viewport_bounds_delta_y = |
| 428 layer->position_constraint().is_fixed_to_bottom_edge(); | 452 PositionConstraint(layer).is_fixed_to_bottom_edge(); |
| 429 if (node->data.affected_by_inner_viewport_bounds_delta_x || | 453 if (node->data.affected_by_inner_viewport_bounds_delta_x || |
| 430 node->data.affected_by_inner_viewport_bounds_delta_y) { | 454 node->data.affected_by_inner_viewport_bounds_delta_y) { |
| 431 data_for_children->transform_tree | 455 data_for_children->transform_tree |
| 432 ->AddNodeAffectedByInnerViewportBoundsDelta(node->id); | 456 ->AddNodeAffectedByInnerViewportBoundsDelta(node->id); |
| 433 } | 457 } |
| 434 } else if (data_from_ancestor.affected_by_outer_viewport_bounds_delta) { | 458 } else if (data_from_ancestor.affected_by_outer_viewport_bounds_delta) { |
| 435 node->data.affected_by_outer_viewport_bounds_delta_x = | 459 node->data.affected_by_outer_viewport_bounds_delta_x = |
| 436 layer->position_constraint().is_fixed_to_right_edge(); | 460 PositionConstraint(layer).is_fixed_to_right_edge(); |
| 437 node->data.affected_by_outer_viewport_bounds_delta_y = | 461 node->data.affected_by_outer_viewport_bounds_delta_y = |
| 438 layer->position_constraint().is_fixed_to_bottom_edge(); | 462 PositionConstraint(layer).is_fixed_to_bottom_edge(); |
| 439 if (node->data.affected_by_outer_viewport_bounds_delta_x || | 463 if (node->data.affected_by_outer_viewport_bounds_delta_x || |
| 440 node->data.affected_by_outer_viewport_bounds_delta_y) { | 464 node->data.affected_by_outer_viewport_bounds_delta_y) { |
| 441 data_for_children->transform_tree | 465 data_for_children->transform_tree |
| 442 ->AddNodeAffectedByOuterViewportBoundsDelta(node->id); | 466 ->AddNodeAffectedByOuterViewportBoundsDelta(node->id); |
| 443 } | 467 } |
| 444 } | 468 } |
| 445 } | 469 } |
| 446 | 470 |
| 447 node->data.local = layer->transform(); | 471 node->data.local = layer->transform(); |
| 448 node->data.update_pre_local_transform(TransformOrigin(layer)); | 472 node->data.update_pre_local_transform(TransformOrigin(layer)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return layer->test_properties()->force_render_surface; | 511 return layer->test_properties()->force_render_surface; |
| 488 } | 512 } |
| 489 | 513 |
| 490 template <typename LayerType> | 514 template <typename LayerType> |
| 491 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | 515 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { |
| 492 return layer->Is3dSorted() && layer->parent() && | 516 return layer->Is3dSorted() && layer->parent() && |
| 493 layer->parent()->Is3dSorted() && | 517 layer->parent()->Is3dSorted() && |
| 494 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); | 518 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); |
| 495 } | 519 } |
| 496 | 520 |
| 521 static inline bool IsRootForIsolatedGroup(Layer* layer) { |
| 522 return layer->is_root_for_isolated_group(); |
| 523 } |
| 524 |
| 525 static inline bool IsRootForIsolatedGroup(LayerImpl* layer) { |
| 526 return false; |
| 527 } |
| 528 |
| 529 static inline int NumDescendantsThatDrawContent(Layer* layer) { |
| 530 return layer->NumDescendantsThatDrawContent(); |
| 531 } |
| 532 |
| 533 static inline int NumDescendantsThatDrawContent(LayerImpl* layer) { |
| 534 return layer->test_properties()->num_descendants_that_draw_content; |
| 535 } |
| 536 |
| 497 template <typename LayerType> | 537 template <typename LayerType> |
| 498 bool ShouldCreateRenderSurface(LayerType* layer, | 538 bool ShouldCreateRenderSurface(LayerType* layer, |
| 499 gfx::Transform current_transform, | 539 gfx::Transform current_transform, |
| 500 bool axis_aligned) { | 540 bool axis_aligned) { |
| 501 const bool preserves_2d_axis_alignment = | 541 const bool preserves_2d_axis_alignment = |
| 502 (current_transform * layer->transform()).Preserves2dAxisAlignment() && | 542 (current_transform * layer->transform()).Preserves2dAxisAlignment() && |
| 503 axis_aligned && layer->AnimationsPreserveAxisAlignment(); | 543 axis_aligned && layer->AnimationsPreserveAxisAlignment(); |
| 504 const bool is_root = !layer->parent(); | 544 const bool is_root = !layer->parent(); |
| 505 if (is_root) | 545 if (is_root) |
| 506 return true; | 546 return true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 520 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { | 560 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { |
| 521 return true; | 561 return true; |
| 522 } | 562 } |
| 523 | 563 |
| 524 // If the layer will use a CSS filter. In this case, the animation | 564 // If the layer will use a CSS filter. In this case, the animation |
| 525 // will start and add a filter to this layer, so it needs a surface. | 565 // will start and add a filter to this layer, so it needs a surface. |
| 526 if (layer->HasPotentiallyRunningFilterAnimation()) { | 566 if (layer->HasPotentiallyRunningFilterAnimation()) { |
| 527 return true; | 567 return true; |
| 528 } | 568 } |
| 529 | 569 |
| 530 int num_descendants_that_draw_content = | 570 int num_descendants_that_draw_content = NumDescendantsThatDrawContent(layer); |
| 531 layer->NumDescendantsThatDrawContent(); | |
| 532 | 571 |
| 533 // If the layer flattens its subtree, but it is treated as a 3D object by its | 572 // If the layer flattens its subtree, but it is treated as a 3D object by its |
| 534 // parent (i.e. parent participates in a 3D rendering context). | 573 // parent (i.e. parent participates in a 3D rendering context). |
| 535 if (LayerIsInExisting3DRenderingContext(layer) && | 574 if (LayerIsInExisting3DRenderingContext(layer) && |
| 536 layer->should_flatten_transform() && | 575 ShouldFlattenTransform(layer) && num_descendants_that_draw_content > 0) { |
| 537 num_descendants_that_draw_content > 0) { | |
| 538 TRACE_EVENT_INSTANT0( | 576 TRACE_EVENT_INSTANT0( |
| 539 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface flattening", | 577 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface flattening", |
| 540 TRACE_EVENT_SCOPE_THREAD); | 578 TRACE_EVENT_SCOPE_THREAD); |
| 541 return true; | 579 return true; |
| 542 } | 580 } |
| 543 | 581 |
| 544 // If the layer has blending. | 582 // If the layer has blending. |
| 545 // TODO(rosca): this is temporary, until blending is implemented for other | 583 // TODO(rosca): this is temporary, until blending is implemented for other |
| 546 // types of quads than RenderPassDrawQuad. Layers having descendants that draw | 584 // types of quads than RenderPassDrawQuad. Layers having descendants that draw |
| 547 // content will still create a separate rendering surface. | 585 // content will still create a separate rendering surface. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 564 | 602 |
| 565 // If the layer has some translucency and does not have a preserves-3d | 603 // If the layer has some translucency and does not have a preserves-3d |
| 566 // transform style. This condition only needs a render surface if two or more | 604 // transform style. This condition only needs a render surface if two or more |
| 567 // layers in the subtree overlap. But checking layer overlaps is unnecessarily | 605 // layers in the subtree overlap. But checking layer overlaps is unnecessarily |
| 568 // costly so instead we conservatively create a surface whenever at least two | 606 // costly so instead we conservatively create a surface whenever at least two |
| 569 // layers draw content for this subtree. | 607 // layers draw content for this subtree. |
| 570 bool at_least_two_layers_in_subtree_draw_content = | 608 bool at_least_two_layers_in_subtree_draw_content = |
| 571 num_descendants_that_draw_content > 0 && | 609 num_descendants_that_draw_content > 0 && |
| 572 (layer->DrawsContent() || num_descendants_that_draw_content > 1); | 610 (layer->DrawsContent() || num_descendants_that_draw_content > 1); |
| 573 | 611 |
| 574 if (layer->EffectiveOpacity() != 1.f && layer->should_flatten_transform() && | 612 if (layer->EffectiveOpacity() != 1.f && ShouldFlattenTransform(layer) && |
| 575 at_least_two_layers_in_subtree_draw_content) { | 613 at_least_two_layers_in_subtree_draw_content) { |
| 576 TRACE_EVENT_INSTANT0( | 614 TRACE_EVENT_INSTANT0( |
| 577 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface opacity", | 615 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface opacity", |
| 578 TRACE_EVENT_SCOPE_THREAD); | 616 TRACE_EVENT_SCOPE_THREAD); |
| 579 DCHECK(!is_root); | 617 DCHECK(!is_root); |
| 580 return true; | 618 return true; |
| 581 } | 619 } |
| 582 // If the layer has isolation. | 620 // If the layer has isolation. |
| 583 // TODO(rosca): to be optimized - create separate rendering surface only when | 621 // TODO(rosca): to be optimized - create separate rendering surface only when |
| 584 // the blending descendants might have access to the content behind this layer | 622 // the blending descendants might have access to the content behind this layer |
| 585 // (layer has transparent background or descendants overflow). | 623 // (layer has transparent background or descendants overflow). |
| 586 // https://code.google.com/p/chromium/issues/detail?id=301738 | 624 // https://code.google.com/p/chromium/issues/detail?id=301738 |
| 587 if (layer->is_root_for_isolated_group()) { | 625 if (IsRootForIsolatedGroup(layer)) { |
| 588 TRACE_EVENT_INSTANT0( | 626 TRACE_EVENT_INSTANT0( |
| 589 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation", | 627 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation", |
| 590 TRACE_EVENT_SCOPE_THREAD); | 628 TRACE_EVENT_SCOPE_THREAD); |
| 591 return true; | 629 return true; |
| 592 } | 630 } |
| 593 | 631 |
| 594 // If we force it. | 632 // If we force it. |
| 595 if (ForceRenderSurface(layer)) | 633 if (ForceRenderSurface(layer)) |
| 596 return true; | 634 return true; |
| 597 | 635 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 if (SkColorGetA(color) != 255) | 1058 if (SkColorGetA(color) != 255) |
| 1021 color = SkColorSetA(color, 255); | 1059 color = SkColorSetA(color, 255); |
| 1022 BuildPropertyTreesTopLevelInternal( | 1060 BuildPropertyTreesTopLevelInternal( |
| 1023 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1061 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 1024 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1062 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 1025 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1063 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 1026 device_transform, property_trees, color); | 1064 device_transform, property_trees, color); |
| 1027 } | 1065 } |
| 1028 | 1066 |
| 1029 } // namespace cc | 1067 } // namespace cc |
| OLD | NEW |