| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 ResetIfHasNanCoordinate(&clip_node->data.clip); | 466 ResetIfHasNanCoordinate(&clip_node->data.clip); |
| 467 clip_node->data.clip_in_target_space = clip_node->data.clip; | 467 clip_node->data.clip_in_target_space = clip_node->data.clip; |
| 468 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; | 468 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; |
| 469 continue; | 469 continue; |
| 470 } | 470 } |
| 471 const TransformNode* transform_node = | 471 const TransformNode* transform_node = |
| 472 transform_tree.Node(clip_node->data.transform_id); | 472 transform_tree.Node(clip_node->data.transform_id); |
| 473 ClipNode* parent_clip_node = clip_tree->parent(clip_node); | 473 ClipNode* parent_clip_node = clip_tree->parent(clip_node); |
| 474 | 474 |
| 475 gfx::Transform parent_to_current; | 475 gfx::Transform parent_to_current; |
| 476 const TransformNode* parent_transform_node = | 476 const TransformNode* parent_target_transform_node = |
| 477 transform_tree.Node(parent_clip_node->data.transform_id); | 477 transform_tree.Node(parent_clip_node->data.target_id); |
| 478 bool success = true; | 478 bool success = true; |
| 479 | 479 |
| 480 // Clips must be combined in target space. We cannot, for example, combine | 480 // Clips must be combined in target space. We cannot, for example, combine |
| 481 // clips in the space of the child clip. The reason is non-affine | 481 // clips in the space of the child clip. The reason is non-affine |
| 482 // transforms. Say we have the following tree T->A->B->C, and B clips C, but | 482 // transforms. Say we have the following tree T->A->B->C, and B clips C, but |
| 483 // draw into target T. It may be the case that A applies a perspective | 483 // draw into target T. It may be the case that A applies a perspective |
| 484 // transform, and B and C are at different z positions. When projected into | 484 // transform, and B and C are at different z positions. When projected into |
| 485 // target space, the relative sizes and positions of B and C can shift. | 485 // target space, the relative sizes and positions of B and C can shift. |
| 486 // Since it's the relationship in target space that matters, that's where we | 486 // Since it's the relationship in target space that matters, that's where we |
| 487 // must combine clips. For each clip node, we save the clip rects in its | 487 // must combine clips. For each clip node, we save the clip rects in its |
| 488 // target space. So, we need to get the ancestor clip rect in the current | 488 // target space. So, we need to get the ancestor clip rect in the current |
| 489 // clip node's target space. | 489 // clip node's target space. |
| 490 gfx::RectF parent_combined_clip_in_target_space = | 490 gfx::RectF parent_combined_clip_in_target_space = |
| 491 parent_clip_node->data.combined_clip_in_target_space; | 491 parent_clip_node->data.combined_clip_in_target_space; |
| 492 gfx::RectF parent_clip_in_target_space = | 492 gfx::RectF parent_clip_in_target_space = |
| 493 parent_clip_node->data.clip_in_target_space; | 493 parent_clip_node->data.clip_in_target_space; |
| 494 if (parent_clip_node->data.target_id != clip_node->data.target_id && | 494 if (parent_target_transform_node && |
| 495 parent_target_transform_node->id != clip_node->data.target_id && |
| 495 non_root_surfaces_enabled) { | 496 non_root_surfaces_enabled) { |
| 496 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( | 497 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 497 parent_clip_node->data.target_id, clip_node->data.target_id, | 498 parent_target_transform_node->id, clip_node->data.target_id, |
| 498 &parent_to_current); | 499 &parent_to_current); |
| 499 if (parent_transform_node->data.sublayer_scale.x() > 0 && | 500 if (parent_target_transform_node->data.sublayer_scale.x() > 0 && |
| 500 parent_transform_node->data.sublayer_scale.y() > 0) | 501 parent_target_transform_node->data.sublayer_scale.y() > 0) |
| 501 parent_to_current.Scale( | 502 parent_to_current.Scale( |
| 502 1.f / parent_transform_node->data.sublayer_scale.x(), | 503 1.f / parent_target_transform_node->data.sublayer_scale.x(), |
| 503 1.f / parent_transform_node->data.sublayer_scale.y()); | 504 1.f / parent_target_transform_node->data.sublayer_scale.y()); |
| 504 // If we can't compute a transform, it's because we had to use the inverse | 505 // If we can't compute a transform, it's because we had to use the inverse |
| 505 // of a singular transform. We won't draw in this case, so there's no need | 506 // of a singular transform. We won't draw in this case, so there's no need |
| 506 // to compute clips. | 507 // to compute clips. |
| 507 if (!success) | 508 if (!success) |
| 508 continue; | 509 continue; |
| 509 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 510 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 510 parent_to_current, | 511 parent_to_current, |
| 511 parent_clip_node->data.combined_clip_in_target_space); | 512 parent_clip_node->data.combined_clip_in_target_space); |
| 512 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 513 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 513 parent_to_current, parent_clip_node->data.clip_in_target_space); | 514 parent_to_current, parent_clip_node->data.clip_in_target_space); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1113 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1113 const Layer* overscroll_elasticity_layer, | 1114 const Layer* overscroll_elasticity_layer, |
| 1114 const gfx::Vector2dF& elastic_overscroll) { | 1115 const gfx::Vector2dF& elastic_overscroll) { |
| 1115 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1116 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1116 elastic_overscroll); | 1117 elastic_overscroll); |
| 1117 } | 1118 } |
| 1118 | 1119 |
| 1119 } // namespace draw_property_utils | 1120 } // namespace draw_property_utils |
| 1120 | 1121 |
| 1121 } // namespace cc | 1122 } // namespace cc |
| OLD | NEW |