| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/PaintLayerPainter.h" | 5 #include "core/paint/PaintLayerPainter.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/paint/ClipPathClipper.h" | 9 #include "core/paint/ClipPathClipper.h" |
| 10 #include "core/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // Repaint subsequence if the layer is marked for needing repaint. | 220 // Repaint subsequence if the layer is marked for needing repaint. |
| 221 // We don't set needsResetEmptyPaintPhase here, but clear the empty paint | 221 // We don't set needsResetEmptyPaintPhase here, but clear the empty paint |
| 222 // phase flags in PaintLayer::setNeedsPaintPhaseXXX(), to ensure that we won't | 222 // phase flags in PaintLayer::setNeedsPaintPhaseXXX(), to ensure that we won't |
| 223 // clear previousPaintPhaseXXXEmpty flags when unrelated things changed which | 223 // clear previousPaintPhaseXXXEmpty flags when unrelated things changed which |
| 224 // won't cause the paint phases to become non-empty. | 224 // won't cause the paint phases to become non-empty. |
| 225 if (paintLayer.needsRepaint()) | 225 if (paintLayer.needsRepaint()) |
| 226 needsRepaint = true; | 226 needsRepaint = true; |
| 227 | 227 |
| 228 // Repaint if layer's clip changes. | 228 // Repaint if layer's clip changes. |
| 229 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { | 229 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { |
| 230 ClipRects& clipRects = paintLayer.clipper().paintingClipRects( | 230 ClipRects& clipRects = paintLayer.clipper(false).paintingClipRects( |
| 231 paintingInfo.rootLayer, respectOverflowClip, subpixelAccumulation); | 231 paintingInfo.rootLayer, respectOverflowClip, subpixelAccumulation); |
| 232 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); | 232 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); |
| 233 if (&clipRects != previousClipRects && | 233 if (&clipRects != previousClipRects && |
| 234 (!previousClipRects || clipRects != *previousClipRects)) { | 234 (!previousClipRects || clipRects != *previousClipRects)) { |
| 235 needsRepaint = true; | 235 needsRepaint = true; |
| 236 shouldClearEmptyPaintPhaseFlags = true; | 236 shouldClearEmptyPaintPhaseFlags = true; |
| 237 } | 237 } |
| 238 paintLayer.setPreviousPaintingClipRects(clipRects); | 238 paintLayer.setPreviousPaintingClipRects(clipRects); |
| 239 } | 239 } |
| 240 | 240 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 | 439 |
| 440 // TODO(trchen): We haven't decided how to handle visual fragmentation with | 440 // TODO(trchen): We haven't decided how to handle visual fragmentation with |
| 441 // SPv2. Related thread | 441 // SPv2. Related thread |
| 442 // https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuW
Ff-mxM | 442 // https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuW
Ff-mxM |
| 443 if (fragmentPolicy == ForceSingleFragment || | 443 if (fragmentPolicy == ForceSingleFragment || |
| 444 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 444 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 445 paintLayerForFragments->appendSingleFragmentIgnoringPagination( | 445 paintLayerForFragments->appendSingleFragmentIgnoringPagination( |
| 446 layerFragments, localPaintingInfo.rootLayer, | 446 layerFragments, localPaintingInfo.rootLayer, |
| 447 localPaintingInfo.paintDirtyRect, cacheSlot, | 447 localPaintingInfo.paintDirtyRect, cacheSlot, |
| 448 RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(), |
| 448 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, | 449 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
| 449 localPaintingInfo.subPixelAccumulation); | 450 localPaintingInfo.subPixelAccumulation); |
| 450 } else if (isFixedPositionObjectInPagedMedia()) { | 451 } else if (isFixedPositionObjectInPagedMedia()) { |
| 451 PaintLayerFragments singleFragment; | 452 PaintLayerFragments singleFragment; |
| 452 paintLayerForFragments->appendSingleFragmentIgnoringPagination( | 453 paintLayerForFragments->appendSingleFragmentIgnoringPagination( |
| 453 singleFragment, localPaintingInfo.rootLayer, | 454 singleFragment, localPaintingInfo.rootLayer, |
| 454 localPaintingInfo.paintDirtyRect, cacheSlot, | 455 localPaintingInfo.paintDirtyRect, cacheSlot, |
| 456 RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(), |
| 455 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, | 457 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
| 456 localPaintingInfo.subPixelAccumulation); | 458 localPaintingInfo.subPixelAccumulation); |
| 457 repeatFixedPositionObjectInPages(singleFragment[0], paintingInfo, | 459 repeatFixedPositionObjectInPages(singleFragment[0], paintingInfo, |
| 458 layerFragments); | 460 layerFragments); |
| 459 } else { | 461 } else { |
| 460 paintLayerForFragments->collectFragments( | 462 paintLayerForFragments->collectFragments( |
| 461 layerFragments, localPaintingInfo.rootLayer, | 463 layerFragments, localPaintingInfo.rootLayer, |
| 462 localPaintingInfo.paintDirtyRect, cacheSlot, | 464 localPaintingInfo.paintDirtyRect, cacheSlot, |
| 465 RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(), |
| 463 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, | 466 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
| 464 localPaintingInfo.subPixelAccumulation); | 467 localPaintingInfo.subPixelAccumulation); |
| 465 } | 468 } |
| 466 | 469 |
| 467 if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { | 470 if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { |
| 468 // Fragment offsets have been computed in the clipping container's | 471 // Fragment offsets have been computed in the clipping container's |
| 469 // layer's coordinate system, but for the rest of painting we need | 472 // layer's coordinate system, but for the rest of painting we need |
| 470 // them in the layer coordinate. So move them and the foreground rect | 473 // them in the layer coordinate. So move them and the foreground rect |
| 471 // that is also in the clipper's space. | 474 // that is also in the clipper's space. |
| 472 LayoutSize negativeOffset(-offsetToClipper.x(), -offsetToClipper.y()); | 475 LayoutSize negativeOffset(-offsetToClipper.x(), -offsetToClipper.y()); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 // to figure out which fragmentainers (e.g. columns) we need to visit. | 715 // to figure out which fragmentainers (e.g. columns) we need to visit. |
| 713 LayoutRect transformedExtent = PaintLayer::transparencyClipBox( | 716 LayoutRect transformedExtent = PaintLayer::transparencyClipBox( |
| 714 &m_paintLayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, | 717 &m_paintLayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, |
| 715 PaintLayer::RootOfTransparencyClipBox, | 718 PaintLayer::RootOfTransparencyClipBox, |
| 716 paintingInfo.subPixelAccumulation, paintingInfo.getGlobalPaintFlags()); | 719 paintingInfo.subPixelAccumulation, paintingInfo.getGlobalPaintFlags()); |
| 717 // FIXME: we don't check if paginationLayer is within | 720 // FIXME: we don't check if paginationLayer is within |
| 718 // paintingInfo.rootLayer | 721 // paintingInfo.rootLayer |
| 719 // here. | 722 // here. |
| 720 paginationLayer->collectFragments( | 723 paginationLayer->collectFragments( |
| 721 layerFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, | 724 layerFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, |
| 722 cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, nullptr, | 725 cacheSlot, RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled(), |
| 726 IgnoreOverlayScrollbarSize, respectOverflowClip, nullptr, |
| 723 paintingInfo.subPixelAccumulation, &transformedExtent); | 727 paintingInfo.subPixelAccumulation, &transformedExtent); |
| 724 } | 728 } |
| 725 | 729 |
| 726 Optional<DisplayItemCacheSkipper> cacheSkipper; | 730 Optional<DisplayItemCacheSkipper> cacheSkipper; |
| 727 if (layerFragments.size() > 1) | 731 if (layerFragments.size() > 1) |
| 728 cacheSkipper.emplace(context); | 732 cacheSkipper.emplace(context); |
| 729 | 733 |
| 730 ClipRect ancestorBackgroundClipRect; | 734 ClipRect ancestorBackgroundClipRect; |
| 731 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 735 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 732 if (parentLayer) { | 736 if (parentLayer) { |
| 733 // Calculate the clip rectangle that the ancestors establish. | 737 // Calculate the clip rectangle that the ancestors establish. |
| 734 ClipRectsContext clipRectsContext( | 738 ClipRectsContext clipRectsContext( |
| 735 paintingInfo.rootLayer, | 739 paintingInfo.rootLayer, |
| 736 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects | 740 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects |
| 737 : PaintingClipRects, | 741 : PaintingClipRects, |
| 738 IgnoreOverlayScrollbarSize); | 742 IgnoreOverlayScrollbarSize); |
| 739 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) == | 743 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) == |
| 740 IgnoreOverflowClip) | 744 IgnoreOverflowClip) |
| 741 clipRectsContext.setIgnoreOverflowClip(); | 745 clipRectsContext.setIgnoreOverflowClip(); |
| 742 ancestorBackgroundClipRect = | 746 ancestorBackgroundClipRect = |
| 743 m_paintLayer.clipper().backgroundClipRect(clipRectsContext); | 747 m_paintLayer |
| 748 .clipper( |
| 749 RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 750 .backgroundClipRect(clipRectsContext); |
| 744 } | 751 } |
| 745 } | 752 } |
| 746 | 753 |
| 747 PaintResult result = FullyPainted; | 754 PaintResult result = FullyPainted; |
| 748 for (const auto& fragment : layerFragments) { | 755 for (const auto& fragment : layerFragments) { |
| 749 Optional<LayerClipRecorder> clipRecorder; | 756 Optional<LayerClipRecorder> clipRecorder; |
| 750 if (parentLayer && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 757 if (parentLayer && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 751 ClipRect clipRectForFragment(ancestorBackgroundClipRect); | 758 ClipRect clipRectForFragment(ancestorBackgroundClipRect); |
| 752 // A fixed-position object is repeated on every page instead of paginated, | 759 // A fixed-position object is repeated on every page instead of paginated, |
| 753 // so we should apply the original ancestor clip rect. | 760 // so we should apply the original ancestor clip rect. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 context, layoutObject, PaintPhaseClippingMask)) | 1193 context, layoutObject, PaintPhaseClippingMask)) |
| 1187 return; | 1194 return; |
| 1188 | 1195 |
| 1189 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); | 1196 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
| 1190 LayoutObjectDrawingRecorder drawingRecorder( | 1197 LayoutObjectDrawingRecorder drawingRecorder( |
| 1191 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); | 1198 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); |
| 1192 context.fillRect(snappedClipRect, Color::black); | 1199 context.fillRect(snappedClipRect, Color::black); |
| 1193 } | 1200 } |
| 1194 | 1201 |
| 1195 } // namespace blink | 1202 } // namespace blink |
| OLD | NEW |