| 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 "core/paint/PaintInvalidator.h" | 5 #include "core/paint/PaintInvalidator.h" |
| 6 | 6 |
| 7 #include "core/editing/FrameSelection.h" | 7 #include "core/editing/FrameSelection.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // TODO(wangxianzhu): Combine this into | 46 // TODO(wangxianzhu): Combine this into |
| 47 // PaintInvalidator::mapLocalRectToBacking() when removing | 47 // PaintInvalidator::mapLocalRectToBacking() when removing |
| 48 // PaintInvalidationState. | 48 // PaintInvalidationState. |
| 49 // This function is templatized to avoid FloatRect<->LayoutRect conversions | 49 // This function is templatized to avoid FloatRect<->LayoutRect conversions |
| 50 // which affect performance. | 50 // which affect performance. |
| 51 template <typename Rect, typename Point> | 51 template <typename Rect, typename Point> |
| 52 static LayoutRect mapLocalRectToVisualRectInBacking( | 52 static LayoutRect mapLocalRectToVisualRectInBacking( |
| 53 const LayoutObject& object, | 53 const LayoutObject& object, |
| 54 const Rect& localRect, | 54 const Rect& localRect, |
| 55 const PaintInvalidatorContext& context, | 55 const PaintInvalidatorContext& context) { |
| 56 GeometryMapper& geometryMapper) { | |
| 57 if (localRect.isEmpty()) | 56 if (localRect.isEmpty()) |
| 58 return LayoutRect(); | 57 return LayoutRect(); |
| 59 | 58 |
| 60 bool isSVGChild = object.isSVGChild(); | 59 bool isSVGChild = object.isSVGChild(); |
| 61 | 60 |
| 62 // TODO(wkorman): The flip below is required because visual rects are | 61 // TODO(wkorman): The flip below is required because visual rects are |
| 63 // currently in "physical coordinates with flipped block-flow direction" | 62 // currently in "physical coordinates with flipped block-flow direction" |
| 64 // (see LayoutBoxModelObject.h) but we need them to be in physical | 63 // (see LayoutBoxModelObject.h) but we need them to be in physical |
| 65 // coordinates. | 64 // coordinates. |
| 66 Rect rect = localRect; | 65 Rect rect = localRect; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (!isSVGChild && | 122 if (!isSVGChild && |
| 124 context.treeBuilderContext.current.transform != | 123 context.treeBuilderContext.current.transform != |
| 125 containerContentsProperties->transform()) | 124 containerContentsProperties->transform()) |
| 126 rect = Rect(enclosingIntRect(rect)); | 125 rect = Rect(enclosingIntRect(rect)); |
| 127 | 126 |
| 128 PropertyTreeState currentTreeState( | 127 PropertyTreeState currentTreeState( |
| 129 context.treeBuilderContext.current.transform, | 128 context.treeBuilderContext.current.transform, |
| 130 context.treeBuilderContext.current.clip, nullptr); | 129 context.treeBuilderContext.current.clip, nullptr); |
| 131 | 130 |
| 132 FloatRect floatRect(rect); | 131 FloatRect floatRect(rect); |
| 133 geometryMapper.sourceToDestinationVisualRect( | 132 context.geometryMapper.sourceToDestinationVisualRect( |
| 134 currentTreeState, *containerContentsProperties, floatRect); | 133 currentTreeState, *containerContentsProperties, floatRect); |
| 135 result = LayoutRect(floatRect); | 134 result = LayoutRect(floatRect); |
| 136 } | 135 } |
| 137 | 136 |
| 138 // Convert the result to the container's contents space. | 137 // Convert the result to the container's contents space. |
| 139 result.moveBy(-context.paintInvalidationContainer->paintOffset()); | 138 result.moveBy(-context.paintInvalidationContainer->paintOffset()); |
| 140 } | 139 } |
| 141 | 140 |
| 142 object.adjustVisualRectForRasterEffects(result); | 141 object.adjustVisualRectForRasterEffects(result); |
| 143 | 142 |
| 144 PaintLayer::mapRectInPaintInvalidationContainerToBacking( | 143 PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
| 145 *context.paintInvalidationContainer, result); | 144 *context.paintInvalidationContainer, result); |
| 146 | 145 |
| 147 result.move(object.scrollAdjustmentForPaintInvalidation( | 146 result.move(object.scrollAdjustmentForPaintInvalidation( |
| 148 *context.paintInvalidationContainer)); | 147 *context.paintInvalidationContainer)); |
| 149 | 148 |
| 150 return result; | 149 return result; |
| 151 } | 150 } |
| 152 | 151 |
| 153 void PaintInvalidatorContext::mapLocalRectToVisualRectInBacking( | 152 void PaintInvalidatorContext::mapLocalRectToVisualRectInBacking( |
| 154 const LayoutObject& object, | 153 const LayoutObject& object, |
| 155 LayoutRect& rect) const { | 154 LayoutRect& rect) const { |
| 156 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | |
| 157 rect = blink::mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>( | 155 rect = blink::mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>( |
| 158 object, rect, *this, *geometryMapper); | 156 object, rect, *this); |
| 159 } | 157 } |
| 160 | 158 |
| 161 LayoutRect PaintInvalidator::computeVisualRectInBacking( | 159 LayoutRect PaintInvalidator::computeVisualRectInBacking( |
| 162 const LayoutObject& object, | 160 const LayoutObject& object, |
| 163 const PaintInvalidatorContext& context) { | 161 const PaintInvalidatorContext& context) { |
| 164 if (object.isSVGChild()) { | 162 if (object.isSVGChild()) { |
| 165 FloatRect localRect = SVGLayoutSupport::localVisualRect(object); | 163 FloatRect localRect = SVGLayoutSupport::localVisualRect(object); |
| 166 return mapLocalRectToVisualRectInBacking<FloatRect, FloatPoint>( | 164 return mapLocalRectToVisualRectInBacking<FloatRect, FloatPoint>( |
| 167 object, localRect, context, m_geometryMapper); | 165 object, localRect, context); |
| 168 } | 166 } |
| 169 return mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>( | 167 return mapLocalRectToVisualRectInBacking<LayoutRect, LayoutPoint>( |
| 170 object, object.localVisualRect(), context, m_geometryMapper); | 168 object, object.localVisualRect(), context); |
| 171 } | 169 } |
| 172 | 170 |
| 173 LayoutPoint PaintInvalidator::computeLocationInBacking( | 171 LayoutPoint PaintInvalidator::computeLocationInBacking( |
| 174 const LayoutObject& object, | 172 const LayoutObject& object, |
| 175 const PaintInvalidatorContext& context) { | 173 const PaintInvalidatorContext& context) { |
| 176 // In SPv2, locationInBacking is in the space of their local transform node. | 174 // In SPv2, locationInBacking is in the space of their local transform node. |
| 177 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 175 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 178 return object.paintOffset(); | 176 return object.paintOffset(); |
| 179 | 177 |
| 180 LayoutPoint point; | 178 LayoutPoint point; |
| 181 if (object != context.paintInvalidationContainer) { | 179 if (object != context.paintInvalidationContainer) { |
| 182 point.moveBy(object.paintOffset()); | 180 point.moveBy(object.paintOffset()); |
| 183 | 181 |
| 184 const auto* containerTransform = | 182 const auto* containerTransform = |
| 185 context.paintInvalidationContainer->paintProperties() | 183 context.paintInvalidationContainer->paintProperties() |
| 186 ->contentsProperties() | 184 ->contentsProperties() |
| 187 ->transform(); | 185 ->transform(); |
| 188 if (context.treeBuilderContext.current.transform != containerTransform) { | 186 if (context.treeBuilderContext.current.transform != containerTransform) { |
| 189 FloatRect rect = FloatRect(FloatPoint(point), FloatSize()); | 187 FloatRect rect = FloatRect(FloatPoint(point), FloatSize()); |
| 190 m_geometryMapper.sourceToDestinationRect( | 188 context.geometryMapper.sourceToDestinationRect( |
| 191 context.treeBuilderContext.current.transform, containerTransform, | 189 context.treeBuilderContext.current.transform, containerTransform, |
| 192 rect); | 190 rect); |
| 193 point = LayoutPoint(rect.location()); | 191 point = LayoutPoint(rect.location()); |
| 194 } | 192 } |
| 195 | 193 |
| 196 // Convert the result to the container's contents space. | 194 // Convert the result to the container's contents space. |
| 197 point.moveBy(-context.paintInvalidationContainer->paintOffset()); | 195 point.moveBy(-context.paintInvalidationContainer->paintOffset()); |
| 198 } | 196 } |
| 199 | 197 |
| 200 if (context.paintInvalidationContainer->layer()->groupedMapping()) { | 198 if (context.paintInvalidationContainer->layer()->groupedMapping()) { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 489 } |
| 492 } | 490 } |
| 493 | 491 |
| 494 void PaintInvalidator::processPendingDelayedPaintInvalidations() { | 492 void PaintInvalidator::processPendingDelayedPaintInvalidations() { |
| 495 for (auto target : m_pendingDelayedPaintInvalidations) | 493 for (auto target : m_pendingDelayedPaintInvalidations) |
| 496 target->getMutableForPainting().setShouldDoFullPaintInvalidation( | 494 target->getMutableForPainting().setShouldDoFullPaintInvalidation( |
| 497 PaintInvalidationDelayedFull); | 495 PaintInvalidationDelayedFull); |
| 498 } | 496 } |
| 499 | 497 |
| 500 } // namespace blink | 498 } // namespace blink |
| OLD | NEW |