| 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/draw_property_utils.h" | 5 #include "cc/trees/draw_property_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // transforms. Say we have the following tree T->A->B->C, and B clips C, but | 523 // transforms. Say we have the following tree T->A->B->C, and B clips C, but |
| 524 // draw into target T. It may be the case that A applies a perspective | 524 // draw into target T. It may be the case that A applies a perspective |
| 525 // transform, and B and C are at different z positions. When projected into | 525 // transform, and B and C are at different z positions. When projected into |
| 526 // target space, the relative sizes and positions of B and C can shift. | 526 // target space, the relative sizes and positions of B and C can shift. |
| 527 // Since it's the relationship in target space that matters, that's where we | 527 // Since it's the relationship in target space that matters, that's where we |
| 528 // must combine clips. For each clip node, we save the clip rects in its | 528 // must combine clips. For each clip node, we save the clip rects in its |
| 529 // target space. So, we need to get the ancestor clip rect in the current | 529 // target space. So, we need to get the ancestor clip rect in the current |
| 530 // clip node's target space. | 530 // clip node's target space. |
| 531 gfx::RectF parent_combined_clip_in_target_space = | 531 gfx::RectF parent_combined_clip_in_target_space = |
| 532 parent_clip_node->data.combined_clip_in_target_space; | 532 parent_clip_node->data.combined_clip_in_target_space; |
| 533 gfx::RectF parent_clip_in_target_space = |
| 534 parent_clip_node->data.clip_in_target_space; |
| 533 if (parent_clip_node->data.target_id != clip_node->data.target_id && | 535 if (parent_clip_node->data.target_id != clip_node->data.target_id && |
| 534 non_root_surfaces_enabled) { | 536 non_root_surfaces_enabled) { |
| 535 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( | 537 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 536 parent_clip_node->data.target_id, clip_node->data.target_id, | 538 parent_clip_node->data.target_id, clip_node->data.target_id, |
| 537 &parent_to_current); | 539 &parent_to_current); |
| 538 if (parent_transform_node->data.sublayer_scale.x() > 0 && | 540 if (parent_transform_node->data.sublayer_scale.x() > 0 && |
| 539 parent_transform_node->data.sublayer_scale.y() > 0) | 541 parent_transform_node->data.sublayer_scale.y() > 0) |
| 540 parent_to_current.Scale( | 542 parent_to_current.Scale( |
| 541 1.f / parent_transform_node->data.sublayer_scale.x(), | 543 1.f / parent_transform_node->data.sublayer_scale.x(), |
| 542 1.f / parent_transform_node->data.sublayer_scale.y()); | 544 1.f / parent_transform_node->data.sublayer_scale.y()); |
| 543 // If we can't compute a transform, it's because we had to use the inverse | 545 // If we can't compute a transform, it's because we had to use the inverse |
| 544 // of a singular transform. We won't draw in this case, so there's no need | 546 // of a singular transform. We won't draw in this case, so there's no need |
| 545 // to compute clips. | 547 // to compute clips. |
| 546 if (!success) | 548 if (!success) |
| 547 continue; | 549 continue; |
| 548 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 550 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 549 parent_to_current, | 551 parent_to_current, |
| 550 parent_clip_node->data.combined_clip_in_target_space); | 552 parent_clip_node->data.combined_clip_in_target_space); |
| 553 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 554 parent_to_current, parent_clip_node->data.clip_in_target_space); |
| 551 } | 555 } |
| 552 // Only nodes affected by ancestor clips will have their clip adjusted due | 556 // Only nodes affected by ancestor clips will have their clip adjusted due |
| 553 // to intersecting with an ancestor clip. But, we still need to propagate | 557 // to intersecting with an ancestor clip. But, we still need to propagate |
| 554 // the combined clip to our children because if they are clipped, they may | 558 // the combined clip to our children because if they are clipped, they may |
| 555 // need to clip using our parent clip and if we don't propagate it here, | 559 // need to clip using our parent clip and if we don't propagate it here, |
| 556 // it will be lost. | 560 // it will be lost. |
| 557 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { | 561 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { |
| 558 if (clip_node->data.applies_local_clip) { | 562 if (clip_node->data.applies_local_clip) { |
| 559 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( | 563 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( |
| 560 transform_node->data.to_target, clip_node->data.clip); | 564 transform_node->data.to_target, clip_node->data.clip); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 572 continue; | 576 continue; |
| 573 } | 577 } |
| 574 bool use_only_parent_clip = !clip_node->data.applies_local_clip; | 578 bool use_only_parent_clip = !clip_node->data.applies_local_clip; |
| 575 if (use_only_parent_clip) { | 579 if (use_only_parent_clip) { |
| 576 clip_node->data.combined_clip_in_target_space = | 580 clip_node->data.combined_clip_in_target_space = |
| 577 parent_combined_clip_in_target_space; | 581 parent_combined_clip_in_target_space; |
| 578 if (!non_root_surfaces_enabled) { | 582 if (!non_root_surfaces_enabled) { |
| 579 clip_node->data.clip_in_target_space = | 583 clip_node->data.clip_in_target_space = |
| 580 parent_clip_node->data.clip_in_target_space; | 584 parent_clip_node->data.clip_in_target_space; |
| 581 } else if (!clip_node->data.target_is_clipped) { | 585 } else if (!clip_node->data.target_is_clipped) { |
| 582 clip_node->data.clip_in_target_space = | 586 clip_node->data.clip_in_target_space = parent_clip_in_target_space; |
| 583 parent_combined_clip_in_target_space; | |
| 584 } else { | 587 } else { |
| 585 // Render Surface applies clip and the owning layer itself applies | 588 // Render Surface applies clip and the owning layer itself applies |
| 586 // no clip. So, clip_in_target_space is not used and hence we can set | 589 // no clip. So, clip_in_target_space is not used and hence we can set |
| 587 // it to an empty rect. | 590 // it to an empty rect. |
| 588 clip_node->data.clip_in_target_space = gfx::RectF(); | 591 clip_node->data.clip_in_target_space = gfx::RectF(); |
| 589 } | 592 } |
| 590 } else { | 593 } else { |
| 591 gfx::Transform source_to_target; | 594 gfx::Transform source_to_target; |
| 592 | 595 |
| 593 if (!non_root_surfaces_enabled) { | 596 if (!non_root_surfaces_enabled) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 608 | 611 |
| 609 // With surfaces disabled, the only case where we use only the local clip | 612 // With surfaces disabled, the only case where we use only the local clip |
| 610 // for layer clipping is the case where no non-viewport ancestor node | 613 // for layer clipping is the case where no non-viewport ancestor node |
| 611 // applies a local clip. | 614 // applies a local clip. |
| 612 bool layer_clipping_uses_only_local_clip = | 615 bool layer_clipping_uses_only_local_clip = |
| 613 non_root_surfaces_enabled | 616 non_root_surfaces_enabled |
| 614 ? clip_node->data.layer_clipping_uses_only_local_clip | 617 ? clip_node->data.layer_clipping_uses_only_local_clip |
| 615 : !parent_clip_node->data | 618 : !parent_clip_node->data |
| 616 .layers_are_clipped_when_surfaces_disabled; | 619 .layers_are_clipped_when_surfaces_disabled; |
| 617 if (!layer_clipping_uses_only_local_clip) { | 620 if (!layer_clipping_uses_only_local_clip) { |
| 618 gfx::RectF parent_clip_in_target_space = MathUtil::ProjectClippedRect( | |
| 619 parent_to_current, parent_clip_node->data.clip_in_target_space); | |
| 620 clip_node->data.clip_in_target_space = gfx::IntersectRects( | 621 clip_node->data.clip_in_target_space = gfx::IntersectRects( |
| 621 parent_clip_in_target_space, source_clip_in_target_space); | 622 parent_clip_in_target_space, source_clip_in_target_space); |
| 622 } else { | 623 } else { |
| 623 clip_node->data.clip_in_target_space = source_clip_in_target_space; | 624 clip_node->data.clip_in_target_space = source_clip_in_target_space; |
| 624 } | 625 } |
| 625 | 626 |
| 626 clip_node->data.combined_clip_in_target_space = gfx::IntersectRects( | 627 clip_node->data.combined_clip_in_target_space = gfx::IntersectRects( |
| 627 parent_combined_clip_in_target_space, source_clip_in_target_space); | 628 parent_combined_clip_in_target_space, source_clip_in_target_space); |
| 628 } | 629 } |
| 629 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); | 630 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1128 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1128 const Layer* overscroll_elasticity_layer, | 1129 const Layer* overscroll_elasticity_layer, |
| 1129 const gfx::Vector2dF& elastic_overscroll) { | 1130 const gfx::Vector2dF& elastic_overscroll) { |
| 1130 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1131 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1131 elastic_overscroll); | 1132 elastic_overscroll); |
| 1132 } | 1133 } |
| 1133 | 1134 |
| 1134 } // namespace draw_property_utils | 1135 } // namespace draw_property_utils |
| 1135 | 1136 |
| 1136 } // namespace cc | 1137 } // namespace cc |
| OLD | NEW |