Index: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
index d4f28037c6037c13b25f0c1a00f6e12e7b95be38..285f2ded9a2edf22504834df2f8426c37d5c28fd 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp |
@@ -9,6 +9,7 @@ |
#include "core/paint/ClipPathClipper.h" |
#include "core/paint/FilterPainter.h" |
#include "core/paint/LayerClipRecorder.h" |
+#include "core/paint/LayoutObjectDrawingRecorder.h" |
#include "core/paint/ObjectPaintProperties.h" |
#include "core/paint/PaintInfo.h" |
#include "core/paint/PaintLayer.h" |
@@ -901,6 +902,15 @@ void PaintLayerPainter::paintFragmentWithPhase( |
paintFlags, clippingRule); |
} |
+ // If we are painting a mask for any reason and we have already processed the |
+ // clips, there is no need to go through the remaining painting pipeline. |
+ // We know that the mask just needs the area bounded by the clip rects to be |
+ // filled with black. |
+ if (clipRecorder && phase == PaintPhaseClippingMask) { |
+ fillMaskingFragment(context, *clipRecorder); |
+ return; |
+ } |
+ |
LayoutRect newCullRect(clipRect.rect()); |
Optional<ScrollRecorder> scrollRecorder; |
LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation(); |
@@ -1116,4 +1126,25 @@ void PaintLayerPainter::paintOverlayScrollbars( |
m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
} |
+void PaintLayerPainter::fillMaskingFragment( |
+ GraphicsContext& context, |
+ const LayerClipRecorder& clipRecorder) { |
+ DCHECK(m_paintLayer.compositingState() == PaintsIntoOwnBacking); |
+ DCHECK(m_paintLayer.layoutObject()->isBox()); |
+ |
+ const LayoutBox* layoutBox = toLayoutBox(m_paintLayer.layoutObject()); |
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
+ context, *layoutBox, PaintPhaseClippingMask)) |
+ return; |
+ |
+ IntRect clipBoundingRect = clipRecorder.snappedClipRect(); |
+ for (auto& roundedRect : clipRecorder.roundedRects()) { |
+ IntRect snappedRect = enclosingIntRect(roundedRect.rect()); |
+ clipBoundingRect.unite(snappedRect); |
+ } |
+ LayoutObjectDrawingRecorder drawingRecorder( |
+ context, *layoutBox, PaintPhaseClippingMask, clipBoundingRect); |
+ context.fillRect(clipBoundingRect, Color::black); |
+} |
+ |
} // namespace blink |