| 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 if (shouldPaintContent) { | 486 if (shouldPaintContent) { |
| 487 // TODO(wangxianzhu): This is for old slow scrolling. Implement similar | 487 // TODO(wangxianzhu): This is for old slow scrolling. Implement similar |
| 488 // optimization for slimming paint v2. | 488 // optimization for slimming paint v2. |
| 489 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect( | 489 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect( |
| 490 layerFragments, localPaintingInfo, paintFlags, offsetFromRoot); | 490 layerFragments, localPaintingInfo, paintFlags, offsetFromRoot); |
| 491 if (!shouldPaintContent) | 491 if (!shouldPaintContent) |
| 492 result = MayBeClippedByPaintDirtyRect; | 492 result = MayBeClippedByPaintDirtyRect; |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 | 495 |
| 496 Optional<ScopedPaintChunkProperties> contentScopedPaintChunkProperties; |
| 497 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 498 !scopedPaintChunkProperties.has_value()) { |
| 499 // If layoutObject() is a LayoutView and root layer scrolling is enabled, |
| 500 // the LayoutView's paint properties will already have been applied at |
| 501 // the top of this method, in scopedPaintChunkProperties. |
| 502 DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 503 m_paintLayer.layoutObject() && |
| 504 m_paintLayer.layoutObject()->isLayoutView())); |
| 505 const auto* objectPaintProperties = |
| 506 m_paintLayer.layoutObject()->paintProperties(); |
| 507 DCHECK(objectPaintProperties && |
| 508 objectPaintProperties->localBorderBoxProperties()); |
| 509 PaintChunkProperties properties( |
| 510 context.getPaintController().currentPaintChunkProperties()); |
| 511 properties.propertyTreeState = |
| 512 *objectPaintProperties->localBorderBoxProperties(); |
| 513 properties.backfaceHidden = |
| 514 m_paintLayer.layoutObject()->hasHiddenBackface(); |
| 515 contentScopedPaintChunkProperties.emplace(context.getPaintController(), |
| 516 m_paintLayer, properties); |
| 517 } |
| 518 |
| 496 bool selectionOnly = | 519 bool selectionOnly = |
| 497 localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSelectionOnly; | 520 localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSelectionOnly; |
| 498 | |
| 499 { // Begin block for the lifetime of any filter. | 521 { // Begin block for the lifetime of any filter. |
| 500 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, | 522 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, |
| 501 layerFragments.isEmpty() | 523 layerFragments.isEmpty() |
| 502 ? ClipRect() | 524 ? ClipRect() |
| 503 : layerFragments[0].backgroundRect, | 525 : layerFragments[0].backgroundRect, |
| 504 localPaintingInfo, paintFlags); | 526 localPaintingInfo, paintFlags); |
| 505 | 527 |
| 506 Optional<ScopedPaintChunkProperties> contentScopedPaintChunkProperties; | |
| 507 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | |
| 508 !scopedPaintChunkProperties.has_value()) { | |
| 509 // If layoutObject() is a LayoutView and root layer scrolling is enabled, | |
| 510 // the LayoutView's paint properties will already have been applied at | |
| 511 // the top of this method, in scopedPaintChunkProperties. | |
| 512 DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | |
| 513 m_paintLayer.layoutObject() && | |
| 514 m_paintLayer.layoutObject()->isLayoutView())); | |
| 515 const auto* objectPaintProperties = | |
| 516 m_paintLayer.layoutObject()->paintProperties(); | |
| 517 DCHECK(objectPaintProperties && | |
| 518 objectPaintProperties->localBorderBoxProperties()); | |
| 519 PaintChunkProperties properties( | |
| 520 context.getPaintController().currentPaintChunkProperties()); | |
| 521 properties.propertyTreeState = | |
| 522 *objectPaintProperties->localBorderBoxProperties(); | |
| 523 properties.backfaceHidden = | |
| 524 m_paintLayer.layoutObject()->hasHiddenBackface(); | |
| 525 contentScopedPaintChunkProperties.emplace(context.getPaintController(), | |
| 526 m_paintLayer, properties); | |
| 527 } | |
| 528 | |
| 529 bool isPaintingRootLayer = (&m_paintLayer) == paintingInfo.rootLayer; | 528 bool isPaintingRootLayer = (&m_paintLayer) == paintingInfo.rootLayer; |
| 530 bool shouldPaintBackground = | 529 bool shouldPaintBackground = |
| 531 shouldPaintContent && !selectionOnly && | 530 shouldPaintContent && !selectionOnly && |
| 532 (isPaintingCompositedBackground || | 531 (isPaintingCompositedBackground || |
| 533 (isPaintingRootLayer && | 532 (isPaintingRootLayer && |
| 534 !(paintFlags & PaintLayerPaintingSkipRootBackground))); | 533 !(paintFlags & PaintLayerPaintingSkipRootBackground))); |
| 535 bool shouldPaintNegZOrderList = | 534 bool shouldPaintNegZOrderList = |
| 536 (isPaintingScrollingContent && isPaintingOverflowContents) || | 535 (isPaintingScrollingContent && isPaintingOverflowContents) || |
| 537 (!isPaintingScrollingContent && isPaintingCompositedBackground); | 536 (!isPaintingScrollingContent && isPaintingCompositedBackground); |
| 538 bool shouldPaintOwnContents = | 537 bool shouldPaintOwnContents = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 576 |
| 578 bool shouldPaintMask = | 577 bool shouldPaintMask = |
| 579 (paintFlags & PaintLayerPaintingCompositingMaskPhase) && | 578 (paintFlags & PaintLayerPaintingCompositingMaskPhase) && |
| 580 shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && | 579 shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && |
| 581 !selectionOnly; | 580 !selectionOnly; |
| 582 bool shouldPaintClippingMask = | 581 bool shouldPaintClippingMask = |
| 583 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | | 582 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
| 584 PaintLayerPaintingAncestorClippingMaskPhase)) && | 583 PaintLayerPaintingAncestorClippingMaskPhase)) && |
| 585 shouldPaintContent && !selectionOnly; | 584 shouldPaintContent && !selectionOnly; |
| 586 | 585 |
| 587 if (shouldPaintMask) | 586 if (shouldPaintMask) { |
| 588 paintMaskForFragments(layerFragments, context, localPaintingInfo, | 587 paintMaskForFragments(layerFragments, context, localPaintingInfo, |
| 589 paintFlags); | 588 paintFlags); |
| 589 } |
| 590 |
| 590 if (shouldPaintClippingMask) { | 591 if (shouldPaintClippingMask) { |
| 591 // Paint the border radius mask for the fragments. | 592 // Paint the border radius mask for the fragments. |
| 592 paintChildClippingMaskForFragments(layerFragments, context, | 593 paintChildClippingMaskForFragments(layerFragments, context, |
| 593 localPaintingInfo, paintFlags); | 594 localPaintingInfo, paintFlags); |
| 594 } | 595 } |
| 595 | 596 |
| 596 if (subsequenceRecorder) | 597 if (subsequenceRecorder) |
| 597 m_paintLayer.setPreviousPaintResult(result); | 598 m_paintLayer.setPreviousPaintResult(result); |
| 598 return result; | 599 return result; |
| 599 } | 600 } |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 | 1151 |
| 1151 void PaintLayerPainter::paintMaskForFragments( | 1152 void PaintLayerPainter::paintMaskForFragments( |
| 1152 const PaintLayerFragments& layerFragments, | 1153 const PaintLayerFragments& layerFragments, |
| 1153 GraphicsContext& context, | 1154 GraphicsContext& context, |
| 1154 const PaintLayerPaintingInfo& localPaintingInfo, | 1155 const PaintLayerPaintingInfo& localPaintingInfo, |
| 1155 PaintLayerFlags paintFlags) { | 1156 PaintLayerFlags paintFlags) { |
| 1156 Optional<DisplayItemCacheSkipper> cacheSkipper; | 1157 Optional<DisplayItemCacheSkipper> cacheSkipper; |
| 1157 if (layerFragments.size() > 1) | 1158 if (layerFragments.size() > 1) |
| 1158 cacheSkipper.emplace(context); | 1159 cacheSkipper.emplace(context); |
| 1159 | 1160 |
| 1161 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; |
| 1162 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1163 const auto* objectPaintProperties = |
| 1164 m_paintLayer.layoutObject()->paintProperties(); |
| 1165 DCHECK(objectPaintProperties && objectPaintProperties->mask()); |
| 1166 PaintChunkProperties properties( |
| 1167 context.getPaintController().currentPaintChunkProperties()); |
| 1168 properties.propertyTreeState.setEffect(objectPaintProperties->mask()); |
| 1169 scopedPaintChunkProperties.emplace(context.getPaintController(), |
| 1170 m_paintLayer, properties); |
| 1171 } |
| 1172 |
| 1160 for (auto& fragment : layerFragments) | 1173 for (auto& fragment : layerFragments) |
| 1161 paintFragmentWithPhase(PaintPhaseMask, fragment, context, | 1174 paintFragmentWithPhase(PaintPhaseMask, fragment, context, |
| 1162 fragment.backgroundRect, localPaintingInfo, | 1175 fragment.backgroundRect, localPaintingInfo, |
| 1163 paintFlags, HasNotClipped); | 1176 paintFlags, HasNotClipped); |
| 1164 } | 1177 } |
| 1165 | 1178 |
| 1166 void PaintLayerPainter::paintChildClippingMaskForFragments( | 1179 void PaintLayerPainter::paintChildClippingMaskForFragments( |
| 1167 const PaintLayerFragments& layerFragments, | 1180 const PaintLayerFragments& layerFragments, |
| 1168 GraphicsContext& context, | 1181 GraphicsContext& context, |
| 1169 const PaintLayerPaintingInfo& localPaintingInfo, | 1182 const PaintLayerPaintingInfo& localPaintingInfo, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1200 context, layoutObject, PaintPhaseClippingMask)) | 1213 context, layoutObject, PaintPhaseClippingMask)) |
| 1201 return; | 1214 return; |
| 1202 | 1215 |
| 1203 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); | 1216 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
| 1204 LayoutObjectDrawingRecorder drawingRecorder( | 1217 LayoutObjectDrawingRecorder drawingRecorder( |
| 1205 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); | 1218 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); |
| 1206 context.fillRect(snappedClipRect, Color::black); | 1219 context.fillRect(snappedClipRect, Color::black); |
| 1207 } | 1220 } |
| 1208 | 1221 |
| 1209 } // namespace blink | 1222 } // namespace blink |
| OLD | NEW |