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

Side by Side 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: Add documentation 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 unified diff | Download patch
OLDNEW
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/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/ClipPathOperation.h" 9 #include "core/layout/ClipPathOperation.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // The layer doesn't have children. Subsequence caching is not worth because normally the actual painting will be cheap. 208 // The layer doesn't have children. Subsequence caching is not worth because normally the actual painting will be cheap.
209 if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren) .next()) 209 if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren) .next())
210 return false; 210 return false;
211 211
212 return true; 212 return true;
213 } 213 }
214 214
215 static bool shouldRepaintSubsequence(PaintLayer& paintLayer, const PaintLayerPai ntingInfo& paintingInfo, ShouldRespectOverflowClipType respectOverflowClip, cons t LayoutSize& subpixelAccumulation) 215 static bool shouldRepaintSubsequence(PaintLayer& paintLayer, const PaintLayerPai ntingInfo& paintingInfo, ShouldRespectOverflowClipType respectOverflowClip, cons t LayoutSize& subpixelAccumulation)
216 { 216 {
217 bool needsRepaint = false; 217 bool needsRepaint = false;
218 bool needsResetEmptyPaintPhaseFlags = false;
218 219
219 // Repaint subsequence if the layer is marked for needing repaint. 220 // Repaint subsequence if the layer is marked for needing repaint.
220 if (paintLayer.needsRepaint()) 221 if (paintLayer.needsRepaint())
221 needsRepaint = true; 222 needsRepaint = true;
222 223
223 // Repaint if layer's clip changes. 224 // Repaint if layer's clip changes.
224 ClipRects& clipRects = paintLayer.clipper().paintingClipRects(paintingInfo.r ootLayer, respectOverflowClip, subpixelAccumulation); 225 ClipRects& clipRects = paintLayer.clipper().paintingClipRects(paintingInfo.r ootLayer, respectOverflowClip, subpixelAccumulation);
225 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); 226 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects();
226 if (!needsRepaint && &clipRects != previousClipRects && (!previousClipRects || clipRects != *previousClipRects)) 227 if (&clipRects != previousClipRects && (!previousClipRects || clipRects != * previousClipRects)) {
227 needsRepaint = true; 228 needsRepaint = true;
229 needsResetEmptyPaintPhaseFlags = true;
230 }
228 paintLayer.setPreviousPaintingClipRects(clipRects); 231 paintLayer.setPreviousPaintingClipRects(clipRects);
229 232
230 // Repaint if previously the layer might be clipped by paintDirtyRect and pa intDirtyRect changes. 233 // Repaint if previously the layer might be clipped by paintDirtyRect and pa intDirtyRect changes.
231 if (!needsRepaint && paintLayer.previousPaintResult() == PaintLayerPainter:: MayBeClippedByPaintDirtyRect && paintLayer.previousPaintDirtyRect() != paintingI nfo.paintDirtyRect) 234 if (paintLayer.previousPaintResult() == PaintLayerPainter::MayBeClippedByPai ntDirtyRect && paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRec t) {
232 needsRepaint = true; 235 needsRepaint = true;
236 needsResetEmptyPaintPhaseFlags = true;
237 }
233 paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect); 238 paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect);
234 239
235 // Repaint if scroll offset accumulation changes. 240 // Repaint if scroll offset accumulation changes.
236 if (!needsRepaint && paintingInfo.scrollOffsetAccumulation != paintLayer.pre viousScrollOffsetAccumulationForPainting()) 241 if (paintingInfo.scrollOffsetAccumulation != paintLayer.previousScrollOffset AccumulationForPainting()) {
237 needsRepaint = true; 242 needsRepaint = true;
243 needsResetEmptyPaintPhaseFlags = true;
244 }
238 paintLayer.setPreviousScrollOffsetAccumulationForPainting(paintingInfo.scrol lOffsetAccumulation); 245 paintLayer.setPreviousScrollOffsetAccumulationForPainting(paintingInfo.scrol lOffsetAccumulation);
239 246
247 if (needsResetEmptyPaintPhaseFlags) {
248 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false);
249 paintLayer.setPreviousPaintPhaseFloatEmpty(false);
250 paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false);
251 }
252
240 return needsRepaint; 253 return needsRepaint;
241 } 254 }
242 255
243 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon text& context, const PaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags pa intFlags, FragmentPolicy fragmentPolicy) 256 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon text& context, const PaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags pa intFlags, FragmentPolicy fragmentPolicy)
244 { 257 {
245 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant()); 258 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant());
246 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); 259 ASSERT(!(paintFlags & PaintLayerAppliedTransform));
247 260
248 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); 261 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer();
249 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars; 262 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 705 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
693 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags); 706 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags);
694 clipState = HasClipped; 707 clipState = HasClipped;
695 } 708 }
696 709
697 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 710 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
698 // interleaving of the fragments to work properly. 711 // interleaving of the fragments to work properly.
699 if (selectionOnly) { 712 if (selectionOnly) {
700 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments , context, localPaintingInfo, paintFlags, clipState); 713 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments , context, localPaintingInfo, paintFlags, clipState);
701 } else { 714 } else {
702 if (m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) 715 if (m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) {
716 size_t sizeBefore = context.paintController().newDisplayItemList().s ize();
703 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantBlockBackgr oundsOnly, layerFragments, context, localPaintingInfo, paintFlags, clipState); 717 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantBlockBackgr oundsOnly, layerFragments, context, localPaintingInfo, paintFlags, clipState);
704 if (m_paintLayer.needsPaintPhaseFloat()) 718 m_paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(co ntext.paintController().newDisplayItemList().size() == sizeBefore);
719 }
720 if (m_paintLayer.needsPaintPhaseFloat()) {
721 size_t sizeBefore = context.paintController().newDisplayItemList().s ize();
705 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments , context, localPaintingInfo, paintFlags, clipState); 722 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments , context, localPaintingInfo, paintFlags, clipState);
723 m_paintLayer.setPreviousPaintPhaseFloatEmpty(context.paintController ().newDisplayItemList().size() == sizeBefore);
724 }
706 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintFlags, clipState); 725 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintFlags, clipState);
707 if (m_paintLayer.needsPaintPhaseDescendantOutlines()) 726 if (m_paintLayer.needsPaintPhaseDescendantOutlines()) {
727 size_t sizeBefore = context.paintController().newDisplayItemList().s ize();
708 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnl y, layerFragments, context, localPaintingInfo, paintFlags, clipState); 728 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnl y, layerFragments, context, localPaintingInfo, paintFlags, clipState);
729 m_paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(context.pa intController().newDisplayItemList().size() == sizeBefore);
730 }
709 } 731 }
710 } 732 }
711 733
712 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, 734 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase,
713 const PaintLayerFragments& layerFragments, GraphicsContext& context, 735 const PaintLayerFragments& layerFragments, GraphicsContext& context,
714 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags, ClipState clipState) 736 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags, ClipState clipState)
715 { 737 {
716 bool needsScope = layerFragments.size() > 1; 738 bool needsScope = layerFragments.size() > 1;
717 for (auto& fragment : layerFragments) { 739 for (auto& fragment : layerFragments) {
718 if (!fragment.foregroundRect.isEmpty()) { 740 if (!fragment.foregroundRect.isEmpty()) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 789 if (!m_paintLayer.containsDirtyOverlayScrollbars())
768 return; 790 return;
769 791
770 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); 792 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize());
771 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 793 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
772 794
773 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 795 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
774 } 796 }
775 797
776 } // namespace blink 798 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698