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

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp

Issue 2581243002: Simplify and speed up painting of clipping masks (Closed)
Patch Set: Fix cases with no clip recorder Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698