| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/paint/GeometryMapper.h" | 5 #include "platform/graphics/paint/GeometryMapper.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 const auto& transform_matrix = LocalToAncestorMatrixInternal( | 114 const auto& transform_matrix = LocalToAncestorMatrixInternal( |
| 115 local_state.Transform(), ancestor_state.Transform(), success); | 115 local_state.Transform(), ancestor_state.Transform(), success); |
| 116 if (!success) { | 116 if (!success) { |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 | 119 |
| 120 FloatRect mapped_rect = transform_matrix.MapRect(rect_to_map.Rect()); | 120 FloatRect mapped_rect = transform_matrix.MapRect(rect_to_map.Rect()); |
| 121 | 121 |
| 122 FloatClipRect clip_rect = | 122 const FloatClipRect& clip_rect = |
| 123 LocalToAncestorClipRectInternal(local_state.Clip(), ancestor_state.Clip(), | 123 LocalToAncestorClipRectInternal(local_state.Clip(), ancestor_state.Clip(), |
| 124 ancestor_state.Transform(), success); | 124 ancestor_state.Transform(), success); |
| 125 | 125 |
| 126 if (success) { | 126 if (success) { |
| 127 // This is where we propagate the rounded-ness of |clipRect| to | 127 // This is where we propagate the rounded-ness of |clipRect| to |
| 128 // |rectToMap|. | 128 // |rectToMap|. |
| 129 rect_to_map = clip_rect; | 129 rect_to_map = clip_rect; |
| 130 rect_to_map.Intersect(mapped_rect); | 130 rect_to_map.Intersect(mapped_rect); |
| 131 } else if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 131 } else if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 132 // On SPv1 we may fail when the paint invalidation container creates an | 132 // On SPv1 we may fail when the paint invalidation container creates an |
| 133 // overflow clip (in ancestorState) which is not in localState of an | 133 // overflow clip (in ancestorState) which is not in localState of an |
| 134 // out-of-flow positioned descendant. See crbug.com/513108 and layout test | 134 // out-of-flow positioned descendant. See crbug.com/513108 and layout test |
| 135 // compositing/overflow/handle-non-ancestor-clip-parent.html (run with | 135 // compositing/overflow/handle-non-ancestor-clip-parent.html (run with |
| 136 // --enable-prefer-compositing-to-lcd-text) for details. | 136 // --enable-prefer-compositing-to-lcd-text) for details. |
| 137 // Ignore it for SPv1 for now. | 137 // Ignore it for SPv1 for now. |
| 138 success = true; | 138 success = true; |
| 139 rect_to_map.SetRect(mapped_rect); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 void GeometryMapper::SlowLocalToAncestorVisualRectWithEffects( | 143 void GeometryMapper::SlowLocalToAncestorVisualRectWithEffects( |
| 143 const PropertyTreeState& local_state, | 144 const PropertyTreeState& local_state, |
| 144 const PropertyTreeState& ancestor_state, | 145 const PropertyTreeState& ancestor_state, |
| 145 FloatClipRect& mapping_rect, | 146 FloatClipRect& mapping_rect, |
| 146 bool& success) { | 147 bool& success) { |
| 147 PropertyTreeState last_transform_and_clip_state(local_state.Transform(), | 148 PropertyTreeState last_transform_and_clip_state(local_state.Transform(), |
| 148 local_state.Clip(), nullptr); | 149 local_state.Clip(), nullptr); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return; | 207 return; |
| 207 | 208 |
| 208 const auto& transform_matrix = | 209 const auto& transform_matrix = |
| 209 LocalToAncestorMatrix(local_transform_node, ancestor_transform_node); | 210 LocalToAncestorMatrix(local_transform_node, ancestor_transform_node); |
| 210 DCHECK(transform_matrix.IsInvertible()); | 211 DCHECK(transform_matrix.IsInvertible()); |
| 211 | 212 |
| 212 // TODO(chrishtr): Cache the inverse? | 213 // TODO(chrishtr): Cache the inverse? |
| 213 rect = transform_matrix.Inverse().MapRect(rect); | 214 rect = transform_matrix.Inverse().MapRect(rect); |
| 214 } | 215 } |
| 215 | 216 |
| 216 FloatClipRect GeometryMapper::LocalToAncestorClipRect( | 217 const FloatClipRect& GeometryMapper::LocalToAncestorClipRect( |
| 217 const PropertyTreeState& local_state, | 218 const PropertyTreeState& local_state, |
| 218 const PropertyTreeState& ancestor_state) { | 219 const PropertyTreeState& ancestor_state) { |
| 219 bool success = false; | 220 bool success = false; |
| 220 FloatClipRect result = | 221 const FloatClipRect& result = |
| 221 LocalToAncestorClipRectInternal(local_state.Clip(), ancestor_state.Clip(), | 222 LocalToAncestorClipRectInternal(local_state.Clip(), ancestor_state.Clip(), |
| 222 ancestor_state.Transform(), success); | 223 ancestor_state.Transform(), success); |
| 223 | 224 |
| 224 DCHECK(success); | 225 DCHECK(success); |
| 225 | 226 |
| 226 return result; | 227 return result; |
| 227 } | 228 } |
| 228 | 229 |
| 229 const FloatClipRect& GeometryMapper::SourceToDestinationClipRect( | 230 const FloatClipRect& GeometryMapper::SourceToDestinationClipRect( |
| 230 const PropertyTreeState& source_state, | 231 const PropertyTreeState& source_state, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 const TransformPaintPropertyNode*, | 471 const TransformPaintPropertyNode*, |
| 471 const TransformPaintPropertyNode*); | 472 const TransformPaintPropertyNode*); |
| 472 template const ClipPaintPropertyNode* GeometryMapper::LowestCommonAncestor( | 473 template const ClipPaintPropertyNode* GeometryMapper::LowestCommonAncestor( |
| 473 const ClipPaintPropertyNode*, | 474 const ClipPaintPropertyNode*, |
| 474 const ClipPaintPropertyNode*); | 475 const ClipPaintPropertyNode*); |
| 475 template const ScrollPaintPropertyNode* GeometryMapper::LowestCommonAncestor( | 476 template const ScrollPaintPropertyNode* GeometryMapper::LowestCommonAncestor( |
| 476 const ScrollPaintPropertyNode*, | 477 const ScrollPaintPropertyNode*, |
| 477 const ScrollPaintPropertyNode*); | 478 const ScrollPaintPropertyNode*); |
| 478 | 479 |
| 479 } // namespace blink | 480 } // namespace blink |
| OLD | NEW |