Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintInvalidator.cpp

Issue 2457023002: Replace coversExtraPixels with simpler logic (Closed)
Patch Set: - Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 toLayoutView(object).mapToVisualRectInAncestorSpace( 36 toLayoutView(object).mapToVisualRectInAncestorSpace(
37 &ancestor, result, InputIsInFrameCoordinates, DefaultVisualRectFlags); 37 &ancestor, result, InputIsInFrameCoordinates, DefaultVisualRectFlags);
38 else 38 else
39 object.mapToVisualRectInAncestorSpace(&ancestor, result); 39 object.mapToVisualRectInAncestorSpace(&ancestor, result);
40 return result; 40 return result;
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 PaintInvalidationRectInBacking 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 // TODO(wkorman): The flip below is required because visual rects are 51 // TODO(wkorman): The flip below is required because visual rects are
52 // currently in "physical coordinates with flipped block-flow direction" 52 // currently in "physical coordinates with flipped block-flow direction"
53 // (see LayoutBoxModelObject.h) but we need them to be in physical 53 // (see LayoutBoxModelObject.h) but we need them to be in physical
54 // coordinates. 54 // coordinates.
55 FloatRect rect = localRect; 55 FloatRect rect = localRect;
56 // Writing-mode flipping doesn't apply to non-root SVG. 56 // Writing-mode flipping doesn't apply to non-root SVG.
57 if (!object.isSVG() || object.isSVGRoot()) { 57 if (!object.isSVG() || object.isSVGRoot()) {
58 if (object.isBox()) { 58 if (object.isBox()) {
59 toLayoutBox(object).flipForWritingMode(rect); 59 toLayoutBox(object).flipForWritingMode(rect);
60 } else if (!(context.forcedSubtreeInvalidationFlags & 60 } else if (!(context.forcedSubtreeInvalidationFlags &
61 PaintInvalidatorContext::ForcedSubtreeSlowPathRect)) { 61 PaintInvalidatorContext::ForcedSubtreeSlowPathRect)) {
62 // For SPv2 and the GeometryMapper path, we also need to convert the rect 62 // For SPv2 and the GeometryMapper path, we also need to convert the rect
63 // for non-boxes into physical coordinates before applying paint offset. 63 // for non-boxes into physical coordinates before applying paint offset.
64 // (Otherwise we'll call mapToVisualrectInAncestorSpace() which requires 64 // (Otherwise we'll call mapToVisualrectInAncestorSpace() which requires
65 // physical coordinates for boxes, but "physical coordinates with flipped 65 // physical coordinates for boxes, but "physical coordinates with flipped
66 // block-flow direction" for non-boxes for which we don't need to flip.) 66 // block-flow direction" for non-boxes for which we don't need to flip.)
67 // TODO(wangxianzhu): Avoid containingBlock(). 67 // TODO(wangxianzhu): Avoid containingBlock().
68 object.containingBlock()->flipForWritingMode(rect); 68 object.containingBlock()->flipForWritingMode(rect);
69 } 69 }
70 } 70 }
71 71
72 PaintInvalidationRectInBacking result;
73 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 72 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
74 // In SPv2, visual rects are in the space of their local transform node. 73 // In SPv2, visual rects are in the space of their local transform node.
75 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); 74 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
76 // Use enclosingIntRect to ensure the final visual rect will cover the 75 // Use enclosingIntRect to ensure the final visual rect will cover the
77 // rect in source coordinates no matter if the painting will use pixel 76 // rect in source coordinates no matter if the painting will use pixel
78 // snapping. 77 // snapping.
79 result.rect = LayoutRect(enclosingIntRect(rect)); 78 return LayoutRect(enclosingIntRect(rect));
80 if (FloatRect(result.rect) != rect)
81 result.coversExtraPixels = true;
82 return result;
83 } 79 }
84 80
81 LayoutRect result;
85 if (context.forcedSubtreeInvalidationFlags & 82 if (context.forcedSubtreeInvalidationFlags &
86 PaintInvalidatorContext::ForcedSubtreeSlowPathRect) { 83 PaintInvalidatorContext::ForcedSubtreeSlowPathRect) {
87 result.rect = slowMapToVisualRectInAncestorSpace( 84 result = slowMapToVisualRectInAncestorSpace(
88 object, *context.paintInvalidationContainer, rect); 85 object, *context.paintInvalidationContainer, rect);
89 } else if (object == context.paintInvalidationContainer) { 86 } else if (object == context.paintInvalidationContainer) {
90 result.rect = LayoutRect(rect); 87 result = LayoutRect(rect);
91 } else { 88 } else {
92 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset)); 89 rect.moveBy(FloatPoint(context.treeBuilderContext.current.paintOffset));
93 if ((!object.isSVG() || object.isSVGRoot()) && !rect.isEmpty()) { 90 if ((!object.isSVG() || object.isSVGRoot()) && !rect.isEmpty()) {
94 // Use enclosingIntRect to ensure the final visual rect will cover the 91 // Use enclosingIntRect to ensure the final visual rect will cover the
95 // rect in source coordinates no matter if the painting will use pixel 92 // rect in source coordinates no matter if the painting will use pixel
96 // snapping. 93 // snapping.
97 IntRect intRect = enclosingIntRect(rect); 94 rect = enclosingIntRect(rect);
98 if (FloatRect(intRect) != rect) {
99 result.coversExtraPixels = true;
100 rect = intRect;
101 }
102 } 95 }
103 96
104 PropertyTreeState currentTreeState( 97 PropertyTreeState currentTreeState(
105 context.treeBuilderContext.current.transform, 98 context.treeBuilderContext.current.transform,
106 context.treeBuilderContext.current.clip, 99 context.treeBuilderContext.current.clip,
107 context.treeBuilderContext.currentEffect, 100 context.treeBuilderContext.currentEffect,
108 context.treeBuilderContext.current.scroll); 101 context.treeBuilderContext.current.scroll);
109 const auto* containerPaintProperties = 102 const auto* containerPaintProperties =
110 context.paintInvalidationContainer->paintProperties(); 103 context.paintInvalidationContainer->paintProperties();
111 auto containerContentsProperties = 104 auto containerContentsProperties =
112 containerPaintProperties->contentsProperties(); 105 containerPaintProperties->contentsProperties();
113 106
114 // TODO(wangxianzhu): Set coversExtraPixels if there are any non-translate
115 // transforms. Currently this case is handled in BoxPaintInvalidator by
116 // checking transforms.
117 bool success = false; 107 bool success = false;
118 result.rect = LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( 108 result = LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace(
119 rect, currentTreeState, containerContentsProperties.propertyTreeState, 109 rect, currentTreeState, containerContentsProperties.propertyTreeState,
120 success)); 110 success));
121 DCHECK(success); 111 DCHECK(success);
122 112
123 // Convert the result to the container's contents space. 113 // Convert the result to the container's contents space.
124 result.rect.moveBy(-containerContentsProperties.paintOffset); 114 result.moveBy(-containerContentsProperties.paintOffset);
125 } 115 }
126 116
127 if (context.paintInvalidationContainer->layer()->groupedMapping()) { 117 if (context.paintInvalidationContainer->layer()->groupedMapping()) {
128 PaintLayer::mapRectInPaintInvalidationContainerToBacking( 118 PaintLayer::mapRectInPaintInvalidationContainerToBacking(
129 *context.paintInvalidationContainer, result.rect); 119 *context.paintInvalidationContainer, result);
130 } 120 }
131 return result; 121 return result;
132 } 122 }
133 123
134 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking( 124 void PaintInvalidatorContext::mapLocalRectToPaintInvalidationBacking(
135 const LayoutObject& object, 125 const LayoutObject& object,
136 LayoutRect& rect) const { 126 LayoutRect& rect) const {
137 GeometryMapper geometryMapper; 127 GeometryMapper geometryMapper;
138 rect = blink::mapLocalRectToPaintInvalidationBacking(geometryMapper, object, 128 rect = blink::mapLocalRectToPaintInvalidationBacking(geometryMapper, object,
139 FloatRect(rect), *this) 129 FloatRect(rect), *this);
140 .rect;
141 } 130 }
142 131
143 PaintInvalidationRectInBacking 132 LayoutRect PaintInvalidator::mapLocalRectToPaintInvalidationBacking(
144 PaintInvalidator::mapLocalRectToPaintInvalidationBacking(
145 const LayoutObject& object, 133 const LayoutObject& object,
146 const FloatRect& localRect, 134 const FloatRect& localRect,
147 const PaintInvalidatorContext& context) { 135 const PaintInvalidatorContext& context) {
148 return blink::mapLocalRectToPaintInvalidationBacking(m_geometryMapper, object, 136 return blink::mapLocalRectToPaintInvalidationBacking(m_geometryMapper, object,
149 localRect, context); 137 localRect, context);
150 } 138 }
151 139
152 PaintInvalidationRectInBacking 140 LayoutRect PaintInvalidator::computePaintInvalidationRectInBacking(
153 PaintInvalidator::computePaintInvalidationRectInBacking(
154 const LayoutObject& object, 141 const LayoutObject& object,
155 const PaintInvalidatorContext& context) { 142 const PaintInvalidatorContext& context) {
156 FloatRect localRect; 143 FloatRect localRect;
157 if (object.isSVG() && !object.isSVGRoot()) 144 if (object.isSVG() && !object.isSVGRoot())
158 localRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation(object); 145 localRect = SVGLayoutSupport::localOverflowRectForPaintInvalidation(object);
159 else 146 else
160 localRect = FloatRect(object.localOverflowRectForPaintInvalidation()); 147 localRect = FloatRect(object.localOverflowRectForPaintInvalidation());
161 148
162 return mapLocalRectToPaintInvalidationBacking(object, localRect, context); 149 return mapLocalRectToPaintInvalidationBacking(object, localRect, context);
163 } 150 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 context.forcedSubtreeInvalidationFlags |= 313 context.forcedSubtreeInvalidationFlags |=
327 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; 314 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking;
328 315
329 // TODO(crbug.com/637313): This is temporary before we support filters in 316 // TODO(crbug.com/637313): This is temporary before we support filters in
330 // paint property tree. 317 // paint property tree.
331 // TODO(crbug.com/648274): This is a workaround for multi-column contents. 318 // TODO(crbug.com/648274): This is a workaround for multi-column contents.
332 if (object.hasFilterInducingProperty() || object.isLayoutFlowThread()) 319 if (object.hasFilterInducingProperty() || object.isLayoutFlowThread())
333 context.forcedSubtreeInvalidationFlags |= 320 context.forcedSubtreeInvalidationFlags |=
334 PaintInvalidatorContext::ForcedSubtreeSlowPathRect; 321 PaintInvalidatorContext::ForcedSubtreeSlowPathRect;
335 322
336 context.oldBounds.rect = object.previousPaintInvalidationRect(); 323 context.oldBounds = object.previousPaintInvalidationRect();
337 context.oldBounds.coversExtraPixels =
338 object.previousPaintInvalidationRectCoversExtraPixels();
339 context.oldLocation = object.previousPositionFromPaintInvalidationBacking(); 324 context.oldLocation = object.previousPositionFromPaintInvalidationBacking();
340 context.newBounds = computePaintInvalidationRectInBacking(object, context); 325 context.newBounds = computePaintInvalidationRectInBacking(object, context);
341 context.newLocation = 326 context.newLocation =
342 computeLocationFromPaintInvalidationBacking(object, context); 327 computeLocationFromPaintInvalidationBacking(object, context);
343 328
344 IntSize adjustment = object.scrollAdjustmentForPaintInvalidation( 329 IntSize adjustment = object.scrollAdjustmentForPaintInvalidation(
345 *context.paintInvalidationContainer); 330 *context.paintInvalidationContainer);
346 context.newLocation.move(adjustment); 331 context.newLocation.move(adjustment);
347 context.newBounds.rect.move(adjustment); 332 context.newBounds.move(adjustment);
348 333
349 object.getMutableForPainting().setPreviousPaintInvalidationRect( 334 object.getMutableForPainting().setPreviousPaintInvalidationRect(
350 context.newBounds.rect, context.newBounds.coversExtraPixels); 335 context.newBounds);
351 object.getMutableForPainting() 336 object.getMutableForPainting()
352 .setPreviousPositionFromPaintInvalidationBacking(context.newLocation); 337 .setPreviousPositionFromPaintInvalidationBacking(context.newLocation);
353 } 338 }
354 339
355 void PaintInvalidator::invalidatePaintIfNeeded( 340 void PaintInvalidator::invalidatePaintIfNeeded(
356 FrameView& frameView, 341 FrameView& frameView,
357 PaintInvalidatorContext& context) { 342 PaintInvalidatorContext& context) {
358 LayoutView* layoutView = frameView.layoutView(); 343 LayoutView* layoutView = frameView.layoutView();
359 CHECK(layoutView); 344 CHECK(layoutView);
360 345
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we 432 // TODO(crbug.com/533277): This is a workaround for the bug. Remove when we
448 // detect paint offset change. 433 // detect paint offset change.
449 if (reason != PaintInvalidationNone && 434 if (reason != PaintInvalidationNone &&
450 hasPercentageTransform(object.styleRef())) 435 hasPercentageTransform(object.styleRef()))
451 context.forcedSubtreeInvalidationFlags |= 436 context.forcedSubtreeInvalidationFlags |=
452 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; 437 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking;
453 438
454 // TODO(crbug.com/490725): This is a workaround for the bug, to force 439 // TODO(crbug.com/490725): This is a workaround for the bug, to force
455 // descendant to update paint invalidation rects on clipping change. 440 // descendant to update paint invalidation rects on clipping change.
456 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 441 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
457 context.oldBounds.rect != context.newBounds.rect 442 context.oldBounds != context.newBounds
458 // Note that isLayoutView() below becomes unnecessary after the launch of 443 // Note that isLayoutView() below becomes unnecessary after the launch of
459 // root layer scrolling. 444 // root layer scrolling.
460 && (object.hasOverflowClip() || object.isLayoutView()) && 445 && (object.hasOverflowClip() || object.isLayoutView()) &&
461 !toLayoutBox(object).usesCompositedScrolling()) 446 !toLayoutBox(object).usesCompositedScrolling())
462 context.forcedSubtreeInvalidationFlags |= 447 context.forcedSubtreeInvalidationFlags |=
463 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; 448 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate;
464 449
465 object.getMutableForPainting().clearPaintInvalidationFlags(); 450 object.getMutableForPainting().clearPaintInvalidationFlags();
466 } 451 }
467 452
468 void PaintInvalidator::processPendingDelayedPaintInvalidations() { 453 void PaintInvalidator::processPendingDelayedPaintInvalidations() {
469 for (auto target : m_pendingDelayedPaintInvalidations) 454 for (auto target : m_pendingDelayedPaintInvalidations)
470 target->getMutableForPainting().setShouldDoFullPaintInvalidation( 455 target->getMutableForPainting().setShouldDoFullPaintInvalidation(
471 PaintInvalidationDelayedFull); 456 PaintInvalidationDelayedFull);
472 } 457 }
473 458
474 } // namespace blink 459 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698