| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/layers/draw_properties.h" | 10 #include "cc/layers/draw_properties.h" |
| 11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 12 #include "cc/layers/layer_impl.h" | 12 #include "cc/layers/layer_impl.h" |
| 13 #include "cc/layers/render_surface_draw_properties.h" | 13 #include "cc/layers/render_surface_draw_properties.h" |
| 14 #include "cc/trees/layer_tree_impl.h" | 14 #include "cc/trees/layer_tree_impl.h" |
| 15 #include "cc/trees/property_tree.h" | 15 #include "cc/trees/property_tree.h" |
| 16 #include "cc/trees/property_tree_builder.h" | 16 #include "cc/trees/property_tree_builder.h" |
| 17 #include "ui/gfx/geometry/rect_conversions.h" | 17 #include "ui/gfx/geometry/rect_conversions.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 template <typename LayerType> | 23 template <typename LayerType> |
| 24 void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list, | 24 void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list, |
| 25 const ClipTree& clip_tree, | 25 const ClipTree& clip_tree, |
| 26 const TransformTree& transform_tree) { | 26 const TransformTree& transform_tree, |
| 27 bool non_root_surfaces_enabled) { |
| 27 for (auto& layer : visible_layer_list) { | 28 for (auto& layer : visible_layer_list) { |
| 28 gfx::Size layer_bounds = layer->bounds(); | 29 gfx::Size layer_bounds = layer->bounds(); |
| 29 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); | 30 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); |
| 30 const bool is_unclipped = | 31 const bool is_unclipped = clip_node->data.resets_clip && |
| 31 clip_node->data.resets_clip && !clip_node->data.applies_local_clip; | 32 !clip_node->data.applies_local_clip && |
| 33 non_root_surfaces_enabled; |
| 32 // When both the layer and the target are unclipped, the entire layer | 34 // When both the layer and the target are unclipped, the entire layer |
| 33 // content rect is visible. | 35 // content rect is visible. |
| 34 const bool fully_visible = !clip_node->data.layers_are_clipped && | 36 const bool fully_visible = !clip_node->data.layers_are_clipped && |
| 35 !clip_node->data.target_is_clipped; | 37 !clip_node->data.target_is_clipped && |
| 38 non_root_surfaces_enabled; |
| 36 const TransformNode* transform_node = | 39 const TransformNode* transform_node = |
| 37 transform_tree.Node(layer->transform_tree_index()); | 40 transform_tree.Node(layer->transform_tree_index()); |
| 38 if (!is_unclipped && !fully_visible) { | 41 if (!is_unclipped && !fully_visible) { |
| 39 const TransformNode* target_node = | 42 const TransformNode* target_node = |
| 40 transform_tree.Node(transform_node->data.content_target_id); | 43 non_root_surfaces_enabled |
| 44 ? transform_tree.Node(transform_node->data.content_target_id) |
| 45 : transform_tree.Node(0); |
| 41 | 46 |
| 42 // The clip node stores clip rect in its target space. If required, | 47 // The clip node stores clip rect in its target space. If required, |
| 43 // this clip rect should be mapped to the current layer's target space. | 48 // this clip rect should be mapped to the current layer's target space. |
| 44 gfx::Rect clip_rect_in_target_space; | 49 gfx::Rect clip_rect_in_target_space; |
| 45 gfx::Rect combined_clip_rect_in_target_space; | 50 gfx::Rect combined_clip_rect_in_target_space; |
| 46 bool success = true; | 51 bool success = true; |
| 47 | 52 |
| 48 if (clip_node->data.target_id != target_node->id) { | 53 // When we only have a root surface, the clip node and the layer must |
| 54 // necessarily have the same target (the root). |
| 55 if (clip_node->data.target_id != target_node->id && |
| 56 non_root_surfaces_enabled) { |
| 49 // In this case, layer has a clip parent (or shares the target with an | 57 // In this case, layer has a clip parent (or shares the target with an |
| 50 // ancestor layer that has clip parent) and the clip parent's target is | 58 // ancestor layer that has clip parent) and the clip parent's target is |
| 51 // different from the layer's target. As the layer's target has | 59 // different from the layer's target. As the layer's target has |
| 52 // unclippped descendants, it is unclippped. | 60 // unclippped descendants, it is unclippped. |
| 53 if (!clip_node->data.layers_are_clipped) { | 61 if (!clip_node->data.layers_are_clipped) { |
| 54 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); | 62 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); |
| 55 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); | 63 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); |
| 56 continue; | 64 continue; |
| 57 } | 65 } |
| 58 gfx::Transform clip_to_target; | 66 gfx::Transform clip_to_target; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 75 // visible rect computation. | 83 // visible rect computation. |
| 76 combined_clip_rect_in_target_space = | 84 combined_clip_rect_in_target_space = |
| 77 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 85 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 78 clip_to_target, clip_node->data.clip_in_target_space)); | 86 clip_to_target, clip_node->data.clip_in_target_space)); |
| 79 clip_rect_in_target_space = | 87 clip_rect_in_target_space = |
| 80 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 88 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 81 clip_to_target, clip_node->data.clip_in_target_space)); | 89 clip_to_target, clip_node->data.clip_in_target_space)); |
| 82 } else { | 90 } else { |
| 83 clip_rect_in_target_space = | 91 clip_rect_in_target_space = |
| 84 gfx::ToEnclosingRect(clip_node->data.clip_in_target_space); | 92 gfx::ToEnclosingRect(clip_node->data.clip_in_target_space); |
| 85 if (clip_node->data.target_is_clipped) | 93 if (clip_node->data.target_is_clipped || !non_root_surfaces_enabled) |
| 86 combined_clip_rect_in_target_space = gfx::ToEnclosingRect( | 94 combined_clip_rect_in_target_space = gfx::ToEnclosingRect( |
| 87 clip_node->data.combined_clip_in_target_space); | 95 clip_node->data.combined_clip_in_target_space); |
| 88 else | 96 else |
| 89 combined_clip_rect_in_target_space = clip_rect_in_target_space; | 97 combined_clip_rect_in_target_space = clip_rect_in_target_space; |
| 90 } | 98 } |
| 91 | 99 |
| 92 if (!clip_rect_in_target_space.IsEmpty()) { | 100 if (!clip_rect_in_target_space.IsEmpty()) { |
| 93 layer->set_clip_rect_in_target_space_from_property_trees( | 101 layer->set_clip_rect_in_target_space_from_property_trees( |
| 94 clip_rect_in_target_space); | 102 clip_rect_in_target_space); |
| 95 } else { | 103 } else { |
| 96 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); | 104 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); |
| 97 } | 105 } |
| 98 | 106 |
| 99 // The clip rect should be intersected with layer rect in target space. | 107 // The clip rect should be intersected with layer rect in target space. |
| 100 gfx::Transform content_to_target = transform_node->data.to_target; | 108 gfx::Transform content_to_target = non_root_surfaces_enabled |
| 109 ? transform_node->data.to_target |
| 110 : transform_node->data.to_screen; |
| 101 | 111 |
| 102 content_to_target.Translate(layer->offset_to_transform_parent().x(), | 112 content_to_target.Translate(layer->offset_to_transform_parent().x(), |
| 103 layer->offset_to_transform_parent().y()); | 113 layer->offset_to_transform_parent().y()); |
| 104 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); | 114 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); |
| 105 gfx::Rect layer_content_bounds_in_target_space = | 115 gfx::Rect layer_content_bounds_in_target_space = |
| 106 MathUtil::MapEnclosingClippedRect(content_to_target, | 116 MathUtil::MapEnclosingClippedRect(content_to_target, |
| 107 layer_content_rect); | 117 layer_content_rect); |
| 108 combined_clip_rect_in_target_space.Intersect( | 118 combined_clip_rect_in_target_space.Intersect( |
| 109 layer_content_bounds_in_target_space); | 119 layer_content_bounds_in_target_space); |
| 110 if (combined_clip_rect_in_target_space.IsEmpty()) { | 120 if (combined_clip_rect_in_target_space.IsEmpty()) { |
| 111 layer->set_visible_rect_from_property_trees(gfx::Rect()); | 121 layer->set_visible_rect_from_property_trees(gfx::Rect()); |
| 112 continue; | 122 continue; |
| 113 } | 123 } |
| 114 | 124 |
| 115 // If the layer is fully contained within the clip, treat it as fully | 125 // If the layer is fully contained within the clip, treat it as fully |
| 116 // visible. Since clip_rect_in_target_space has already been intersected | 126 // visible. Since clip_rect_in_target_space has already been intersected |
| 117 // with layer_content_bounds_in_target_space, the layer is fully contained | 127 // with layer_content_bounds_in_target_space, the layer is fully contained |
| 118 // within the clip iff these rects are equal. | 128 // within the clip iff these rects are equal. |
| 119 if (combined_clip_rect_in_target_space == | 129 if (combined_clip_rect_in_target_space == |
| 120 layer_content_bounds_in_target_space) { | 130 layer_content_bounds_in_target_space) { |
| 121 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); | 131 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); |
| 122 continue; | 132 continue; |
| 123 } | 133 } |
| 124 | 134 |
| 125 gfx::Transform target_to_content; | 135 gfx::Transform target_to_content; |
| 126 gfx::Transform target_to_layer; | 136 gfx::Transform target_to_layer; |
| 127 | 137 |
| 128 if (transform_node->data.ancestors_are_invertible) { | 138 if (transform_node->data.ancestors_are_invertible) { |
| 129 target_to_layer = transform_node->data.from_target; | 139 target_to_layer = non_root_surfaces_enabled |
| 140 ? transform_node->data.from_target |
| 141 : transform_node->data.from_screen; |
| 130 success = true; | 142 success = true; |
| 131 } else { | 143 } else { |
| 132 success = transform_tree.ComputeTransformWithSourceSublayerScale( | 144 success = transform_tree.ComputeTransformWithSourceSublayerScale( |
| 133 target_node->id, transform_node->id, &target_to_layer); | 145 target_node->id, transform_node->id, &target_to_layer); |
| 134 } | 146 } |
| 135 | 147 |
| 136 if (!success) { | 148 if (!success) { |
| 137 // An animated singular transform may become non-singular during the | 149 // An animated singular transform may become non-singular during the |
| 138 // animation, so we still need to compute a visible rect. In this | 150 // animation, so we still need to compute a visible rect. In this |
| 139 // situation, we treat the entire layer as visible. | 151 // situation, we treat the entire layer as visible. |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 420 } |
| 409 | 421 |
| 410 for (size_t i = 0; i < layer->children().size(); ++i) { | 422 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 411 FindLayersThatNeedUpdates(layer->child_at(i), tree, layer_is_drawn, | 423 FindLayersThatNeedUpdates(layer->child_at(i), tree, layer_is_drawn, |
| 412 update_layer_list, visible_layer_list); | 424 update_layer_list, visible_layer_list); |
| 413 } | 425 } |
| 414 } | 426 } |
| 415 | 427 |
| 416 } // namespace | 428 } // namespace |
| 417 | 429 |
| 418 void ComputeClips(ClipTree* clip_tree, const TransformTree& transform_tree) { | 430 void ComputeClips(ClipTree* clip_tree, |
| 431 const TransformTree& transform_tree, |
| 432 bool non_root_surfaces_enabled) { |
| 419 if (!clip_tree->needs_update()) | 433 if (!clip_tree->needs_update()) |
| 420 return; | 434 return; |
| 421 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { | 435 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { |
| 422 ClipNode* clip_node = clip_tree->Node(i); | 436 ClipNode* clip_node = clip_tree->Node(i); |
| 423 | 437 |
| 424 if (clip_node->id == 1) { | 438 if (clip_node->id == 1) { |
| 425 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; | 439 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; |
| 426 clip_node->data.clip_in_target_space = clip_node->data.clip; | 440 clip_node->data.clip_in_target_space = clip_node->data.clip; |
| 427 continue; | 441 continue; |
| 428 } | 442 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 440 // transforms. Say we have the following tree T->A->B->C, and B clips C, but | 454 // transforms. Say we have the following tree T->A->B->C, and B clips C, but |
| 441 // draw into target T. It may be the case that A applies a perspective | 455 // draw into target T. It may be the case that A applies a perspective |
| 442 // transform, and B and C are at different z positions. When projected into | 456 // transform, and B and C are at different z positions. When projected into |
| 443 // target space, the relative sizes and positions of B and C can shift. | 457 // target space, the relative sizes and positions of B and C can shift. |
| 444 // Since it's the relationship in target space that matters, that's where we | 458 // Since it's the relationship in target space that matters, that's where we |
| 445 // must combine clips. For each clip node, we save the clip rects in its | 459 // must combine clips. For each clip node, we save the clip rects in its |
| 446 // target space. So, we need to get the ancestor clip rect in the current | 460 // target space. So, we need to get the ancestor clip rect in the current |
| 447 // clip node's target space. | 461 // clip node's target space. |
| 448 gfx::RectF parent_combined_clip_in_target_space = | 462 gfx::RectF parent_combined_clip_in_target_space = |
| 449 parent_clip_node->data.combined_clip_in_target_space; | 463 parent_clip_node->data.combined_clip_in_target_space; |
| 450 if (parent_clip_node->data.target_id != clip_node->data.target_id) { | 464 if (parent_clip_node->data.target_id != clip_node->data.target_id && |
| 465 non_root_surfaces_enabled) { |
| 451 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( | 466 success &= transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 452 parent_clip_node->data.target_id, clip_node->data.target_id, | 467 parent_clip_node->data.target_id, clip_node->data.target_id, |
| 453 &parent_to_current); | 468 &parent_to_current); |
| 454 if (parent_transform_node->data.sublayer_scale.x() > 0 && | 469 if (parent_transform_node->data.sublayer_scale.x() > 0 && |
| 455 parent_transform_node->data.sublayer_scale.y() > 0) | 470 parent_transform_node->data.sublayer_scale.y() > 0) |
| 456 parent_to_current.Scale( | 471 parent_to_current.Scale( |
| 457 1.f / parent_transform_node->data.sublayer_scale.x(), | 472 1.f / parent_transform_node->data.sublayer_scale.x(), |
| 458 1.f / parent_transform_node->data.sublayer_scale.y()); | 473 1.f / parent_transform_node->data.sublayer_scale.y()); |
| 459 // If we can't compute a transform, it's because we had to use the inverse | 474 // If we can't compute a transform, it's because we had to use the inverse |
| 460 // of a singular transform. We won't draw in this case, so there's no need | 475 // of a singular transform. We won't draw in this case, so there's no need |
| 461 // to compute clips. | 476 // to compute clips. |
| 462 if (!success) | 477 if (!success) |
| 463 continue; | 478 continue; |
| 464 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 479 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 465 parent_to_current, | 480 parent_to_current, |
| 466 parent_clip_node->data.combined_clip_in_target_space); | 481 parent_clip_node->data.combined_clip_in_target_space); |
| 467 } | 482 } |
| 468 | 483 |
| 469 // Only nodes affected by ancestor clips will have their clip adjusted due | 484 // Only nodes affected by ancestor clips will have their clip adjusted due |
| 470 // to intersecting with an ancestor clip. But, we still need to propagate | 485 // to intersecting with an ancestor clip. But, we still need to propagate |
| 471 // the combined clip to our children because if they are clipped, they may | 486 // the combined clip to our children because if they are clipped, they may |
| 472 // need to clip using our parent clip and if we don't propagate it here, | 487 // need to clip using our parent clip and if we don't propagate it here, |
| 473 // it will be lost. | 488 // it will be lost. |
| 474 if (clip_node->data.resets_clip) { | 489 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { |
| 475 if (clip_node->data.applies_local_clip) { | 490 if (clip_node->data.applies_local_clip) { |
| 476 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( | 491 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( |
| 477 transform_node->data.to_target, clip_node->data.clip); | 492 transform_node->data.to_target, clip_node->data.clip); |
| 478 clip_node->data.combined_clip_in_target_space = | 493 clip_node->data.combined_clip_in_target_space = |
| 479 gfx::IntersectRects(clip_node->data.clip_in_target_space, | 494 gfx::IntersectRects(clip_node->data.clip_in_target_space, |
| 480 parent_combined_clip_in_target_space); | 495 parent_combined_clip_in_target_space); |
| 481 } else { | 496 } else { |
| 482 DCHECK(!clip_node->data.target_is_clipped); | 497 DCHECK(!clip_node->data.target_is_clipped); |
| 483 DCHECK(!clip_node->data.layers_are_clipped); | 498 DCHECK(!clip_node->data.layers_are_clipped); |
| 484 clip_node->data.combined_clip_in_target_space = | 499 clip_node->data.combined_clip_in_target_space = |
| 485 parent_combined_clip_in_target_space; | 500 parent_combined_clip_in_target_space; |
| 486 } | 501 } |
| 487 continue; | 502 continue; |
| 488 } | 503 } |
| 489 | 504 |
| 490 bool use_only_parent_clip = !clip_node->data.applies_local_clip; | 505 bool use_only_parent_clip = !clip_node->data.applies_local_clip; |
| 491 if (use_only_parent_clip) { | 506 if (use_only_parent_clip) { |
| 492 clip_node->data.combined_clip_in_target_space = | 507 clip_node->data.combined_clip_in_target_space = |
| 493 parent_combined_clip_in_target_space; | 508 parent_combined_clip_in_target_space; |
| 494 if (!clip_node->data.target_is_clipped) { | 509 if (!non_root_surfaces_enabled) { |
| 510 clip_node->data.clip_in_target_space = |
| 511 parent_clip_node->data.clip_in_target_space; |
| 512 } else if (!clip_node->data.target_is_clipped) { |
| 495 clip_node->data.clip_in_target_space = | 513 clip_node->data.clip_in_target_space = |
| 496 parent_combined_clip_in_target_space; | 514 parent_combined_clip_in_target_space; |
| 497 } else { | 515 } else { |
| 498 // Render Surface applies clip and the owning layer itself applies | 516 // Render Surface applies clip and the owning layer itself applies |
| 499 // no clip. So, clip_in_target_space is not used and hence we can set | 517 // no clip. So, clip_in_target_space is not used and hence we can set |
| 500 // it to an empty rect. | 518 // it to an empty rect. |
| 501 clip_node->data.clip_in_target_space = gfx::RectF(); | 519 clip_node->data.clip_in_target_space = gfx::RectF(); |
| 502 } | 520 } |
| 503 } else { | 521 } else { |
| 504 gfx::Transform source_to_target; | 522 gfx::Transform source_to_target; |
| 505 | 523 |
| 506 if (transform_node->data.content_target_id == clip_node->data.target_id) { | 524 if (!non_root_surfaces_enabled) { |
| 525 source_to_target = transform_node->data.to_screen; |
| 526 } else if (transform_node->data.content_target_id == |
| 527 clip_node->data.target_id) { |
| 507 source_to_target = transform_node->data.to_target; | 528 source_to_target = transform_node->data.to_target; |
| 508 } else { | 529 } else { |
| 509 success = transform_tree.ComputeTransformWithDestinationSublayerScale( | 530 success = transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 510 transform_node->id, clip_node->data.target_id, &source_to_target); | 531 transform_node->id, clip_node->data.target_id, &source_to_target); |
| 511 // source_to_target computation should be successful as target is an | 532 // source_to_target computation should be successful as target is an |
| 512 // ancestor of the transform node. | 533 // ancestor of the transform node. |
| 513 DCHECK(success); | 534 DCHECK(success); |
| 514 } | 535 } |
| 515 | 536 |
| 516 gfx::RectF source_clip_in_target_space = | 537 gfx::RectF source_clip_in_target_space = |
| 517 MathUtil::MapClippedRect(source_to_target, clip_node->data.clip); | 538 MathUtil::MapClippedRect(source_to_target, clip_node->data.clip); |
| 518 | 539 |
| 519 if (!clip_node->data.layer_clipping_uses_only_local_clip) { | 540 // With surfaces disabled, the only case where we use only the local clip |
| 541 // for layer clipping is the case where no non-viewport ancestor node |
| 542 // applies a local clip. |
| 543 bool layer_clipping_uses_only_local_clip = |
| 544 non_root_surfaces_enabled |
| 545 ? clip_node->data.layer_clipping_uses_only_local_clip |
| 546 : !parent_clip_node->data |
| 547 .layers_are_clipped_when_surfaces_disabled; |
| 548 if (!layer_clipping_uses_only_local_clip) { |
| 520 gfx::RectF parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 549 gfx::RectF parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 521 parent_to_current, parent_clip_node->data.clip_in_target_space); | 550 parent_to_current, parent_clip_node->data.clip_in_target_space); |
| 522 clip_node->data.clip_in_target_space = gfx::IntersectRects( | 551 clip_node->data.clip_in_target_space = gfx::IntersectRects( |
| 523 parent_clip_in_target_space, source_clip_in_target_space); | 552 parent_clip_in_target_space, source_clip_in_target_space); |
| 524 } else { | 553 } else { |
| 525 clip_node->data.clip_in_target_space = source_clip_in_target_space; | 554 clip_node->data.clip_in_target_space = source_clip_in_target_space; |
| 526 } | 555 } |
| 527 | 556 |
| 528 clip_node->data.combined_clip_in_target_space = gfx::IntersectRects( | 557 clip_node->data.combined_clip_in_target_space = gfx::IntersectRects( |
| 529 parent_combined_clip_in_target_space, source_clip_in_target_space); | 558 parent_combined_clip_in_target_space, source_clip_in_target_space); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 545 return; | 574 return; |
| 546 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) | 575 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) |
| 547 effect_tree->UpdateOpacities(i); | 576 effect_tree->UpdateOpacities(i); |
| 548 effect_tree->set_needs_update(false); | 577 effect_tree->set_needs_update(false); |
| 549 } | 578 } |
| 550 | 579 |
| 551 template <typename LayerType> | 580 template <typename LayerType> |
| 552 void ComputeVisibleRectsUsingPropertyTreesInternal( | 581 void ComputeVisibleRectsUsingPropertyTreesInternal( |
| 553 LayerType* root_layer, | 582 LayerType* root_layer, |
| 554 PropertyTrees* property_trees, | 583 PropertyTrees* property_trees, |
| 584 bool can_render_to_separate_surface, |
| 555 typename LayerType::LayerListType* update_layer_list) { | 585 typename LayerType::LayerListType* update_layer_list) { |
| 586 if (property_trees->non_root_surfaces_enabled != |
| 587 can_render_to_separate_surface) { |
| 588 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; |
| 589 property_trees->transform_tree.set_needs_update(true); |
| 590 } |
| 556 if (property_trees->transform_tree.needs_update()) | 591 if (property_trees->transform_tree.needs_update()) |
| 557 property_trees->clip_tree.set_needs_update(true); | 592 property_trees->clip_tree.set_needs_update(true); |
| 558 ComputeTransforms(&property_trees->transform_tree); | 593 ComputeTransforms(&property_trees->transform_tree); |
| 559 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree); | 594 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, |
| 595 can_render_to_separate_surface); |
| 560 ComputeOpacities(&property_trees->effect_tree); | 596 ComputeOpacities(&property_trees->effect_tree); |
| 561 | 597 |
| 562 const bool subtree_is_visible_from_ancestor = true; | 598 const bool subtree_is_visible_from_ancestor = true; |
| 563 std::vector<LayerType*> visible_layer_list; | 599 std::vector<LayerType*> visible_layer_list; |
| 564 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree, | 600 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree, |
| 565 subtree_is_visible_from_ancestor, update_layer_list, | 601 subtree_is_visible_from_ancestor, update_layer_list, |
| 566 &visible_layer_list); | 602 &visible_layer_list); |
| 567 CalculateVisibleRects<LayerType>(visible_layer_list, | 603 CalculateVisibleRects<LayerType>( |
| 568 property_trees->clip_tree, | 604 visible_layer_list, property_trees->clip_tree, |
| 569 property_trees->transform_tree); | 605 property_trees->transform_tree, can_render_to_separate_surface); |
| 570 } | 606 } |
| 571 | 607 |
| 572 void BuildPropertyTreesAndComputeVisibleRects( | 608 void BuildPropertyTreesAndComputeVisibleRects( |
| 573 Layer* root_layer, | 609 Layer* root_layer, |
| 574 const Layer* page_scale_layer, | 610 const Layer* page_scale_layer, |
| 575 const Layer* inner_viewport_scroll_layer, | 611 const Layer* inner_viewport_scroll_layer, |
| 576 const Layer* outer_viewport_scroll_layer, | 612 const Layer* outer_viewport_scroll_layer, |
| 577 float page_scale_factor, | 613 float page_scale_factor, |
| 578 float device_scale_factor, | 614 float device_scale_factor, |
| 579 const gfx::Rect& viewport, | 615 const gfx::Rect& viewport, |
| 580 const gfx::Transform& device_transform, | 616 const gfx::Transform& device_transform, |
| 617 bool can_render_to_separate_surface, |
| 581 PropertyTrees* property_trees, | 618 PropertyTrees* property_trees, |
| 582 LayerList* update_layer_list) { | 619 LayerList* update_layer_list) { |
| 583 PropertyTreeBuilder::BuildPropertyTrees( | 620 PropertyTreeBuilder::BuildPropertyTrees( |
| 584 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 621 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 585 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 622 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
| 586 viewport, device_transform, property_trees); | 623 viewport, device_transform, property_trees); |
| 587 ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees, | 624 ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees, |
| 625 can_render_to_separate_surface, |
| 588 update_layer_list); | 626 update_layer_list); |
| 589 } | 627 } |
| 590 | 628 |
| 591 void BuildPropertyTreesAndComputeVisibleRects( | 629 void BuildPropertyTreesAndComputeVisibleRects( |
| 592 LayerImpl* root_layer, | 630 LayerImpl* root_layer, |
| 593 const LayerImpl* page_scale_layer, | 631 const LayerImpl* page_scale_layer, |
| 594 const LayerImpl* inner_viewport_scroll_layer, | 632 const LayerImpl* inner_viewport_scroll_layer, |
| 595 const LayerImpl* outer_viewport_scroll_layer, | 633 const LayerImpl* outer_viewport_scroll_layer, |
| 596 float page_scale_factor, | 634 float page_scale_factor, |
| 597 float device_scale_factor, | 635 float device_scale_factor, |
| 598 const gfx::Rect& viewport, | 636 const gfx::Rect& viewport, |
| 599 const gfx::Transform& device_transform, | 637 const gfx::Transform& device_transform, |
| 638 bool can_render_to_separate_surface, |
| 600 PropertyTrees* property_trees, | 639 PropertyTrees* property_trees, |
| 601 LayerImplList* update_layer_list) { | 640 LayerImplList* update_layer_list) { |
| 602 PropertyTreeBuilder::BuildPropertyTrees( | 641 PropertyTreeBuilder::BuildPropertyTrees( |
| 603 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 642 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 604 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, | 643 outer_viewport_scroll_layer, page_scale_factor, device_scale_factor, |
| 605 viewport, device_transform, property_trees); | 644 viewport, device_transform, property_trees); |
| 606 ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees, | 645 ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees, |
| 646 can_render_to_separate_surface, |
| 607 update_layer_list); | 647 update_layer_list); |
| 608 } | 648 } |
| 609 | 649 |
| 610 void ComputeVisibleRectsUsingPropertyTrees(Layer* root_layer, | 650 void ComputeVisibleRectsUsingPropertyTrees(Layer* root_layer, |
| 611 PropertyTrees* property_trees, | 651 PropertyTrees* property_trees, |
| 652 bool can_render_to_separate_surface, |
| 612 LayerList* update_layer_list) { | 653 LayerList* update_layer_list) { |
| 613 ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees, | 654 ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees, |
| 655 can_render_to_separate_surface, |
| 614 update_layer_list); | 656 update_layer_list); |
| 615 } | 657 } |
| 616 | 658 |
| 617 void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer, | 659 void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer, |
| 618 PropertyTrees* property_trees, | 660 PropertyTrees* property_trees, |
| 661 bool can_render_to_separate_surface, |
| 619 LayerImplList* update_layer_list) { | 662 LayerImplList* update_layer_list) { |
| 620 ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees, | 663 ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees, |
| 664 can_render_to_separate_surface, |
| 621 update_layer_list); | 665 update_layer_list); |
| 622 } | 666 } |
| 623 | 667 |
| 624 template <typename LayerType> | 668 template <typename LayerType> |
| 625 gfx::Transform DrawTransformFromPropertyTreesInternal( | 669 gfx::Transform DrawTransformFromPropertyTreesInternal( |
| 626 const LayerType* layer, | 670 const LayerType* layer, |
| 627 const TransformNode* node) { | 671 const TransformNode* node) { |
| 628 gfx::Transform xform; | 672 gfx::Transform xform; |
| 629 const bool owns_non_root_surface = | 673 const bool owns_non_root_surface = |
| 630 layer->parent() && layer->has_render_surface(); | 674 layer->parent() && layer->has_render_surface(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 draw_properties->visible_layer_rect = | 888 draw_properties->visible_layer_rect = |
| 845 layer->visible_rect_from_property_trees(); | 889 layer->visible_rect_from_property_trees(); |
| 846 | 890 |
| 847 const TransformNode* transform_node = | 891 const TransformNode* transform_node = |
| 848 property_trees->transform_tree.Node(layer->transform_tree_index()); | 892 property_trees->transform_tree.Node(layer->transform_tree_index()); |
| 849 const EffectNode* effect_node = | 893 const EffectNode* effect_node = |
| 850 property_trees->effect_tree.Node(layer->effect_tree_index()); | 894 property_trees->effect_tree.Node(layer->effect_tree_index()); |
| 851 const ClipNode* clip_node = | 895 const ClipNode* clip_node = |
| 852 property_trees->clip_tree.Node(layer->clip_tree_index()); | 896 property_trees->clip_tree.Node(layer->clip_tree_index()); |
| 853 | 897 |
| 854 draw_properties->target_space_transform = | |
| 855 DrawTransformFromPropertyTreesInternal(layer, transform_node); | |
| 856 draw_properties->screen_space_transform = | 898 draw_properties->screen_space_transform = |
| 857 ScreenSpaceTransformFromPropertyTreesInternal(layer, transform_node); | 899 ScreenSpaceTransformFromPropertyTreesInternal(layer, transform_node); |
| 900 if (property_trees->non_root_surfaces_enabled) { |
| 901 draw_properties->target_space_transform = |
| 902 DrawTransformFromPropertyTreesInternal(layer, transform_node); |
| 903 } else { |
| 904 draw_properties->target_space_transform = |
| 905 draw_properties->screen_space_transform; |
| 906 } |
| 858 draw_properties->screen_space_transform_is_animating = | 907 draw_properties->screen_space_transform_is_animating = |
| 859 transform_node->data.to_screen_is_animated; | 908 transform_node->data.to_screen_is_animated; |
| 860 if (layer->layer_tree_impl() | 909 if (layer->layer_tree_impl() |
| 861 ->settings() | 910 ->settings() |
| 862 .layer_transforms_should_scale_layer_contents) { | 911 .layer_transforms_should_scale_layer_contents) { |
| 863 draw_properties->maximum_animation_contents_scale = | 912 draw_properties->maximum_animation_contents_scale = |
| 864 transform_node->data.combined_maximum_animation_target_scale; | 913 transform_node->data.combined_maximum_animation_target_scale; |
| 865 draw_properties->starting_animation_contents_scale = | 914 draw_properties->starting_animation_contents_scale = |
| 866 transform_node->data.combined_starting_animation_scale; | 915 transform_node->data.combined_starting_animation_scale; |
| 867 } else { | 916 } else { |
| 868 draw_properties->maximum_animation_contents_scale = 0.f; | 917 draw_properties->maximum_animation_contents_scale = 0.f; |
| 869 draw_properties->starting_animation_contents_scale = 0.f; | 918 draw_properties->starting_animation_contents_scale = 0.f; |
| 870 } | 919 } |
| 871 | 920 |
| 872 draw_properties->opacity = | 921 draw_properties->opacity = |
| 873 LayerDrawOpacity(layer, property_trees->effect_tree); | 922 LayerDrawOpacity(layer, property_trees->effect_tree); |
| 874 draw_properties->can_use_lcd_text = | 923 draw_properties->can_use_lcd_text = |
| 875 LayerCanUseLcdText(layer, layers_always_allowed_lcd_text, | 924 LayerCanUseLcdText(layer, layers_always_allowed_lcd_text, |
| 876 can_use_lcd_text, transform_node, effect_node); | 925 can_use_lcd_text, transform_node, effect_node); |
| 877 draw_properties->is_clipped = clip_node->data.layers_are_clipped; | 926 if (property_trees->non_root_surfaces_enabled) { |
| 927 draw_properties->is_clipped = clip_node->data.layers_are_clipped; |
| 928 } else { |
| 929 draw_properties->is_clipped = |
| 930 clip_node->data.layers_are_clipped_when_surfaces_disabled; |
| 931 } |
| 878 | 932 |
| 879 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( | 933 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 880 draw_properties->target_space_transform, gfx::Rect(layer->bounds())); | 934 draw_properties->target_space_transform, gfx::Rect(layer->bounds())); |
| 881 draw_properties->clip_rect = LayerClipRect(layer, bounds_in_target_space); | 935 draw_properties->clip_rect = LayerClipRect(layer, bounds_in_target_space); |
| 882 draw_properties->drawable_content_rect = LayerDrawableContentRect( | 936 draw_properties->drawable_content_rect = LayerDrawableContentRect( |
| 883 layer, bounds_in_target_space, draw_properties->clip_rect); | 937 layer, bounds_in_target_space, draw_properties->clip_rect); |
| 884 } | 938 } |
| 885 | 939 |
| 886 void ComputeSurfaceDrawPropertiesUsingPropertyTrees( | 940 void ComputeSurfaceDrawPropertiesUsingPropertyTrees( |
| 887 RenderSurfaceImpl* render_surface, | 941 RenderSurfaceImpl* render_surface, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 const Layer* page_scale_layer, | 1023 const Layer* page_scale_layer, |
| 970 float page_scale_factor, | 1024 float page_scale_factor, |
| 971 float device_scale_factor, | 1025 float device_scale_factor, |
| 972 const gfx::Transform device_transform) { | 1026 const gfx::Transform device_transform) { |
| 973 UpdatePageScaleFactorInPropertyTreesInternal( | 1027 UpdatePageScaleFactorInPropertyTreesInternal( |
| 974 property_trees, page_scale_layer, page_scale_factor, device_scale_factor, | 1028 property_trees, page_scale_layer, page_scale_factor, device_scale_factor, |
| 975 device_transform); | 1029 device_transform); |
| 976 } | 1030 } |
| 977 | 1031 |
| 978 } // namespace cc | 1032 } // namespace cc |
| OLD | NEW |