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

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

Issue 1739893006: Skip PaintLayer empty paint phases if it previously painted nothing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 months 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
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 1dd3743352d2028eda0ef7f14961428a9535a298..e717da6a3e707d4d98f08ae8b9745a76730ca0af 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
@@ -215,6 +215,7 @@ static bool shouldCreateSubsequence(const PaintLayer& paintLayer, GraphicsContex
static bool shouldRepaintSubsequence(PaintLayer& paintLayer, const PaintLayerPaintingInfo& paintingInfo, ShouldRespectOverflowClipType respectOverflowClip, const LayoutSize& subpixelAccumulation)
{
bool needsRepaint = false;
+ bool needsResetEmptyPaintPhaseFlags = false;
// Repaint subsequence if the layer is marked for needing repaint.
if (paintLayer.needsRepaint())
@@ -223,20 +224,32 @@ static bool shouldRepaintSubsequence(PaintLayer& paintLayer, const PaintLayerPai
// Repaint if layer's clip changes.
ClipRects& clipRects = paintLayer.clipper().paintingClipRects(paintingInfo.rootLayer, respectOverflowClip, subpixelAccumulation);
ClipRects* previousClipRects = paintLayer.previousPaintingClipRects();
- if (!needsRepaint && &clipRects != previousClipRects && (!previousClipRects || clipRects != *previousClipRects))
+ if (&clipRects != previousClipRects && (!previousClipRects || clipRects != *previousClipRects)) {
needsRepaint = true;
+ needsResetEmptyPaintPhaseFlags = true;
+ }
paintLayer.setPreviousPaintingClipRects(clipRects);
// Repaint if previously the layer might be clipped by paintDirtyRect and paintDirtyRect changes.
- if (!needsRepaint && paintLayer.previousPaintResult() == PaintLayerPainter::MayBeClippedByPaintDirtyRect && paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRect)
+ if (paintLayer.previousPaintResult() == PaintLayerPainter::MayBeClippedByPaintDirtyRect && paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRect) {
needsRepaint = true;
+ needsResetEmptyPaintPhaseFlags = true;
+ }
paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect);
// Repaint if scroll offset accumulation changes.
- if (!needsRepaint && paintingInfo.scrollOffsetAccumulation != paintLayer.previousScrollOffsetAccumulationForPainting())
+ if (paintingInfo.scrollOffsetAccumulation != paintLayer.previousScrollOffsetAccumulationForPainting()) {
needsRepaint = true;
+ needsResetEmptyPaintPhaseFlags = true;
+ }
paintLayer.setPreviousScrollOffsetAccumulationForPainting(paintingInfo.scrollOffsetAccumulation);
+ if (needsResetEmptyPaintPhaseFlags) {
+ paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false);
+ paintLayer.setPreviousPaintPhaseFloatEmpty(false);
+ paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false);
+ }
+
return needsRepaint;
}
@@ -699,13 +712,22 @@ void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l
if (selectionOnly) {
paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments, context, localPaintingInfo, paintFlags, clipState);
} else {
- if (m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds())
+ if (m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) {
+ size_t sizeBefore = context.paintController().newDisplayItemList().size();
paintForegroundForFragmentsWithPhase(PaintPhaseDescendantBlockBackgroundsOnly, layerFragments, context, localPaintingInfo, paintFlags, clipState);
- if (m_paintLayer.needsPaintPhaseFloat())
+ m_paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(context.paintController().newDisplayItemList().size() == sizeBefore);
+ }
+ if (m_paintLayer.needsPaintPhaseFloat()) {
+ size_t sizeBefore = context.paintController().newDisplayItemList().size();
paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, context, localPaintingInfo, paintFlags, clipState);
+ m_paintLayer.setPreviousPaintPhaseFloatEmpty(context.paintController().newDisplayItemList().size() == sizeBefore);
+ }
paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragments, context, localPaintingInfo, paintFlags, clipState);
- if (m_paintLayer.needsPaintPhaseDescendantOutlines())
+ if (m_paintLayer.needsPaintPhaseDescendantOutlines()) {
+ size_t sizeBefore = context.paintController().newDisplayItemList().size();
paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnly, layerFragments, context, localPaintingInfo, paintFlags, clipState);
+ m_paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(context.paintController().newDisplayItemList().size() == sizeBefore);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698