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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 data_for_children->clip_tree_parent = | 449 data_for_children->clip_tree_parent = |
450 data_for_children->property_trees->clip_tree.Insert(node, parent_id); | 450 data_for_children->property_trees->clip_tree.Insert(node, parent_id); |
451 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = | 451 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = |
452 data_for_children->clip_tree_parent; | 452 data_for_children->clip_tree_parent; |
453 } | 453 } |
454 | 454 |
455 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); | 455 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
456 } | 456 } |
457 | 457 |
458 template <typename LayerType> | 458 template <typename LayerType> |
| 459 void AddClipNodeOnlyIfLayerClipsSubtree( |
| 460 const DataForRecursion<LayerType>& data_from_ancestor, |
| 461 LayerType* layer, |
| 462 bool created_render_surface, |
| 463 bool created_transform_node, |
| 464 DataForRecursion<LayerType>* data_for_children) { |
| 465 const bool inherits_clip = !ClipParent(layer); |
| 466 const int parent_id = inherits_clip ? data_from_ancestor.clip_tree_parent |
| 467 : ClipParent(layer)->clip_tree_index(); |
| 468 ClipNode* parent = |
| 469 data_from_ancestor.property_trees->clip_tree.Node(parent_id); |
| 470 |
| 471 bool apply_ancestor_clip = false; |
| 472 if (inherits_clip) { |
| 473 apply_ancestor_clip = data_from_ancestor.apply_ancestor_clip; |
| 474 } else { |
| 475 const EffectNode* parent_effect_node = |
| 476 data_from_ancestor.property_trees->effect_tree.Node( |
| 477 ClipParent(layer)->effect_tree_parent()); |
| 478 if (parent_effect_node->clip_id == parent->id) { |
| 479 if (parent_effect_node->surface_is_clipped) { |
| 480 // In this case, there is no clipping layer between the clip parent and |
| 481 // its target and the target has applied the clip. |
| 482 apply_ancestor_clip = false; |
| 483 } else { |
| 484 // In this case, there is no clipping layer between the clip parent and |
| 485 // its target and the target has not applied the clip. There are two |
| 486 // cases when a target doesn't apply clip. First, there is no ancestor |
| 487 // clip to apply, in this case apply_ancestor_clip should be false. |
| 488 // Second, there is a clip to apply but there are unclipped descendants, |
| 489 // so the target cannot apply the clip. In this case, |
| 490 // apply_ancestor_clip should be true. |
| 491 apply_ancestor_clip = parent_effect_node->has_unclipped_descendants; |
| 492 } |
| 493 } else { |
| 494 // In this case, there is a clipping layer between the clip parent and |
| 495 // its target. |
| 496 apply_ancestor_clip = true; |
| 497 } |
| 498 } |
| 499 if (created_render_surface) |
| 500 SetSurfaceIsClipped(data_for_children, apply_ancestor_clip, layer); |
| 501 |
| 502 bool layer_clips_subtree = LayerClipsSubtree(layer); |
| 503 if (layer_clips_subtree) { |
| 504 data_for_children->apply_ancestor_clip = true; |
| 505 } |
| 506 |
| 507 if (!layer_clips_subtree) { |
| 508 data_for_children->clip_tree_parent = parent_id; |
| 509 } else { |
| 510 LayerType* transform_parent = data_for_children->transform_tree_parent; |
| 511 if (PositionConstraint(layer).is_fixed_position() && |
| 512 !created_transform_node) { |
| 513 transform_parent = data_for_children->transform_fixed_parent; |
| 514 } |
| 515 ClipNode node; |
| 516 node.clip = gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), |
| 517 gfx::SizeF(layer->bounds())); |
| 518 node.transform_id = transform_parent->transform_tree_index(); |
| 519 node.owner_id = layer->id(); |
| 520 if (layer_clips_subtree) |
| 521 node.clip_type = ClipNode::ClipType::APPLIES_LOCAL_CLIP; |
| 522 else |
| 523 node.clip_type = ClipNode::ClipType::NONE; |
| 524 data_for_children->clip_tree_parent = |
| 525 data_for_children->property_trees->clip_tree.Insert(node, parent_id); |
| 526 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = |
| 527 data_for_children->clip_tree_parent; |
| 528 } |
| 529 |
| 530 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
| 531 } |
| 532 |
| 533 template <typename LayerType> |
459 static inline bool IsAtBoundaryOf3dRenderingContext(LayerType* layer) { | 534 static inline bool IsAtBoundaryOf3dRenderingContext(LayerType* layer) { |
460 return Parent(layer) | 535 return Parent(layer) |
461 ? Parent(layer)->sorting_context_id() != | 536 ? Parent(layer)->sorting_context_id() != |
462 layer->sorting_context_id() | 537 layer->sorting_context_id() |
463 : layer->Is3dSorted(); | 538 : layer->Is3dSorted(); |
464 } | 539 } |
465 | 540 |
466 static inline gfx::Point3F TransformOrigin(Layer* layer) { | 541 static inline gfx::Point3F TransformOrigin(Layer* layer) { |
467 return layer->transform_origin(); | 542 return layer->transform_origin(); |
468 } | 543 } |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 color = SkColorSetA(color, 255); | 1579 color = SkColorSetA(color, 255); |
1505 BuildPropertyTreesTopLevelInternal( | 1580 BuildPropertyTreesTopLevelInternal( |
1506 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1581 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
1507 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1582 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
1508 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1583 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
1509 device_transform, property_trees, color); | 1584 device_transform, property_trees, color); |
1510 property_trees->ResetCachedData(); | 1585 property_trees->ResetCachedData(); |
1511 } | 1586 } |
1512 | 1587 |
1513 } // namespace cc | 1588 } // namespace cc |
OLD | NEW |