| 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 ResetIfHasNanCoordinate(&clip_node->data.clip); | 553 ResetIfHasNanCoordinate(&clip_node->data.clip); |
| 554 clip_node->data.clip_in_target_space = clip_node->data.clip; | 554 clip_node->data.clip_in_target_space = clip_node->data.clip; |
| 555 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; | 555 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; |
| 556 continue; | 556 continue; |
| 557 } | 557 } |
| 558 const TransformNode* transform_node = | 558 const TransformNode* transform_node = |
| 559 transform_tree.Node(clip_node->data.transform_id); | 559 transform_tree.Node(clip_node->data.transform_id); |
| 560 ClipNode* parent_clip_node = clip_tree->parent(clip_node); | 560 ClipNode* parent_clip_node = clip_tree->parent(clip_node); |
| 561 | 561 |
| 562 gfx::Transform parent_to_current; | 562 gfx::Transform parent_to_current; |
| 563 const TransformNode* parent_transform_node = | 563 const TransformNode* parent_target_transform_node = |
| 564 transform_tree.Node(parent_clip_node->data.transform_id); | 564 transform_tree.Node(parent_clip_node->data.target_id); |
| 565 bool success = true; | 565 bool success = true; |
| 566 | 566 |
| 567 // Clips must be combined in target space. We cannot, for example, combine | 567 // Clips must be combined in target space. We cannot, for example, combine |
| 568 // clips in the space of the child clip. The reason is non-affine | 568 // clips in the space of the child clip. The reason is non-affine |
| 569 // transforms. Say we have the following tree T->A->B->C, and B clips C, but | 569 // transforms. Say we have the following tree T->A->B->C, and B clips C, but |
| 570 // draw into target T. It may be the case that A applies a perspective | 570 // draw into target T. It may be the case that A applies a perspective |
| 571 // transform, and B and C are at different z positions. When projected into | 571 // transform, and B and C are at different z positions. When projected into |
| 572 // target space, the relative sizes and positions of B and C can shift. | 572 // target space, the relative sizes and positions of B and C can shift. |
| 573 // Since it's the relationship in target space that matters, that's where we | 573 // Since it's the relationship in target space that matters, that's where we |
| 574 // must combine clips. For each clip node, we save the clip rects in its | 574 // must combine clips. For each clip node, we save the clip rects in its |
| 575 // target space. So, we need to get the ancestor clip rect in the current | 575 // target space. So, we need to get the ancestor clip rect in the current |
| 576 // clip node's target space. | 576 // clip node's target space. |
| 577 gfx::RectF parent_combined_clip_in_target_space = | 577 gfx::RectF parent_combined_clip_in_target_space = |
| 578 parent_clip_node->data.combined_clip_in_target_space; | 578 parent_clip_node->data.combined_clip_in_target_space; |
| 579 gfx::RectF parent_clip_in_target_space = | 579 gfx::RectF parent_clip_in_target_space = |
| 580 parent_clip_node->data.clip_in_target_space; | 580 parent_clip_node->data.clip_in_target_space; |
| 581 if (parent_clip_node->data.target_id != clip_node->data.target_id && | 581 if (parent_target_transform_node && |
| 582 parent_target_transform_node->id != clip_node->data.target_id && |
| 582 non_root_surfaces_enabled) { | 583 non_root_surfaces_enabled) { |
| 583 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( | 584 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 584 parent_clip_node->data.target_id, clip_node->data.target_id, | 585 parent_target_transform_node->id, clip_node->data.target_id, |
| 585 &parent_to_current); | 586 &parent_to_current); |
| 586 if (parent_transform_node->data.sublayer_scale.x() > 0 && | 587 if (parent_target_transform_node->data.sublayer_scale.x() > 0 && |
| 587 parent_transform_node->data.sublayer_scale.y() > 0) | 588 parent_target_transform_node->data.sublayer_scale.y() > 0) |
| 588 parent_to_current.Scale( | 589 parent_to_current.Scale( |
| 589 1.f / parent_transform_node->data.sublayer_scale.x(), | 590 1.f / parent_target_transform_node->data.sublayer_scale.x(), |
| 590 1.f / parent_transform_node->data.sublayer_scale.y()); | 591 1.f / parent_target_transform_node->data.sublayer_scale.y()); |
| 591 // If we can't compute a transform, it's because we had to use the inverse | 592 // If we can't compute a transform, it's because we had to use the inverse |
| 592 // of a singular transform. We won't draw in this case, so there's no need | 593 // of a singular transform. We won't draw in this case, so there's no need |
| 593 // to compute clips. | 594 // to compute clips. |
| 594 if (!success) | 595 if (!success) |
| 595 continue; | 596 continue; |
| 596 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 597 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 597 parent_to_current, | 598 parent_to_current, |
| 598 parent_clip_node->data.combined_clip_in_target_space); | 599 parent_clip_node->data.combined_clip_in_target_space); |
| 599 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 600 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 600 parent_to_current, parent_clip_node->data.clip_in_target_space); | 601 parent_to_current, parent_clip_node->data.clip_in_target_space); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1177 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1177 const Layer* overscroll_elasticity_layer, | 1178 const Layer* overscroll_elasticity_layer, |
| 1178 const gfx::Vector2dF& elastic_overscroll) { | 1179 const gfx::Vector2dF& elastic_overscroll) { |
| 1179 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1180 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1180 elastic_overscroll); | 1181 elastic_overscroll); |
| 1181 } | 1182 } |
| 1182 | 1183 |
| 1183 } // namespace draw_property_utils | 1184 } // namespace draw_property_utils |
| 1184 | 1185 |
| 1185 } // namespace cc | 1186 } // namespace cc |
| OLD | NEW |