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 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 // TODO(wangxianzhu): Combine this into | 43 // TODO(wangxianzhu): Combine this into |
44 // PaintInvalidator::mapLocalRectToBacking() when removing | 44 // PaintInvalidator::mapLocalRectToBacking() when removing |
45 // PaintInvalidationState. | 45 // PaintInvalidationState. |
46 static LayoutRect mapLocalRectToPaintInvalidationBacking( | 46 static LayoutRect mapLocalRectToPaintInvalidationBacking( |
47 GeometryMapper& geometryMapper, | 47 GeometryMapper& geometryMapper, |
48 const LayoutObject& object, | 48 const LayoutObject& object, |
49 const FloatRect& localRect, | 49 const FloatRect& localRect, |
50 const PaintInvalidatorContext& context) { | 50 const PaintInvalidatorContext& context) { |
| 51 bool isSVGChild = object.isSVGChild(); |
| 52 |
51 // TODO(wkorman): The flip below is required because visual rects are | 53 // TODO(wkorman): The flip below is required because visual rects are |
52 // currently in "physical coordinates with flipped block-flow direction" | 54 // currently in "physical coordinates with flipped block-flow direction" |
53 // (see LayoutBoxModelObject.h) but we need them to be in physical | 55 // (see LayoutBoxModelObject.h) but we need them to be in physical |
54 // coordinates. | 56 // coordinates. |
55 FloatRect rect = localRect; | 57 FloatRect rect = localRect; |
56 // Writing-mode flipping doesn't apply to non-root SVG. | 58 // Writing-mode flipping doesn't apply to non-root SVG. |
57 if (!object.isSVGChild()) { | 59 if (!isSVGChild) { |
58 if (object.isBox()) { | 60 if (object.isBox()) { |
59 toLayoutBox(object).flipForWritingMode(rect); | 61 toLayoutBox(object).flipForWritingMode(rect); |
60 } else if (!(context.forcedSubtreeInvalidationFlags & | 62 } else if (!(context.forcedSubtreeInvalidationFlags & |
61 PaintInvalidatorContext::ForcedSubtreeSlowPathRect)) { | 63 PaintInvalidatorContext::ForcedSubtreeSlowPathRect)) { |
62 // For SPv2 and the GeometryMapper path, we also need to convert the rect | 64 // For SPv2 and the GeometryMapper path, we also need to convert the rect |
63 // for non-boxes into physical coordinates before applying paint offset. | 65 // for non-boxes into physical coordinates before applying paint offset. |
64 // (Otherwise we'll call mapToVisualrectInAncestorSpace() which requires | 66 // (Otherwise we'll call mapToVisualrectInAncestorSpace() which requires |
65 // physical coordinates for boxes, but "physical coordinates with flipped | 67 // physical coordinates for boxes, but "physical coordinates with flipped |
66 // block-flow direction" for non-boxes for which we don't need to flip.) | 68 // block-flow direction" for non-boxes for which we don't need to flip.) |
67 // TODO(wangxianzhu): Avoid containingBlock(). | 69 // TODO(wangxianzhu): Avoid containingBlock(). |
68 object.containingBlock()->flipForWritingMode(rect); | 70 object.containingBlock()->flipForWritingMode(rect); |
69 } | 71 } |
70 } | 72 } |
71 | 73 |
72 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 74 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
73 // In SPv2, visual rects are in the space of their local transform node. | 75 // In SPv2, visual rects are in the space of their local transform node. |
74 // For SVG, the input rect is in local SVG coordinates in which paint | 76 // For SVG, the input rect is in local SVG coordinates in which paint |
75 // offset doesn't apply. | 77 // offset doesn't apply. |
76 if (!object.isSVGChild()) | 78 if (!isSVGChild) |
77 rect.moveBy(FloatPoint(object.paintOffset())); | 79 rect.moveBy(FloatPoint(object.paintOffset())); |
78 // Use enclosingIntRect to ensure the final visual rect will cover the | 80 // Use enclosingIntRect to ensure the final visual rect will cover the |
79 // rect in source coordinates no matter if the painting will use pixel | 81 // rect in source coordinates no matter if the painting will use pixel |
80 // snapping. | 82 // snapping. |
81 return LayoutRect(enclosingIntRect(rect)); | 83 return LayoutRect(enclosingIntRect(rect)); |
82 } | 84 } |
83 | 85 |
84 LayoutRect result; | 86 LayoutRect result; |
85 if (context.forcedSubtreeInvalidationFlags & | 87 if (context.forcedSubtreeInvalidationFlags & |
86 PaintInvalidatorContext::ForcedSubtreeSlowPathRect) { | 88 PaintInvalidatorContext::ForcedSubtreeSlowPathRect) { |
87 result = slowMapToVisualRectInAncestorSpace( | 89 result = slowMapToVisualRectInAncestorSpace( |
88 object, *context.paintInvalidationContainer, rect); | 90 object, *context.paintInvalidationContainer, rect); |
89 } else if (object == context.paintInvalidationContainer) { | 91 } else if (object == context.paintInvalidationContainer) { |
90 result = LayoutRect(rect); | 92 result = LayoutRect(rect); |
91 } else { | 93 } else { |
92 // For non-root SVG, the input rect is in local SVG coordinates in which | 94 // For non-root SVG, the input rect is in local SVG coordinates in which |
93 // paint offset doesn't apply. | 95 // paint offset doesn't apply. |
94 if (!object.isSVGChild()) { | 96 if (!isSVGChild) { |
95 rect.moveBy(FloatPoint(object.paintOffset())); | 97 rect.moveBy(FloatPoint(object.paintOffset())); |
96 // Use enclosingIntRect to ensure the final visual rect will cover the | 98 // Use enclosingIntRect to ensure the final visual rect will cover the |
97 // rect in source coordinates no matter if the painting will use pixel | 99 // rect in source coordinates no matter if the painting will use pixel |
98 // snapping. | 100 // snapping. |
99 rect = enclosingIntRect(rect); | 101 rect = enclosingIntRect(rect); |
100 } | 102 } |
101 | 103 |
102 PropertyTreeState currentTreeState( | 104 const auto* containerContentsProperties = |
103 context.treeBuilderContext.current.transform, | 105 context.paintInvalidationContainer->paintProperties() |
104 context.treeBuilderContext.current.clip, | 106 ->contentsProperties(); |
105 context.treeBuilderContext.currentEffect, | 107 if (context.treeBuilderContext.current.transform == |
106 context.treeBuilderContext.current.scroll); | 108 containerContentsProperties->transform() && |
107 const auto* containerPaintProperties = | 109 context.treeBuilderContext.current.clip == |
108 context.paintInvalidationContainer->paintProperties(); | 110 containerContentsProperties->clip()) { |
109 auto containerContentsProperties = | 111 result = LayoutRect(rect); |
110 containerPaintProperties->contentsProperties(); | 112 } else { |
111 | 113 PropertyTreeState currentTreeState( |
112 bool success = false; | 114 context.treeBuilderContext.current.transform, |
113 result = LayoutRect(geometryMapper.sourceToDestinationVisualRect( | 115 context.treeBuilderContext.current.clip, nullptr, nullptr); |
114 rect, currentTreeState, containerContentsProperties, success)); | 116 bool success = false; |
115 DCHECK(success); | 117 result = LayoutRect(geometryMapper.sourceToDestinationVisualRect( |
| 118 rect, currentTreeState, *containerContentsProperties, success)); |
| 119 DCHECK(success); |
| 120 } |
116 | 121 |
117 // Convert the result to the container's contents space. | 122 // Convert the result to the container's contents space. |
118 result.moveBy(-context.paintInvalidationContainer->paintOffset()); | 123 result.moveBy(-context.paintInvalidationContainer->paintOffset()); |
119 } | 124 } |
120 | 125 |
121 object.adjustVisualRectForRasterEffects(result); | 126 object.adjustVisualRectForRasterEffects(result); |
122 | 127 |
123 PaintLayer::mapRectInPaintInvalidationContainerToBacking( | 128 PaintLayer::mapRectInPaintInvalidationContainerToBacking( |
124 *context.paintInvalidationContainer, result); | 129 *context.paintInvalidationContainer, result); |
125 | 130 |
(...skipping 29 matching lines...) Expand all Loading... |
155 } | 160 } |
156 | 161 |
157 LayoutPoint PaintInvalidator::computeLocationInBacking( | 162 LayoutPoint PaintInvalidator::computeLocationInBacking( |
158 const LayoutObject& object, | 163 const LayoutObject& object, |
159 const PaintInvalidatorContext& context) { | 164 const PaintInvalidatorContext& context) { |
160 // Use visual rect location for LayoutTexts because it suffices to check | 165 // Use visual rect location for LayoutTexts because it suffices to check |
161 // visual rect change for layout caused invalidation. | 166 // visual rect change for layout caused invalidation. |
162 if (object.isText()) | 167 if (object.isText()) |
163 return context.newVisualRect.location(); | 168 return context.newVisualRect.location(); |
164 | 169 |
165 FloatPoint point; | 170 LayoutPoint point; |
166 if (object != context.paintInvalidationContainer) { | 171 if (object != context.paintInvalidationContainer) { |
167 point.moveBy(FloatPoint(object.paintOffset())); | 172 point.moveBy(object.paintOffset()); |
168 | 173 |
169 const auto* containerPaintProperties = | 174 const auto* containerTransform = |
170 context.paintInvalidationContainer->paintProperties(); | 175 context.paintInvalidationContainer->paintProperties() |
171 auto containerContentsProperties = | 176 ->contentsProperties() |
172 containerPaintProperties->contentsProperties(); | 177 ->transform(); |
173 | 178 if (context.treeBuilderContext.current.transform != containerTransform) { |
174 bool success = false; | 179 bool success = false; |
175 point = m_geometryMapper | 180 point = LayoutPoint(m_geometryMapper |
176 .sourceToDestinationRect( | 181 .sourceToDestinationRect( |
177 FloatRect(point, FloatSize()), | 182 FloatRect(FloatPoint(point), FloatSize()), |
178 context.treeBuilderContext.current.transform, | 183 context.treeBuilderContext.current.transform, |
179 containerContentsProperties.transform(), success) | 184 containerTransform, success) |
180 .location(); | 185 .location()); |
181 DCHECK(success); | 186 DCHECK(success); |
| 187 } |
182 | 188 |
183 // Convert the result to the container's contents space. | 189 // Convert the result to the container's contents space. |
184 point.moveBy(-context.paintInvalidationContainer->paintOffset()); | 190 point.moveBy(-context.paintInvalidationContainer->paintOffset()); |
185 } | 191 } |
186 | 192 |
187 PaintLayer::mapPointInPaintInvalidationContainerToBacking( | 193 if (context.paintInvalidationContainer->layer()->groupedMapping()) { |
188 *context.paintInvalidationContainer, point); | 194 FloatPoint floatPoint(point); |
| 195 PaintLayer::mapPointInPaintInvalidationContainerToBacking( |
| 196 *context.paintInvalidationContainer, floatPoint); |
| 197 point = LayoutPoint(floatPoint); |
| 198 } |
189 | 199 |
190 return LayoutPoint(point); | 200 return point; |
191 } | 201 } |
192 | 202 |
193 void PaintInvalidator::updatePaintingLayer(const LayoutObject& object, | 203 void PaintInvalidator::updatePaintingLayer(const LayoutObject& object, |
194 PaintInvalidatorContext& context) { | 204 PaintInvalidatorContext& context) { |
195 if (object.hasLayer() && | 205 if (object.hasLayer() && |
196 toLayoutBoxModelObject(object).hasSelfPaintingLayer()) { | 206 toLayoutBoxModelObject(object).hasSelfPaintingLayer()) { |
197 context.paintingLayer = toLayoutBoxModelObject(object).layer(); | 207 context.paintingLayer = toLayoutBoxModelObject(object).layer(); |
198 } else if (object.isColumnSpanAll() || | 208 } else if (object.isColumnSpanAll() || |
199 (object.isFloating() && !object.parent()->isLayoutBlock())) { | 209 (object.isFloating() && !object.parent()->isLayoutBlock())) { |
200 // See LayoutObject::paintingLayer() for the special-cases of floating under | 210 // See LayoutObject::paintingLayer() for the special-cases of floating under |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; | 456 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; |
447 } | 457 } |
448 | 458 |
449 void PaintInvalidator::processPendingDelayedPaintInvalidations() { | 459 void PaintInvalidator::processPendingDelayedPaintInvalidations() { |
450 for (auto target : m_pendingDelayedPaintInvalidations) | 460 for (auto target : m_pendingDelayedPaintInvalidations) |
451 target->getMutableForPainting().setShouldDoFullPaintInvalidation( | 461 target->getMutableForPainting().setShouldDoFullPaintInvalidation( |
452 PaintInvalidationDelayedFull); | 462 PaintInvalidationDelayedFull); |
453 } | 463 } |
454 | 464 |
455 } // namespace blink | 465 } // namespace blink |
OLD | NEW |