| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 static ShouldRespectOverflowClipType shouldRespectOverflowClip( | 56 static ShouldRespectOverflowClipType shouldRespectOverflowClip( |
| 57 PaintLayerFlags paintFlags, | 57 PaintLayerFlags paintFlags, |
| 58 const LayoutObject* layoutObject) { | 58 const LayoutObject* layoutObject) { |
| 59 return (paintFlags & PaintLayerPaintingOverflowContents || | 59 return (paintFlags & PaintLayerPaintingOverflowContents || |
| 60 (paintFlags & PaintLayerPaintingChildClippingMaskPhase && | 60 (paintFlags & PaintLayerPaintingChildClippingMaskPhase && |
| 61 layoutObject->hasClipPath())) | 61 layoutObject->hasClipPath())) |
| 62 ? IgnoreOverflowClip | 62 ? IgnoreOverflowClip |
| 63 : RespectOverflowClip; | 63 : RespectOverflowClip; |
| 64 } | 64 } |
| 65 | 65 |
| 66 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer( | 66 PaintResult PaintLayerPainter::paintLayer( |
| 67 GraphicsContext& context, | 67 GraphicsContext& context, |
| 68 const PaintLayerPaintingInfo& paintingInfo, | 68 const PaintLayerPaintingInfo& paintingInfo, |
| 69 PaintLayerFlags paintFlags) { | 69 PaintLayerFlags paintFlags) { |
| 70 // https://code.google.com/p/chromium/issues/detail?id=343772 | 70 // https://code.google.com/p/chromium/issues/detail?id=343772 |
| 71 DisableCompositingQueryAsserts disabler; | 71 DisableCompositingQueryAsserts disabler; |
| 72 | 72 |
| 73 if (m_paintLayer.compositingState() != NotComposited) { | 73 if (m_paintLayer.compositingState() != NotComposited) { |
| 74 if (paintingInfo.getGlobalPaintFlags() & | 74 if (paintingInfo.getGlobalPaintFlags() & |
| 75 GlobalPaintFlattenCompositingLayers) { | 75 GlobalPaintFlattenCompositingLayers) { |
| 76 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? That's | 76 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? That's |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 paintFlags |= PaintLayerHaveTransparency; | 103 paintFlags |= PaintLayerHaveTransparency; |
| 104 | 104 |
| 105 if (m_paintLayer.paintsWithTransform(paintingInfo.getGlobalPaintFlags()) && | 105 if (m_paintLayer.paintsWithTransform(paintingInfo.getGlobalPaintFlags()) && |
| 106 !(paintFlags & PaintLayerAppliedTransform)) | 106 !(paintFlags & PaintLayerAppliedTransform)) |
| 107 return paintLayerWithTransform(context, paintingInfo, paintFlags); | 107 return paintLayerWithTransform(context, paintingInfo, paintFlags); |
| 108 | 108 |
| 109 return paintLayerContentsCompositingAllPhases(context, paintingInfo, | 109 return paintLayerContentsCompositingAllPhases(context, paintingInfo, |
| 110 paintFlags); | 110 paintFlags); |
| 111 } | 111 } |
| 112 | 112 |
| 113 PaintLayerPainter::PaintResult | 113 PaintResult PaintLayerPainter::paintLayerContentsCompositingAllPhases( |
| 114 PaintLayerPainter::paintLayerContentsCompositingAllPhases( | |
| 115 GraphicsContext& context, | 114 GraphicsContext& context, |
| 116 const PaintLayerPaintingInfo& paintingInfo, | 115 const PaintLayerPaintingInfo& paintingInfo, |
| 117 PaintLayerFlags paintFlags, | 116 PaintLayerFlags paintFlags, |
| 118 FragmentPolicy fragmentPolicy) { | 117 FragmentPolicy fragmentPolicy) { |
| 119 DCHECK(m_paintLayer.isSelfPaintingLayer() || | 118 DCHECK(m_paintLayer.isSelfPaintingLayer() || |
| 120 m_paintLayer.hasSelfPaintingLayerDescendant()); | 119 m_paintLayer.hasSelfPaintingLayerDescendant()); |
| 121 | 120 |
| 122 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform); | 121 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform); |
| 123 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; | 122 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; |
| 124 return paintLayerContents(context, paintingInfo, localPaintFlags, | 123 return paintLayerContents(context, paintingInfo, localPaintFlags, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (&clipRects != previousClipRects && | 199 if (&clipRects != previousClipRects && |
| 201 (!previousClipRects || clipRects != *previousClipRects)) { | 200 (!previousClipRects || clipRects != *previousClipRects)) { |
| 202 needsRepaint = true; | 201 needsRepaint = true; |
| 203 shouldClearEmptyPaintPhaseFlags = true; | 202 shouldClearEmptyPaintPhaseFlags = true; |
| 204 } | 203 } |
| 205 paintLayer.setPreviousPaintingClipRects(clipRects); | 204 paintLayer.setPreviousPaintingClipRects(clipRects); |
| 206 } | 205 } |
| 207 | 206 |
| 208 // Repaint if previously the layer might be clipped by paintDirtyRect and | 207 // Repaint if previously the layer might be clipped by paintDirtyRect and |
| 209 // paintDirtyRect changes. | 208 // paintDirtyRect changes. |
| 210 if (paintLayer.previousPaintResult() == | 209 if (paintLayer.previousPaintResult() == MayBeClippedByPaintDirtyRect && |
| 211 PaintLayerPainter::MayBeClippedByPaintDirtyRect && | |
| 212 paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRect) { | 210 paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRect) { |
| 213 needsRepaint = true; | 211 needsRepaint = true; |
| 214 shouldClearEmptyPaintPhaseFlags = true; | 212 shouldClearEmptyPaintPhaseFlags = true; |
| 215 } | 213 } |
| 216 paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect); | 214 paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect); |
| 217 | 215 |
| 218 // Repaint if scroll offset accumulation changes. | 216 // Repaint if scroll offset accumulation changes. |
| 219 if (paintingInfo.scrollOffsetAccumulation != | 217 if (paintingInfo.scrollOffsetAccumulation != |
| 220 paintLayer.previousScrollOffsetAccumulationForPainting()) { | 218 paintLayer.previousScrollOffsetAccumulationForPainting()) { |
| 221 needsRepaint = true; | 219 needsRepaint = true; |
| 222 shouldClearEmptyPaintPhaseFlags = true; | 220 shouldClearEmptyPaintPhaseFlags = true; |
| 223 } | 221 } |
| 224 paintLayer.setPreviousScrollOffsetAccumulationForPainting( | 222 paintLayer.setPreviousScrollOffsetAccumulationForPainting( |
| 225 paintingInfo.scrollOffsetAccumulation); | 223 paintingInfo.scrollOffsetAccumulation); |
| 226 | 224 |
| 227 return needsRepaint; | 225 return needsRepaint; |
| 228 } | 226 } |
| 229 | 227 |
| 230 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents( | 228 PaintResult PaintLayerPainter::paintLayerContents( |
| 231 GraphicsContext& context, | 229 GraphicsContext& context, |
| 232 const PaintLayerPaintingInfo& paintingInfoArg, | 230 const PaintLayerPaintingInfo& paintingInfoArg, |
| 233 PaintLayerFlags paintFlags, | 231 PaintLayerFlags paintFlags, |
| 234 FragmentPolicy fragmentPolicy) { | 232 FragmentPolicy fragmentPolicy) { |
| 235 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; | 233 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; |
| 236 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 234 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 237 RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 235 RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 238 m_paintLayer.layoutObject() && | 236 m_paintLayer.layoutObject() && |
| 239 m_paintLayer.layoutObject()->isLayoutView()) { | 237 m_paintLayer.layoutObject()->isLayoutView()) { |
| 240 const auto* objectPaintProperties = | 238 const auto* objectPaintProperties = |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 // fragment.layerBounds is set to the border box, not the bounding box, of | 571 // fragment.layerBounds is set to the border box, not the bounding box, of |
| 574 // the layer. | 572 // the layer. |
| 575 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, | 573 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, |
| 576 fragment.backgroundRect.rect(), | 574 fragment.backgroundRect.rect(), |
| 577 newOffsetFromRoot)) | 575 newOffsetFromRoot)) |
| 578 return true; | 576 return true; |
| 579 } | 577 } |
| 580 return false; | 578 return false; |
| 581 } | 579 } |
| 582 | 580 |
| 583 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform( | 581 PaintResult PaintLayerPainter::paintLayerWithTransform( |
| 584 GraphicsContext& context, | 582 GraphicsContext& context, |
| 585 const PaintLayerPaintingInfo& paintingInfo, | 583 const PaintLayerPaintingInfo& paintingInfo, |
| 586 PaintLayerFlags paintFlags) { | 584 PaintLayerFlags paintFlags) { |
| 587 TransformationMatrix layerTransform = | 585 TransformationMatrix layerTransform = |
| 588 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags()); | 586 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags()); |
| 589 // If the transform can't be inverted, then don't paint anything. | 587 // If the transform can't be inverted, then don't paint anything. |
| 590 if (!layerTransform.isInvertible()) | 588 if (!layerTransform.isInvertible()) |
| 591 return FullyPainted; | 589 return FullyPainted; |
| 592 | 590 |
| 593 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer | 591 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 701 } |
| 704 } | 702 } |
| 705 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, | 703 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, |
| 706 fragment.paginationOffset) == | 704 fragment.paginationOffset) == |
| 707 MayBeClippedByPaintDirtyRect) | 705 MayBeClippedByPaintDirtyRect) |
| 708 result = MayBeClippedByPaintDirtyRect; | 706 result = MayBeClippedByPaintDirtyRect; |
| 709 } | 707 } |
| 710 return result; | 708 return result; |
| 711 } | 709 } |
| 712 | 710 |
| 713 PaintLayerPainter::PaintResult | 711 PaintResult PaintLayerPainter::paintFragmentByApplyingTransform( |
| 714 PaintLayerPainter::paintFragmentByApplyingTransform( | |
| 715 GraphicsContext& context, | 712 GraphicsContext& context, |
| 716 const PaintLayerPaintingInfo& paintingInfo, | 713 const PaintLayerPaintingInfo& paintingInfo, |
| 717 PaintLayerFlags paintFlags, | 714 PaintLayerFlags paintFlags, |
| 718 const LayoutPoint& fragmentTranslation) { | 715 const LayoutPoint& fragmentTranslation) { |
| 719 // This involves subtracting out the position of the layer in our current | 716 // This involves subtracting out the position of the layer in our current |
| 720 // coordinate space, but preserving the accumulated error for sub-pixel | 717 // coordinate space, but preserving the accumulated error for sub-pixel |
| 721 // layout. | 718 // layout. |
| 722 LayoutPoint delta; | 719 LayoutPoint delta; |
| 723 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); | 720 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); |
| 724 delta.moveBy(fragmentTranslation); | 721 delta.moveBy(fragmentTranslation); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 745 paintingInfo.ancestorHasClipPathClipping; | 742 paintingInfo.ancestorHasClipPathClipping; |
| 746 | 743 |
| 747 // Remove skip root background flag when we're painting with a new root. | 744 // Remove skip root background flag when we're painting with a new root. |
| 748 if (&m_paintLayer != paintingInfo.rootLayer) | 745 if (&m_paintLayer != paintingInfo.rootLayer) |
| 749 paintFlags &= ~PaintLayerPaintingSkipRootBackground; | 746 paintFlags &= ~PaintLayerPaintingSkipRootBackground; |
| 750 | 747 |
| 751 return paintLayerContentsCompositingAllPhases( | 748 return paintLayerContentsCompositingAllPhases( |
| 752 context, transformedPaintingInfo, paintFlags, ForceSingleFragment); | 749 context, transformedPaintingInfo, paintFlags, ForceSingleFragment); |
| 753 } | 750 } |
| 754 | 751 |
| 755 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren( | 752 PaintResult PaintLayerPainter::paintChildren( |
| 756 unsigned childrenToVisit, | 753 unsigned childrenToVisit, |
| 757 GraphicsContext& context, | 754 GraphicsContext& context, |
| 758 const PaintLayerPaintingInfo& paintingInfo, | 755 const PaintLayerPaintingInfo& paintingInfo, |
| 759 PaintLayerFlags paintFlags) { | 756 PaintLayerFlags paintFlags) { |
| 760 PaintResult result = FullyPainted; | 757 PaintResult result = FullyPainted; |
| 761 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) | 758 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) |
| 762 return result; | 759 return result; |
| 763 | 760 |
| 764 #if ENABLE(ASSERT) | 761 #if ENABLE(ASSERT) |
| 765 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); | 762 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 | 1098 |
| 1102 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, | 1099 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, |
| 1103 LayoutRect(enclosingIntRect(damageRect)), | 1100 LayoutRect(enclosingIntRect(damageRect)), |
| 1104 paintFlags, LayoutSize()); | 1101 paintFlags, LayoutSize()); |
| 1105 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 1102 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 1106 | 1103 |
| 1107 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 1104 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 1108 } | 1105 } |
| 1109 | 1106 |
| 1110 } // namespace blink | 1107 } // namespace blink |
| OLD | NEW |