| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 FloatRect GeometryMapper::localToAncestorVisualRectInternal( | 85 FloatRect GeometryMapper::localToAncestorVisualRectInternal( |
| 86 const FloatRect& rect, | 86 const FloatRect& rect, |
| 87 const PropertyTreeState& localState, | 87 const PropertyTreeState& localState, |
| 88 const PropertyTreeState& ancestorState, | 88 const PropertyTreeState& ancestorState, |
| 89 bool& success) { | 89 bool& success) { |
| 90 if (localState == ancestorState) { | 90 if (localState == ancestorState) { |
| 91 success = true; | 91 success = true; |
| 92 return rect; | 92 return rect; |
| 93 } | 93 } |
| 94 | 94 |
| 95 if (localState.effect() != ancestorState.effect()) { |
| 96 return slowLocalToAncestorVisualRectWithEffects(rect, localState, |
| 97 ancestorState, success); |
| 98 } |
| 99 |
| 95 const auto& transformMatrix = localToAncestorMatrixInternal( | 100 const auto& transformMatrix = localToAncestorMatrixInternal( |
| 96 localState.transform(), ancestorState.transform(), success); | 101 localState.transform(), ancestorState.transform(), success); |
| 97 if (!success) | 102 if (!success) |
| 98 return rect; | 103 return rect; |
| 99 | 104 |
| 100 FloatRect mappedRect = transformMatrix.mapRect(rect); | 105 FloatRect mappedRect = transformMatrix.mapRect(rect); |
| 101 | 106 |
| 102 const auto clipRect = | 107 const auto clipRect = |
| 103 localToAncestorClipRectInternal(localState, ancestorState, success); | 108 localToAncestorClipRectInternal(localState, ancestorState, success); |
| 104 | 109 |
| 105 if (success) { | 110 if (success) { |
| 106 mappedRect.intersect(clipRect); | 111 mappedRect.intersect(clipRect); |
| 107 } else if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 112 } else if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 108 // On SPv1 we may fail when the paint invalidation container creates an | 113 // On SPv1 we may fail when the paint invalidation container creates an |
| 109 // overflow clip (in ancestorState) which is not in localState of an | 114 // overflow clip (in ancestorState) which is not in localState of an |
| 110 // out-of-flow positioned descendant. See crbug.com/513108 and layout test | 115 // out-of-flow positioned descendant. See crbug.com/513108 and layout test |
| 111 // compositing/overflow/handle-non-ancestor-clip-parent.html (run with | 116 // compositing/overflow/handle-non-ancestor-clip-parent.html (run with |
| 112 // --enable-prefer-compositing-to-lcd-text) for details. | 117 // --enable-prefer-compositing-to-lcd-text) for details. |
| 113 // Ignore it for SPv1 for now. | 118 // Ignore it for SPv1 for now. |
| 114 success = true; | 119 success = true; |
| 115 } | 120 } |
| 116 | 121 |
| 117 return mappedRect; | 122 return mappedRect; |
| 118 } | 123 } |
| 119 | 124 |
| 125 FloatRect GeometryMapper::slowLocalToAncestorVisualRectWithEffects( |
| 126 const FloatRect& rect, |
| 127 const PropertyTreeState& localState, |
| 128 const PropertyTreeState& ancestorState, |
| 129 bool& success) { |
| 130 PropertyTreeState lastTransformAndClipState( |
| 131 localState.transform(), localState.clip(), nullptr, nullptr); |
| 132 FloatRect result = rect; |
| 133 |
| 134 for (const auto* effect = localState.effect(); |
| 135 effect && effect != ancestorState.effect(); effect = effect->parent()) { |
| 136 if (!effect->hasFilterThanMovesPixels()) |
| 137 continue; |
| 138 |
| 139 PropertyTreeState transformAndClipState( |
| 140 effect->localTransformSpace(), effect->outputClip(), nullptr, nullptr); |
| 141 result = sourceToDestinationVisualRectInternal( |
| 142 result, lastTransformAndClipState, transformAndClipState, success); |
| 143 if (!success) |
| 144 return result; |
| 145 |
| 146 result = effect->mapRect(result); |
| 147 lastTransformAndClipState = transformAndClipState; |
| 148 } |
| 149 |
| 150 PropertyTreeState finalTransformAndClipState( |
| 151 ancestorState.transform(), ancestorState.clip(), nullptr, nullptr); |
| 152 return sourceToDestinationVisualRectInternal( |
| 153 result, lastTransformAndClipState, finalTransformAndClipState, success); |
| 154 } |
| 155 |
| 120 FloatRect GeometryMapper::localToAncestorRect( | 156 FloatRect GeometryMapper::localToAncestorRect( |
| 121 const FloatRect& rect, | 157 const FloatRect& rect, |
| 122 const TransformPaintPropertyNode* localTransformNode, | 158 const TransformPaintPropertyNode* localTransformNode, |
| 123 const TransformPaintPropertyNode* ancestorTransformNode) { | 159 const TransformPaintPropertyNode* ancestorTransformNode) { |
| 124 bool success = false; | 160 bool success = false; |
| 125 FloatRect result = localToAncestorRectInternal( | 161 FloatRect result = localToAncestorRectInternal( |
| 126 rect, localTransformNode, ancestorTransformNode, success); | 162 rect, localTransformNode, ancestorTransformNode, success); |
| 127 DCHECK(success); | 163 DCHECK(success); |
| 128 return result; | 164 return result; |
| 129 } | 165 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 const TransformPaintPropertyNode*, | 374 const TransformPaintPropertyNode*, |
| 339 const TransformPaintPropertyNode*); | 375 const TransformPaintPropertyNode*); |
| 340 template const ClipPaintPropertyNode* GeometryMapper::lowestCommonAncestor( | 376 template const ClipPaintPropertyNode* GeometryMapper::lowestCommonAncestor( |
| 341 const ClipPaintPropertyNode*, | 377 const ClipPaintPropertyNode*, |
| 342 const ClipPaintPropertyNode*); | 378 const ClipPaintPropertyNode*); |
| 343 template const ScrollPaintPropertyNode* GeometryMapper::lowestCommonAncestor( | 379 template const ScrollPaintPropertyNode* GeometryMapper::lowestCommonAncestor( |
| 344 const ScrollPaintPropertyNode*, | 380 const ScrollPaintPropertyNode*, |
| 345 const ScrollPaintPropertyNode*); | 381 const ScrollPaintPropertyNode*); |
| 346 | 382 |
| 347 } // namespace blink | 383 } // namespace blink |
| OLD | NEW |