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