| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 int target_effect_id) { | 164 int target_effect_id) { |
| 165 if (clip_node->transform_id != target_transform_id) | 165 if (clip_node->transform_id != target_transform_id) |
| 166 return ComputeLocalRectInTargetSpace(clip_node->clip, property_trees, | 166 return ComputeLocalRectInTargetSpace(clip_node->clip, property_trees, |
| 167 clip_node->transform_id, | 167 clip_node->transform_id, |
| 168 target_transform_id, target_effect_id); | 168 target_transform_id, target_effect_id); |
| 169 | 169 |
| 170 const EffectTree& effect_tree = property_trees->effect_tree; | 170 const EffectTree& effect_tree = property_trees->effect_tree; |
| 171 gfx::RectF current_clip = clip_node->clip; | 171 gfx::RectF current_clip = clip_node->clip; |
| 172 gfx::Vector2dF surface_contents_scale = | 172 gfx::Vector2dF surface_contents_scale = |
| 173 effect_tree.Node(target_effect_id)->surface_contents_scale; | 173 effect_tree.Node(target_effect_id)->surface_contents_scale; |
| 174 if (surface_contents_scale.x() > 0 && surface_contents_scale.y() > 0) | 174 // The viewport clip should not be scaled. |
| 175 if (surface_contents_scale.x() > 0 && surface_contents_scale.y() > 0 && |
| 176 clip_node->transform_id != TransformTree::kRootNodeId) |
| 175 current_clip.Scale(surface_contents_scale.x(), surface_contents_scale.y()); | 177 current_clip.Scale(surface_contents_scale.x(), surface_contents_scale.y()); |
| 176 return ConditionalClip{true /* is_clipped */, current_clip}; | 178 return ConditionalClip{true /* is_clipped */, current_clip}; |
| 177 } | 179 } |
| 178 | 180 |
| 179 static ConditionalClip ComputeAccumulatedClip( | 181 static ConditionalClip ComputeAccumulatedClip( |
| 180 const PropertyTrees* property_trees, | 182 const PropertyTrees* property_trees, |
| 181 bool include_viewport_clip, | 183 bool include_viewport_clip, |
| 182 int local_clip_id, | 184 int local_clip_id, |
| 183 int target_id) { | 185 int target_id) { |
| 184 DCHECK(!include_viewport_clip || | 186 DCHECK(!include_viewport_clip || |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); | 484 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); |
| 483 bool success = property_trees->ComputeTransformFromTarget( | 485 bool success = property_trees->ComputeTransformFromTarget( |
| 484 transform_node->id, target_effect_node->id, &target_to_layer); | 486 transform_node->id, target_effect_node->id, &target_to_layer); |
| 485 if (!success) { | 487 if (!success) { |
| 486 // An animated singular transform may become non-singular during the | 488 // An animated singular transform may become non-singular during the |
| 487 // animation, so we still need to compute a visible rect. In this | 489 // animation, so we still need to compute a visible rect. In this |
| 488 // situation, we treat the entire layer as visible. | 490 // situation, we treat the entire layer as visible. |
| 489 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 491 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 490 continue; | 492 continue; |
| 491 } | 493 } |
| 492 if (target_effect_node->id > EffectTree::kContentsRootNodeId) | 494 ConcatInverseSurfaceContentsScale(target_effect_node, &target_to_layer); |
| 493 ConcatInverseSurfaceContentsScale(target_effect_node, &target_to_layer); | |
| 494 } | 495 } |
| 495 gfx::Transform target_to_content; | 496 gfx::Transform target_to_content; |
| 496 target_to_content.Translate(-layer->offset_to_transform_parent().x(), | 497 target_to_content.Translate(-layer->offset_to_transform_parent().x(), |
| 497 -layer->offset_to_transform_parent().y()); | 498 -layer->offset_to_transform_parent().y()); |
| 498 target_to_content.PreconcatTransform(target_to_layer); | 499 target_to_content.PreconcatTransform(target_to_layer); |
| 499 | 500 |
| 500 gfx::Rect visible_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 501 gfx::Rect visible_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 501 target_to_content, combined_clip_rect_in_target_space)); | 502 target_to_content, combined_clip_rect_in_target_space)); |
| 502 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 503 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
| 503 layer->set_visible_layer_rect(visible_rect); | 504 layer->set_visible_layer_rect(visible_rect); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 gfx::RectF parent_combined_clip_in_target_space = | 772 gfx::RectF parent_combined_clip_in_target_space = |
| 772 parent_clip_node->combined_clip_in_target_space; | 773 parent_clip_node->combined_clip_in_target_space; |
| 773 gfx::RectF parent_clip_in_target_space = | 774 gfx::RectF parent_clip_in_target_space = |
| 774 parent_clip_node->clip_in_target_space; | 775 parent_clip_node->clip_in_target_space; |
| 775 if (parent_target_transform_node && | 776 if (parent_target_transform_node && |
| 776 parent_target_transform_node->id != clip_node->target_transform_id && | 777 parent_target_transform_node->id != clip_node->target_transform_id && |
| 777 non_root_surfaces_enabled) { | 778 non_root_surfaces_enabled) { |
| 778 success &= property_trees->ComputeTransformFromTarget( | 779 success &= property_trees->ComputeTransformFromTarget( |
| 779 clip_node->target_transform_id, parent_clip_node->target_effect_id, | 780 clip_node->target_transform_id, parent_clip_node->target_effect_id, |
| 780 &parent_to_current); | 781 &parent_to_current); |
| 781 // We don't have to apply surface contents scale when target is root. | 782 const EffectNode* target_effect_node = |
| 782 if (clip_node->target_effect_id != EffectTree::kContentsRootNodeId) { | 783 effect_tree.Node(clip_node->target_effect_id); |
| 783 const EffectNode* target_effect_node = | 784 PostConcatSurfaceContentsScale(target_effect_node, &parent_to_current); |
| 784 effect_tree.Node(clip_node->target_effect_id); | 785 const EffectNode* parent_target_effect_node = |
| 785 PostConcatSurfaceContentsScale(target_effect_node, &parent_to_current); | 786 effect_tree.Node(parent_clip_node->target_effect_id); |
| 786 } | 787 ConcatInverseSurfaceContentsScale(parent_target_effect_node, |
| 787 if (parent_clip_node->target_effect_id != | 788 &parent_to_current); |
| 788 EffectTree::kContentsRootNodeId) { | |
| 789 const EffectNode* parent_target_effect_node = | |
| 790 effect_tree.Node(parent_clip_node->target_effect_id); | |
| 791 ConcatInverseSurfaceContentsScale(parent_target_effect_node, | |
| 792 &parent_to_current); | |
| 793 } | |
| 794 // If we can't compute a transform, it's because we had to use the inverse | 789 // If we can't compute a transform, it's because we had to use the inverse |
| 795 // of a singular transform. We won't draw in this case, so there's no need | 790 // of a singular transform. We won't draw in this case, so there's no need |
| 796 // to compute clips. | 791 // to compute clips. |
| 797 if (!success) | 792 if (!success) |
| 798 continue; | 793 continue; |
| 799 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 794 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 800 parent_to_current, parent_clip_node->combined_clip_in_target_space); | 795 parent_to_current, parent_clip_node->combined_clip_in_target_space); |
| 801 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 796 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
| 802 parent_to_current, parent_clip_node->clip_in_target_space); | 797 parent_to_current, parent_clip_node->clip_in_target_space); |
| 803 } | 798 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 for (int i = 1; i < static_cast<int>(transform_tree->size()); ++i) | 887 for (int i = 1; i < static_cast<int>(transform_tree->size()); ++i) |
| 893 transform_tree->UpdateTransforms(i); | 888 transform_tree->UpdateTransforms(i); |
| 894 transform_tree->set_needs_update(false); | 889 transform_tree->set_needs_update(false); |
| 895 } | 890 } |
| 896 | 891 |
| 897 void UpdateRenderTarget(EffectTree* effect_tree, | 892 void UpdateRenderTarget(EffectTree* effect_tree, |
| 898 bool can_render_to_separate_surface) { | 893 bool can_render_to_separate_surface) { |
| 899 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) { | 894 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) { |
| 900 EffectNode* node = effect_tree->Node(i); | 895 EffectNode* node = effect_tree->Node(i); |
| 901 if (i == 1) { | 896 if (i == 1) { |
| 902 // Render target on the first effect node is root. | 897 // Render target of the node corresponding to root is itself. |
| 903 node->target_id = 0; | 898 node->target_id = 1; |
| 904 } else if (!can_render_to_separate_surface) { | 899 } else if (!can_render_to_separate_surface) { |
| 905 node->target_id = 1; | 900 node->target_id = 1; |
| 906 } else if (effect_tree->parent(node)->has_render_surface) { | 901 } else if (effect_tree->parent(node)->has_render_surface) { |
| 907 node->target_id = node->parent_id; | 902 node->target_id = node->parent_id; |
| 908 } else { | 903 } else { |
| 909 node->target_id = effect_tree->parent(node)->target_id; | 904 node->target_id = effect_tree->parent(node)->target_id; |
| 910 } | 905 } |
| 911 } | 906 } |
| 912 } | 907 } |
| 913 | 908 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1462 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1468 const Layer* overscroll_elasticity_layer, | 1463 const Layer* overscroll_elasticity_layer, |
| 1469 const gfx::Vector2dF& elastic_overscroll) { | 1464 const gfx::Vector2dF& elastic_overscroll) { |
| 1470 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1465 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1471 elastic_overscroll); | 1466 elastic_overscroll); |
| 1472 } | 1467 } |
| 1473 | 1468 |
| 1474 } // namespace draw_property_utils | 1469 } // namespace draw_property_utils |
| 1475 | 1470 |
| 1476 } // namespace cc | 1471 } // namespace cc |
| OLD | NEW |