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