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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 | 86 |
87 gfx::Transform clip_to_target; | 87 gfx::Transform clip_to_target; |
88 if (clip_node->target_transform_id > target_node_id) { | 88 if (clip_node->target_transform_id > target_node_id) { |
89 // In this case, layer has a scroll parent. We need to keep the scale | 89 // In this case, layer has a scroll parent. We need to keep the scale |
90 // at the layer's target but remove the scale at the scroll parent's | 90 // at the layer's target but remove the scale at the scroll parent's |
91 // target. | 91 // target. |
92 if (transform_tree.ComputeTransform(clip_node->target_transform_id, | 92 if (transform_tree.ComputeTransform(clip_node->target_transform_id, |
93 target_node_id, &clip_to_target)) { | 93 target_node_id, &clip_to_target)) { |
94 // We don't have to apply sublayer scale when target is root. | 94 // We don't have to apply sublayer scale when target is root. |
95 if (target_node_id != 0) { | 95 if (target_node_id != 0) { |
96 PostConcatSublayerScale(layer->effect_tree_index(), effect_tree, | 96 const EffectNode* effect_node = |
97 &clip_to_target); | 97 effect_tree.Node(layer->effect_tree_index()); |
98 const EffectNode* target_effect_node = | |
99 effect_node->has_render_surface | |
100 ? effect_node | |
101 : effect_tree.Node(effect_node->target_id); | |
102 PostConcatSublayerScale(target_effect_node, &clip_to_target); | |
98 #if DCHECK_IS_ON() | 103 #if DCHECK_IS_ON() |
99 VerifySublayerScalesMatch(layer->effect_tree_index(), target_node_id, | 104 VerifySublayerScalesMatch(layer->effect_tree_index(), target_node_id, |
100 effect_tree, transform_tree); | 105 effect_tree, transform_tree); |
101 #endif | 106 #endif |
102 } | 107 } |
103 | 108 |
104 const TransformNode* source_node = | 109 const EffectNode* source_node = |
105 transform_tree.Node(clip_node->target_transform_id); | 110 effect_tree.Node(clip_node->target_effect_id); |
106 if (source_node->sublayer_scale.x() != 0.f && | 111 ConcatInverseSublayerScale(source_node, &clip_to_target); |
107 source_node->sublayer_scale.y() != 0.f) | 112 #if DCHECK_IS_ON() |
108 clip_to_target.Scale(1.0f / source_node->sublayer_scale.x(), | 113 VerifySublayerScalesMatch(clip_node->target_effect_id, |
109 1.0f / source_node->sublayer_scale.y()); | 114 clip_node->target_transform_id, effect_tree, |
115 transform_tree); | |
116 #endif | |
110 *clip_rect_in_target_space = MathUtil::MapClippedRect( | 117 *clip_rect_in_target_space = MathUtil::MapClippedRect( |
111 clip_to_target, clip_node->clip_in_target_space); | 118 clip_to_target, clip_node->clip_in_target_space); |
112 } else { | 119 } else { |
113 return false; | 120 return false; |
114 } | 121 } |
115 } else { | 122 } else { |
116 if (transform_tree.ComputeTransform(clip_node->target_transform_id, | 123 if (transform_tree.ComputeTransform(clip_node->target_transform_id, |
117 target_node_id, &clip_to_target)) { | 124 target_node_id, &clip_to_target)) { |
118 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( | 125 *clip_rect_in_target_space = MathUtil::ProjectClippedRect( |
119 clip_to_target, clip_node->clip_in_target_space); | 126 clip_to_target, clip_node->clip_in_target_space); |
120 } else { | 127 } else { |
121 return false; | 128 return false; |
122 } | 129 } |
123 } | 130 } |
124 return true; | 131 return true; |
125 } | 132 } |
126 | 133 |
127 struct ConditionalClip { | 134 struct ConditionalClip { |
128 bool is_clipped; | 135 bool is_clipped; |
129 gfx::RectF clip_rect; | 136 gfx::RectF clip_rect; |
130 }; | 137 }; |
131 | 138 |
132 static ConditionalClip ComputeTargetRectInLocalSpace( | 139 static ConditionalClip ComputeTargetRectInLocalSpace( |
133 gfx::RectF rect, | 140 gfx::RectF rect, |
134 const TransformTree& transform_tree, | 141 const TransformTree& transform_tree, |
142 const EffectTree& effect_tree, | |
135 int current_transform_id, | 143 int current_transform_id, |
136 int target_transform_id) { | 144 int target_transform_id, |
145 const int current_effect_id) { | |
137 gfx::Transform current_to_target; | 146 gfx::Transform current_to_target; |
138 if (!transform_tree.ComputeTransformWithSourceSublayerScale( | 147 bool success = transform_tree.ComputeTransform( |
139 current_transform_id, target_transform_id, ¤t_to_target)) | 148 current_transform_id, target_transform_id, ¤t_to_target); |
149 if (!success) | |
140 // If transform is not invertible, cannot apply clip. | 150 // If transform is not invertible, cannot apply clip. |
141 return ConditionalClip{false, gfx::RectF()}; | 151 return ConditionalClip{false, gfx::RectF()}; |
152 const EffectNode* current_effect_node = effect_tree.Node(current_effect_id); | |
153 ConcatInverseSublayerScale(current_effect_node, ¤t_to_target); | |
142 | 154 |
143 if (current_transform_id > target_transform_id) | 155 if (current_transform_id > target_transform_id) |
144 return ConditionalClip{true, // is_clipped. | 156 return ConditionalClip{true, // is_clipped. |
145 MathUtil::MapClippedRect(current_to_target, rect)}; | 157 MathUtil::MapClippedRect(current_to_target, rect)}; |
146 | 158 |
147 return ConditionalClip{true, // is_clipped. | 159 return ConditionalClip{true, // is_clipped. |
148 MathUtil::ProjectClippedRect(current_to_target, rect)}; | 160 MathUtil::ProjectClippedRect(current_to_target, rect)}; |
149 } | 161 } |
150 | 162 |
151 static ConditionalClip ComputeLocalRectInTargetSpace( | 163 static ConditionalClip ComputeLocalRectInTargetSpace( |
152 gfx::RectF rect, | 164 gfx::RectF rect, |
153 const TransformTree& transform_tree, | 165 const TransformTree& transform_tree, |
154 const EffectTree& effect_tree, | 166 const EffectTree& effect_tree, |
155 int current_transform_id, | 167 int current_transform_id, |
156 int target_transform_id, | 168 int target_transform_id, |
157 int target_effect_id) { | 169 int target_effect_id) { |
158 gfx::Transform current_to_target; | 170 gfx::Transform current_to_target; |
159 if (!transform_tree.ComputeTransform(current_transform_id, | 171 if (!transform_tree.ComputeTransform(current_transform_id, |
160 target_transform_id, ¤t_to_target)) | 172 target_transform_id, ¤t_to_target)) |
161 // If transform is not invertible, cannot apply clip. | 173 // If transform is not invertible, cannot apply clip. |
162 return ConditionalClip{false, gfx::RectF()}; | 174 return ConditionalClip{false, gfx::RectF()}; |
163 // We don't have to apply sublayer scale when target is root. | 175 // We don't have to apply sublayer scale when target is root. |
164 if (target_transform_id != 0) { | 176 if (target_transform_id != 0) { |
165 PostConcatSublayerScale(target_effect_id, effect_tree, ¤t_to_target); | 177 const EffectNode* target_effect_node = effect_tree.Node(target_effect_id); |
178 PostConcatSublayerScale(target_effect_node, ¤t_to_target); | |
166 #if DCHECK_IS_ON() | 179 #if DCHECK_IS_ON() |
167 VerifySublayerScalesMatch(target_effect_id, target_transform_id, | 180 VerifySublayerScalesMatch(target_effect_id, target_transform_id, |
168 effect_tree, transform_tree); | 181 effect_tree, transform_tree); |
169 #endif | 182 #endif |
170 } | 183 } |
171 | 184 |
172 if (current_transform_id > target_transform_id) | 185 if (current_transform_id > target_transform_id) |
173 return ConditionalClip{true, // is_clipped. | 186 return ConditionalClip{true, // is_clipped. |
174 MathUtil::MapClippedRect(current_to_target, rect)}; | 187 MathUtil::MapClippedRect(current_to_target, rect)}; |
175 | 188 |
176 return ConditionalClip{true, // is_clipped. | 189 return ConditionalClip{true, // is_clipped. |
177 MathUtil::ProjectClippedRect(current_to_target, rect)}; | 190 MathUtil::ProjectClippedRect(current_to_target, rect)}; |
178 } | 191 } |
179 | 192 |
180 static ConditionalClip ComputeCurrentClip(const ClipNode* clip_node, | 193 static ConditionalClip ComputeCurrentClip(const ClipNode* clip_node, |
181 const TransformTree& transform_tree, | 194 const TransformTree& transform_tree, |
182 const EffectTree& effect_tree, | 195 const EffectTree& effect_tree, |
183 int target_transform_id, | 196 int target_transform_id, |
184 int target_effect_id) { | 197 int target_effect_id) { |
185 if (clip_node->transform_id != target_transform_id) | 198 if (clip_node->transform_id != target_transform_id) |
186 return ComputeLocalRectInTargetSpace(clip_node->clip, transform_tree, | 199 return ComputeLocalRectInTargetSpace(clip_node->clip, transform_tree, |
187 effect_tree, clip_node->transform_id, | 200 effect_tree, clip_node->transform_id, |
188 target_transform_id, target_effect_id); | 201 target_transform_id, target_effect_id); |
189 | 202 |
190 gfx::RectF current_clip = clip_node->clip; | 203 gfx::RectF current_clip = clip_node->clip; |
191 gfx::Vector2dF sublayer_scale = | 204 gfx::Vector2dF sublayer_scale = |
192 transform_tree.Node(target_transform_id)->sublayer_scale; | 205 effect_tree.Node(target_effect_id)->sublayer_scale; |
193 if (sublayer_scale.x() > 0 && sublayer_scale.y() > 0) | 206 if (sublayer_scale.x() > 0 && sublayer_scale.y() > 0) |
194 current_clip.Scale(sublayer_scale.x(), sublayer_scale.y()); | 207 current_clip.Scale(sublayer_scale.x(), sublayer_scale.y()); |
195 return ConditionalClip{true /* is_clipped */, current_clip}; | 208 return ConditionalClip{true /* is_clipped */, current_clip}; |
196 } | 209 } |
197 | 210 |
198 static ConditionalClip ComputeAccumulatedClip( | 211 static ConditionalClip ComputeAccumulatedClip( |
199 const ClipTree& clip_tree, | 212 const ClipTree& clip_tree, |
200 int local_clip_id, | 213 int local_clip_id, |
201 const EffectTree& effect_tree, | 214 const EffectTree& effect_tree, |
202 int target_id, | 215 int target_id, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 380 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
368 continue; | 381 continue; |
369 } | 382 } |
370 | 383 |
371 gfx::RectF accumulated_clip_in_copy_request_space = | 384 gfx::RectF accumulated_clip_in_copy_request_space = |
372 accumulated_clip_rect.clip_rect; | 385 accumulated_clip_rect.clip_rect; |
373 | 386 |
374 const EffectNode* copy_request_effect_node = | 387 const EffectNode* copy_request_effect_node = |
375 effect_tree.Node(effect_ancestor_with_copy_request); | 388 effect_tree.Node(effect_ancestor_with_copy_request); |
376 ConditionalClip clip_in_layer_space = ComputeTargetRectInLocalSpace( | 389 ConditionalClip clip_in_layer_space = ComputeTargetRectInLocalSpace( |
377 accumulated_clip_in_copy_request_space, transform_tree, | 390 accumulated_clip_in_copy_request_space, transform_tree, effect_tree, |
378 copy_request_effect_node->transform_id, | 391 copy_request_effect_node->transform_id, layer->transform_tree_index(), |
379 layer->transform_tree_index()); | 392 copy_request_effect_node->id); |
380 | 393 |
381 if (clip_in_layer_space.is_clipped) { | 394 if (clip_in_layer_space.is_clipped) { |
382 gfx::RectF clip_rect = clip_in_layer_space.clip_rect; | 395 gfx::RectF clip_rect = clip_in_layer_space.clip_rect; |
383 clip_rect.Offset(-layer->offset_to_transform_parent()); | 396 clip_rect.Offset(-layer->offset_to_transform_parent()); |
384 gfx::Rect visible_rect = gfx::ToEnclosingRect(clip_rect); | 397 gfx::Rect visible_rect = gfx::ToEnclosingRect(clip_rect); |
385 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 398 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
386 layer->set_visible_layer_rect(visible_rect); | 399 layer->set_visible_layer_rect(visible_rect); |
387 } else { | 400 } else { |
388 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 401 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
389 } | 402 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 layer_content_bounds_in_target_space); | 497 layer_content_bounds_in_target_space); |
485 if (combined_clip_rect_in_target_space.IsEmpty()) { | 498 if (combined_clip_rect_in_target_space.IsEmpty()) { |
486 layer->set_visible_layer_rect(gfx::Rect()); | 499 layer->set_visible_layer_rect(gfx::Rect()); |
487 continue; | 500 continue; |
488 } | 501 } |
489 | 502 |
490 gfx::Transform target_to_layer; | 503 gfx::Transform target_to_layer; |
491 if (transform_node->ancestors_are_invertible) { | 504 if (transform_node->ancestors_are_invertible) { |
492 target_to_layer = transform_tree.FromTarget(transform_node->id); | 505 target_to_layer = transform_tree.FromTarget(transform_node->id); |
493 } else { | 506 } else { |
494 if (!transform_tree.ComputeTransformWithSourceSublayerScale( | 507 bool success = transform_tree.ComputeTransform( |
495 target_node_id, transform_node->id, &target_to_layer)) { | 508 target_node_id, transform_node->id, &target_to_layer); |
509 if (!success) { | |
496 // An animated singular transform may become non-singular during the | 510 // An animated singular transform may become non-singular during the |
497 // animation, so we still need to compute a visible rect. In this | 511 // animation, so we still need to compute a visible rect. In this |
498 // situation, we treat the entire layer as visible. | 512 // situation, we treat the entire layer as visible. |
499 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 513 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
500 continue; | 514 continue; |
501 } | 515 } |
516 if (target_node_id != 0) { | |
517 const EffectNode* effect_node = | |
518 effect_tree.Node(layer->effect_tree_index()); | |
519 const EffectNode* target_effect_node = | |
520 effect_node->has_render_surface | |
521 ? effect_node | |
522 : effect_tree.Node(effect_node->target_id); | |
523 ConcatInverseSublayerScale(target_effect_node, &target_to_layer); | |
Ian Vollick
2016/07/15 19:59:07
This logic (grab the effect node, do a ternary, ca
jaydasika
2016/07/15 20:28:49
Done.
| |
524 #if DCHECK_IS_ON() | |
525 VerifySublayerScalesMatch(target_effect_node->id, target_node_id, | |
526 effect_tree, transform_tree); | |
527 #endif | |
528 } | |
502 } | 529 } |
503 | |
504 gfx::Transform target_to_content; | 530 gfx::Transform target_to_content; |
505 target_to_content.Translate(-layer->offset_to_transform_parent().x(), | 531 target_to_content.Translate(-layer->offset_to_transform_parent().x(), |
506 -layer->offset_to_transform_parent().y()); | 532 -layer->offset_to_transform_parent().y()); |
507 target_to_content.PreconcatTransform(target_to_layer); | 533 target_to_content.PreconcatTransform(target_to_layer); |
508 | 534 |
509 gfx::Rect visible_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 535 gfx::Rect visible_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
510 target_to_content, combined_clip_rect_in_target_space)); | 536 target_to_content, combined_clip_rect_in_target_space)); |
511 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 537 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
512 layer->set_visible_layer_rect(visible_rect); | 538 layer->set_visible_layer_rect(visible_rect); |
513 } | 539 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 } | 719 } |
694 } | 720 } |
695 } | 721 } |
696 | 722 |
697 static void ResetIfHasNanCoordinate(gfx::RectF* rect) { | 723 static void ResetIfHasNanCoordinate(gfx::RectF* rect) { |
698 if (std::isnan(rect->x()) || std::isnan(rect->y()) || | 724 if (std::isnan(rect->x()) || std::isnan(rect->y()) || |
699 std::isnan(rect->right()) || std::isnan(rect->bottom())) | 725 std::isnan(rect->right()) || std::isnan(rect->bottom())) |
700 *rect = gfx::RectF(); | 726 *rect = gfx::RectF(); |
701 } | 727 } |
702 | 728 |
703 void PostConcatSublayerScale(const int effect_node_id, | 729 void PostConcatSublayerScale(const EffectNode* effect_node, |
704 const EffectTree& effect_tree, | |
705 gfx::Transform* transform) { | 730 gfx::Transform* transform) { |
706 // TODO(jaydasika): This function should not compute target effect node id. It | 731 DCHECK(effect_node->has_render_surface); |
707 // should receive it from callers. | 732 transform->matrix().postScale(effect_node->sublayer_scale.x(), |
708 const EffectNode* effect_node = effect_tree.Node(effect_node_id); | 733 effect_node->sublayer_scale.y(), 1.f); |
709 const EffectNode* target_effect_node = | |
710 effect_node->has_render_surface | |
711 ? effect_node | |
712 : effect_tree.Node(effect_node->target_id); | |
713 transform->matrix().postScale(target_effect_node->sublayer_scale.x(), | |
714 target_effect_node->sublayer_scale.y(), 1.f); | |
715 } | 734 } |
716 | 735 |
717 void ConcatInverseSublayerScale(const int effect_node_id, | 736 void ConcatInverseSublayerScale(const EffectNode* effect_node, |
718 const EffectTree& effect_tree, | |
719 gfx::Transform* transform) { | 737 gfx::Transform* transform) { |
720 const EffectNode* effect_node = effect_tree.Node(effect_node_id); | 738 DCHECK(effect_node->has_render_surface); |
721 if (effect_node->sublayer_scale.x() != 0.0 && | 739 if (effect_node->sublayer_scale.x() != 0.0 && |
722 effect_node->sublayer_scale.y() != 0.0) | 740 effect_node->sublayer_scale.y() != 0.0) |
723 transform->Scale(1.0 / effect_node->sublayer_scale.x(), | 741 transform->Scale(1.0 / effect_node->sublayer_scale.x(), |
724 1.0 / effect_node->sublayer_scale.y()); | 742 1.0 / effect_node->sublayer_scale.y()); |
725 } | 743 } |
726 | 744 |
727 void ComputeClips(ClipTree* clip_tree, | 745 void ComputeClips(ClipTree* clip_tree, |
728 const TransformTree& transform_tree, | 746 const TransformTree& transform_tree, |
729 const EffectTree& effect_tree, | 747 const EffectTree& effect_tree, |
730 bool non_root_surfaces_enabled) { | 748 bool non_root_surfaces_enabled) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
763 gfx::RectF parent_clip_in_target_space = | 781 gfx::RectF parent_clip_in_target_space = |
764 parent_clip_node->clip_in_target_space; | 782 parent_clip_node->clip_in_target_space; |
765 if (parent_target_transform_node && | 783 if (parent_target_transform_node && |
766 parent_target_transform_node->id != clip_node->target_transform_id && | 784 parent_target_transform_node->id != clip_node->target_transform_id && |
767 non_root_surfaces_enabled) { | 785 non_root_surfaces_enabled) { |
768 success &= transform_tree.ComputeTransform( | 786 success &= transform_tree.ComputeTransform( |
769 parent_target_transform_node->id, clip_node->target_transform_id, | 787 parent_target_transform_node->id, clip_node->target_transform_id, |
770 &parent_to_current); | 788 &parent_to_current); |
771 // We don't have to apply sublayer scale when target is root. | 789 // We don't have to apply sublayer scale when target is root. |
772 if (clip_node->target_transform_id != 0) { | 790 if (clip_node->target_transform_id != 0) { |
773 PostConcatSublayerScale(clip_node->target_effect_id, effect_tree, | 791 const EffectNode* target_effect_node = |
774 &parent_to_current); | 792 effect_tree.Node(clip_node->target_effect_id); |
793 PostConcatSublayerScale(target_effect_node, &parent_to_current); | |
775 #if DCHECK_IS_ON() | 794 #if DCHECK_IS_ON() |
776 VerifySublayerScalesMatch(clip_node->target_effect_id, | 795 VerifySublayerScalesMatch(clip_node->target_effect_id, |
777 clip_node->target_transform_id, effect_tree, | 796 clip_node->target_transform_id, effect_tree, |
778 transform_tree); | 797 transform_tree); |
779 #endif | 798 #endif |
780 } | 799 } |
781 if (parent_target_transform_node->sublayer_scale.x() > 0 && | 800 if (parent_clip_node->target_transform_id != 0) { |
782 parent_target_transform_node->sublayer_scale.y() > 0) | 801 const EffectNode* parent_target_effect_node = |
783 parent_to_current.Scale( | 802 effect_tree.Node(parent_clip_node->target_effect_id); |
784 1.f / parent_target_transform_node->sublayer_scale.x(), | 803 ConcatInverseSublayerScale(parent_target_effect_node, |
785 1.f / parent_target_transform_node->sublayer_scale.y()); | 804 &parent_to_current); |
805 #if DCHECK_IS_ON() | |
806 VerifySublayerScalesMatch(parent_clip_node->target_effect_id, | |
807 parent_clip_node->target_transform_id, | |
808 effect_tree, transform_tree); | |
809 #endif | |
810 } | |
786 // If we can't compute a transform, it's because we had to use the inverse | 811 // If we can't compute a transform, it's because we had to use the inverse |
787 // of a singular transform. We won't draw in this case, so there's no need | 812 // of a singular transform. We won't draw in this case, so there's no need |
788 // to compute clips. | 813 // to compute clips. |
789 if (!success) | 814 if (!success) |
790 continue; | 815 continue; |
791 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( | 816 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( |
792 parent_to_current, parent_clip_node->combined_clip_in_target_space); | 817 parent_to_current, parent_clip_node->combined_clip_in_target_space); |
793 parent_clip_in_target_space = MathUtil::ProjectClippedRect( | 818 parent_clip_in_target_space = MathUtil::ProjectClippedRect( |
794 parent_to_current, parent_clip_node->clip_in_target_space); | 819 parent_to_current, parent_clip_node->clip_in_target_space); |
795 } | 820 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
837 source_to_target = transform_tree.ToScreen(clip_node->transform_id); | 862 source_to_target = transform_tree.ToScreen(clip_node->transform_id); |
838 } else if (transform_tree.ContentTargetId(transform_node->id) == | 863 } else if (transform_tree.ContentTargetId(transform_node->id) == |
839 clip_node->target_transform_id) { | 864 clip_node->target_transform_id) { |
840 source_to_target = transform_tree.ToTarget(clip_node->transform_id); | 865 source_to_target = transform_tree.ToTarget(clip_node->transform_id); |
841 } else { | 866 } else { |
842 success = transform_tree.ComputeTransform( | 867 success = transform_tree.ComputeTransform( |
843 transform_node->id, clip_node->target_transform_id, | 868 transform_node->id, clip_node->target_transform_id, |
844 &source_to_target); | 869 &source_to_target); |
845 // We don't have to apply sublayer scale when target is root. | 870 // We don't have to apply sublayer scale when target is root. |
846 if (clip_node->target_transform_id != 0) { | 871 if (clip_node->target_transform_id != 0) { |
847 PostConcatSublayerScale(clip_node->target_effect_id, effect_tree, | 872 const EffectNode* target_effect_node = |
848 &source_to_target); | 873 effect_tree.Node(clip_node->target_effect_id); |
874 PostConcatSublayerScale(target_effect_node, &source_to_target); | |
849 #if DCHECK_IS_ON() | 875 #if DCHECK_IS_ON() |
850 VerifySublayerScalesMatch(clip_node->target_effect_id, | 876 VerifySublayerScalesMatch(clip_node->target_effect_id, |
851 clip_node->target_transform_id, effect_tree, | 877 clip_node->target_transform_id, effect_tree, |
852 transform_tree); | 878 transform_tree); |
853 #endif | 879 #endif |
854 } | 880 } |
855 // source_to_target computation should be successful as target is an | 881 // source_to_target computation should be successful as target is an |
856 // ancestor of the transform node. | 882 // ancestor of the transform node. |
857 DCHECK(success); | 883 DCHECK(success); |
858 } | 884 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
999 static void VerifyDrawTransformsMatch(LayerImpl* layer, | 1025 static void VerifyDrawTransformsMatch(LayerImpl* layer, |
1000 PropertyTrees* property_trees) { | 1026 PropertyTrees* property_trees) { |
1001 const int source_id = layer->transform_tree_index(); | 1027 const int source_id = layer->transform_tree_index(); |
1002 int destination_id = FindTargetTransformTreeIndexFromEffectTree( | 1028 int destination_id = FindTargetTransformTreeIndexFromEffectTree( |
1003 property_trees->effect_tree, layer->effect_tree_index()); | 1029 property_trees->effect_tree, layer->effect_tree_index()); |
1004 gfx::Transform draw_transform; | 1030 gfx::Transform draw_transform; |
1005 property_trees->transform_tree.ComputeTransform(source_id, destination_id, | 1031 property_trees->transform_tree.ComputeTransform(source_id, destination_id, |
1006 &draw_transform); | 1032 &draw_transform); |
1007 // We don't have to apply sublayer scale when target is root. | 1033 // We don't have to apply sublayer scale when target is root. |
1008 if (destination_id != 0) { | 1034 if (destination_id != 0) { |
1009 PostConcatSublayerScale(layer->effect_tree_index(), | 1035 const EffectNode* effect_node = |
1010 property_trees->effect_tree, &draw_transform); | 1036 property_trees->effect_tree.Node(layer->effect_tree_index()); |
1037 const EffectNode* target_effect_node = | |
1038 effect_node->has_render_surface | |
1039 ? effect_node | |
1040 : property_trees->effect_tree.Node(effect_node->target_id); | |
1041 PostConcatSublayerScale(target_effect_node, &draw_transform); | |
1011 #if DCHECK_IS_ON() | 1042 #if DCHECK_IS_ON() |
1012 VerifySublayerScalesMatch(layer->effect_tree_index(), destination_id, | 1043 VerifySublayerScalesMatch(layer->effect_tree_index(), destination_id, |
1013 property_trees->effect_tree, | 1044 property_trees->effect_tree, |
1014 property_trees->transform_tree); | 1045 property_trees->transform_tree); |
1015 #endif | 1046 #endif |
1016 } | 1047 } |
1017 if (layer->should_flatten_transform_from_property_tree()) | 1048 if (layer->should_flatten_transform_from_property_tree()) |
1018 draw_transform.FlattenTo2d(); | 1049 draw_transform.FlattenTo2d(); |
1019 draw_transform.Translate(layer->offset_to_transform_parent().x(), | 1050 draw_transform.Translate(layer->offset_to_transform_parent().x(), |
1020 layer->offset_to_transform_parent().y()); | 1051 layer->offset_to_transform_parent().y()); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 return; | 1227 return; |
1197 } | 1228 } |
1198 | 1229 |
1199 gfx::Transform render_surface_transform; | 1230 gfx::Transform render_surface_transform; |
1200 const TransformNode* target_transform_node = | 1231 const TransformNode* target_transform_node = |
1201 transform_tree.Node(transform_tree.TargetId(transform_node->id)); | 1232 transform_tree.Node(transform_tree.TargetId(transform_node->id)); |
1202 transform_tree.ComputeTransform(transform_node->id, target_transform_node->id, | 1233 transform_tree.ComputeTransform(transform_node->id, target_transform_node->id, |
1203 &render_surface_transform); | 1234 &render_surface_transform); |
1204 // We don't have to apply sublayer scale when target is root. | 1235 // We don't have to apply sublayer scale when target is root. |
1205 if (target_transform_node->id != 0) { | 1236 if (target_transform_node->id != 0) { |
1206 PostConcatSublayerScale(effect_node->target_id, effect_tree, | 1237 const EffectNode* target_effect_node = |
1207 &render_surface_transform); | 1238 effect_tree.Node(effect_node->target_id); |
1239 PostConcatSublayerScale(target_effect_node, &render_surface_transform); | |
1208 #if DCHECK_IS_ON() | 1240 #if DCHECK_IS_ON() |
1209 VerifySublayerScalesMatch(effect_node->target_id, target_transform_node->id, | 1241 VerifySublayerScalesMatch(effect_node->target_id, target_transform_node->id, |
1210 effect_tree, transform_tree); | 1242 effect_tree, transform_tree); |
1211 #endif | 1243 #endif |
1212 } | 1244 } |
1213 | 1245 |
1214 DCHECK(transform_node->sublayer_scale == effect_node->sublayer_scale); | 1246 ConcatInverseSublayerScale(effect_node, &render_surface_transform); |
1215 if (effect_node->sublayer_scale.x() != 0.0 && | 1247 #if DCHECK_IS_ON() |
1216 effect_node->sublayer_scale.y() != 0.0) | 1248 VerifySublayerScalesMatch(effect_node->id, transform_node->id, effect_tree, |
1217 render_surface_transform.Scale(1.0 / effect_node->sublayer_scale.x(), | 1249 transform_tree); |
1218 1.0 / effect_node->sublayer_scale.y()); | 1250 #endif |
1219 render_surface->SetDrawTransform(render_surface_transform); | 1251 render_surface->SetDrawTransform(render_surface_transform); |
1220 } | 1252 } |
1221 | 1253 |
1222 static void SetSurfaceIsClipped(const ClipNode* clip_node, | 1254 static void SetSurfaceIsClipped(const ClipNode* clip_node, |
1223 RenderSurfaceImpl* render_surface) { | 1255 RenderSurfaceImpl* render_surface) { |
1224 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) | 1256 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) |
1225 << "we now create clip node for every render surface"; | 1257 << "we now create clip node for every render surface"; |
1226 | 1258 |
1227 render_surface->SetIsClipped(clip_node->target_is_clipped); | 1259 render_surface->SetIsClipped(clip_node->target_is_clipped); |
1228 } | 1260 } |
(...skipping 25 matching lines...) Expand all Loading... | |
1254 transform_tree.TargetId(transform_node->id), | 1286 transform_tree.TargetId(transform_node->id), |
1255 &clip_parent_target_to_target); | 1287 &clip_parent_target_to_target); |
1256 | 1288 |
1257 if (!success) { | 1289 if (!success) { |
1258 render_surface->SetClipRect(gfx::Rect()); | 1290 render_surface->SetClipRect(gfx::Rect()); |
1259 return; | 1291 return; |
1260 } | 1292 } |
1261 | 1293 |
1262 // We don't have to apply sublayer scale when target is root. | 1294 // We don't have to apply sublayer scale when target is root. |
1263 if (transform_tree.TargetId(transform_node->id) != 0) { | 1295 if (transform_tree.TargetId(transform_node->id) != 0) { |
1264 PostConcatSublayerScale(render_surface->EffectTreeIndex(), effect_tree, | 1296 const EffectNode* effect_node = |
1265 &clip_parent_target_to_target); | 1297 effect_tree.Node(render_surface->EffectTreeIndex()); |
1298 PostConcatSublayerScale(effect_node, &clip_parent_target_to_target); | |
1266 #if DCHECK_IS_ON() | 1299 #if DCHECK_IS_ON() |
1267 VerifySublayerScalesMatch(render_surface->EffectTreeIndex(), | 1300 VerifySublayerScalesMatch(render_surface->EffectTreeIndex(), |
1268 transform_tree.TargetId(transform_node->id), | 1301 transform_tree.TargetId(transform_node->id), |
1269 effect_tree, transform_tree); | 1302 effect_tree, transform_tree); |
1270 #endif | 1303 #endif |
1271 } | 1304 } |
1272 | 1305 |
1273 DCHECK_LT(parent_clip_node->target_transform_id, | 1306 DCHECK_LT(parent_clip_node->target_transform_id, |
1274 transform_tree.TargetId(transform_node->id)); | 1307 transform_tree.TargetId(transform_node->id)); |
1275 render_surface->SetClipRect(gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 1308 render_surface->SetClipRect(gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1536 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1569 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
1537 const Layer* overscroll_elasticity_layer, | 1570 const Layer* overscroll_elasticity_layer, |
1538 const gfx::Vector2dF& elastic_overscroll) { | 1571 const gfx::Vector2dF& elastic_overscroll) { |
1539 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1572 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
1540 elastic_overscroll); | 1573 elastic_overscroll); |
1541 } | 1574 } |
1542 | 1575 |
1543 } // namespace draw_property_utils | 1576 } // namespace draw_property_utils |
1544 | 1577 |
1545 } // namespace cc | 1578 } // namespace cc |
OLD | NEW |