| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 FloatClipRect GeometryMapper::localToAncestorVisualRectInternal( | 87 FloatClipRect GeometryMapper::localToAncestorVisualRectInternal( |
| 88 const FloatRect& rect, | 88 const FloatRect& rect, |
| 89 const PropertyTreeState& localState, | 89 const PropertyTreeState& localState, |
| 90 const PropertyTreeState& ancestorState, | 90 const PropertyTreeState& ancestorState, |
| 91 bool& success) { | 91 bool& success) { |
| 92 if (localState == ancestorState) { | 92 if (localState == ancestorState) { |
| 93 success = true; | 93 success = true; |
| 94 return rect; | 94 return rect; |
| 95 } | 95 } |
| 96 | 96 |
| 97 if (localState.effect() != ancestorState.effect()) { |
| 98 return slowLocalToAncestorVisualRectWithEffects(rect, localState, |
| 99 ancestorState, success); |
| 100 } |
| 101 |
| 97 const auto& transformMatrix = localToAncestorMatrixInternal( | 102 const auto& transformMatrix = localToAncestorMatrixInternal( |
| 98 localState.transform(), ancestorState.transform(), success); | 103 localState.transform(), ancestorState.transform(), success); |
| 99 if (!success) | 104 if (!success) |
| 100 return rect; | 105 return rect; |
| 101 | 106 |
| 102 FloatRect mappedRect = transformMatrix.mapRect(rect); | 107 FloatRect mappedRect = transformMatrix.mapRect(rect); |
| 103 | 108 |
| 104 FloatClipRect clipRect = | 109 FloatClipRect clipRect = |
| 105 localToAncestorClipRectInternal(localState, ancestorState, success); | 110 localToAncestorClipRectInternal(localState, ancestorState, success); |
| 106 | 111 |
| 107 if (success) { | 112 if (success) { |
| 108 clipRect.intersect(mappedRect); | 113 clipRect.intersect(mappedRect); |
| 109 } else if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 114 } else if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 110 // On SPv1 we may fail when the paint invalidation container creates an | 115 // On SPv1 we may fail when the paint invalidation container creates an |
| 111 // overflow clip (in ancestorState) which is not in localState of an | 116 // overflow clip (in ancestorState) which is not in localState of an |
| 112 // out-of-flow positioned descendant. See crbug.com/513108 and layout test | 117 // out-of-flow positioned descendant. See crbug.com/513108 and layout test |
| 113 // compositing/overflow/handle-non-ancestor-clip-parent.html (run with | 118 // compositing/overflow/handle-non-ancestor-clip-parent.html (run with |
| 114 // --enable-prefer-compositing-to-lcd-text) for details. | 119 // --enable-prefer-compositing-to-lcd-text) for details. |
| 115 // Ignore it for SPv1 for now. | 120 // Ignore it for SPv1 for now. |
| 116 success = true; | 121 success = true; |
| 117 } | 122 } |
| 118 | 123 |
| 119 return clipRect; | 124 return clipRect; |
| 120 } | 125 } |
| 121 | 126 |
| 127 FloatClipRect GeometryMapper::slowLocalToAncestorVisualRectWithEffects( |
| 128 const FloatRect& rect, |
| 129 const PropertyTreeState& localState, |
| 130 const PropertyTreeState& ancestorState, |
| 131 bool& success) { |
| 132 PropertyTreeState lastTransformAndClipState(localState.transform(), |
| 133 localState.clip(), nullptr); |
| 134 FloatClipRect result(rect); |
| 135 |
| 136 for (const auto* effect = localState.effect(); |
| 137 effect && effect != ancestorState.effect(); effect = effect->parent()) { |
| 138 if (!effect->hasFilterThatMovesPixels()) |
| 139 continue; |
| 140 |
| 141 PropertyTreeState transformAndClipState(effect->localTransformSpace(), |
| 142 effect->outputClip(), nullptr); |
| 143 bool hasRadius = result.hasRadius(); |
| 144 result = sourceToDestinationVisualRectInternal( |
| 145 result.rect(), lastTransformAndClipState, transformAndClipState, |
| 146 success); |
| 147 hasRadius |= result.hasRadius(); |
| 148 if (!success) { |
| 149 result.setHasRadius(hasRadius); |
| 150 return result; |
| 151 } |
| 152 |
| 153 result = effect->mapRect(result.rect()); |
| 154 result.setHasRadius(hasRadius); |
| 155 lastTransformAndClipState = transformAndClipState; |
| 156 } |
| 157 |
| 158 PropertyTreeState finalTransformAndClipState(ancestorState.transform(), |
| 159 ancestorState.clip(), nullptr); |
| 160 bool hasRadius = result.hasRadius(); |
| 161 result = sourceToDestinationVisualRectInternal( |
| 162 result.rect(), lastTransformAndClipState, finalTransformAndClipState, |
| 163 success); |
| 164 result.setHasRadius(hasRadius || result.hasRadius()); |
| 165 return result; |
| 166 } |
| 167 |
| 122 FloatRect GeometryMapper::localToAncestorRect( | 168 FloatRect GeometryMapper::localToAncestorRect( |
| 123 const FloatRect& rect, | 169 const FloatRect& rect, |
| 124 const TransformPaintPropertyNode* localTransformNode, | 170 const TransformPaintPropertyNode* localTransformNode, |
| 125 const TransformPaintPropertyNode* ancestorTransformNode) { | 171 const TransformPaintPropertyNode* ancestorTransformNode) { |
| 126 bool success = false; | 172 bool success = false; |
| 127 FloatRect result = localToAncestorRectInternal( | 173 FloatRect result = localToAncestorRectInternal( |
| 128 rect, localTransformNode, ancestorTransformNode, success); | 174 rect, localTransformNode, ancestorTransformNode, success); |
| 129 DCHECK(success); | 175 DCHECK(success); |
| 130 return result; | 176 return result; |
| 131 } | 177 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 const TransformPaintPropertyNode*, | 404 const TransformPaintPropertyNode*, |
| 359 const TransformPaintPropertyNode*); | 405 const TransformPaintPropertyNode*); |
| 360 template const ClipPaintPropertyNode* GeometryMapper::lowestCommonAncestor( | 406 template const ClipPaintPropertyNode* GeometryMapper::lowestCommonAncestor( |
| 361 const ClipPaintPropertyNode*, | 407 const ClipPaintPropertyNode*, |
| 362 const ClipPaintPropertyNode*); | 408 const ClipPaintPropertyNode*); |
| 363 template const ScrollPaintPropertyNode* GeometryMapper::lowestCommonAncestor( | 409 template const ScrollPaintPropertyNode* GeometryMapper::lowestCommonAncestor( |
| 364 const ScrollPaintPropertyNode*, | 410 const ScrollPaintPropertyNode*, |
| 365 const ScrollPaintPropertyNode*); | 411 const ScrollPaintPropertyNode*); |
| 366 | 412 |
| 367 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |