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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp

Issue 1577433003: Statistics of LayoutBox rare data reasons Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 3 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/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 11 matching lines...) Expand all
22 #include "platform/graphics/paint/CompositingRecorder.h" 22 #include "platform/graphics/paint/CompositingRecorder.h"
23 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" 23 #include "platform/graphics/paint/DisplayItemCacheSkipper.h"
24 #include "platform/graphics/paint/PaintChunkProperties.h" 24 #include "platform/graphics/paint/PaintChunkProperties.h"
25 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" 25 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
26 #include "platform/graphics/paint/SubsequenceRecorder.h" 26 #include "platform/graphics/paint/SubsequenceRecorder.h"
27 #include "platform/graphics/paint/Transform3DDisplayItem.h" 27 #include "platform/graphics/paint/Transform3DDisplayItem.h"
28 #include "wtf/Optional.h" 28 #include "wtf/Optional.h"
29 29
30 namespace blink { 30 namespace blink {
31 31
32 int paints[9];
33
34 int* paintCounts() {
35 return paints;
36 }
37
32 static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer) { 38 static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer) {
33 // Avoid painting descendants of the root layer when stylesheets haven't 39 // Avoid painting descendants of the root layer when stylesheets haven't
34 // loaded. This avoids some FOUC. It's ok not to draw, because later on, when 40 // loaded. This avoids some FOUC. It's ok not to draw, because later on, when
35 // all the stylesheets do load, Document::styleResolverMayHaveChanged() will 41 // all the stylesheets do load, Document::styleResolverMayHaveChanged() will
36 // invalidate all painted output via a call to 42 // invalidate all painted output via a call to
37 // LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid 43 // LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid
38 // caching subsequences in this mode; see shouldCreateSubsequence(). 44 // caching subsequences in this mode; see shouldCreateSubsequence().
39 if (layer.layoutObject().document().didLayoutWithPendingStylesheets() && 45 if (layer.layoutObject().document().didLayoutWithPendingStylesheets() &&
40 !layer.isRootLayer() && !layer.layoutObject().isDocumentElement()) 46 !layer.isRootLayer() && !layer.layoutObject().isDocumentElement())
41 return true; 47 return true;
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 Optional<LayerClipRecorder> clipRecorder; 1041 Optional<LayerClipRecorder> clipRecorder;
1036 if (shouldClip && 1042 if (shouldClip &&
1037 needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { 1043 needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) {
1038 clipRecorder.emplace( 1044 clipRecorder.emplace(
1039 context, m_paintLayer.layoutObject(), DisplayItem::kClipLayerForeground, 1045 context, m_paintLayer.layoutObject(), DisplayItem::kClipLayerForeground,
1040 layerFragments[0].foregroundRect, localPaintingInfo.rootLayer, 1046 layerFragments[0].foregroundRect, localPaintingInfo.rootLayer,
1041 layerFragments[0].paginationOffset, paintFlags); 1047 layerFragments[0].paginationOffset, paintFlags);
1042 clipState = HasClipped; 1048 clipState = HasClipped;
1043 } 1049 }
1044 1050
1051 size_t sizeBefore = context.getPaintController().newDisplayItemList().size();
1045 // We have to loop through every fragment multiple times, since we have to 1052 // We have to loop through every fragment multiple times, since we have to
1046 // issue paint invalidations in each specific phase in order for interleaving 1053 // issue paint invalidations in each specific phase in order for interleaving
1047 // of the fragments to work properly. 1054 // of the fragments to work properly.
1048 if (selectionOnly) { 1055 if (selectionOnly) {
1049 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments, 1056 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments,
1050 context, localPaintingInfo, paintFlags, 1057 context, localPaintingInfo, paintFlags,
1051 clipState); 1058 clipState);
1052 } else { 1059 } else {
1053 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || 1060 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() ||
1054 m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) { 1061 m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) {
1055 size_t sizeBefore = 1062 size_t sizeBefore =
1056 context.getPaintController().newDisplayItemList().size(); 1063 context.getPaintController().newDisplayItemList().size();
1057 paintForegroundForFragmentsWithPhase( 1064 paintForegroundForFragmentsWithPhase(
1058 PaintPhaseDescendantBlockBackgroundsOnly, layerFragments, context, 1065 PaintPhaseDescendantBlockBackgroundsOnly, layerFragments, context,
1059 localPaintingInfo, paintFlags, clipState); 1066 localPaintingInfo, paintFlags, clipState);
1060 // Don't set the empty flag if we are not painting the whole background. 1067 // Don't set the empty flag if we are not painting the whole background.
1061 if (!(paintFlags & PaintLayerPaintingSkipRootBackground)) { 1068 if (!(paintFlags & PaintLayerPaintingSkipRootBackground)) {
1062 bool phaseIsEmpty = 1069 bool phaseIsEmpty =
1063 context.getPaintController().newDisplayItemList().size() == 1070 context.getPaintController().newDisplayItemList().size() ==
1064 sizeBefore; 1071 sizeBefore;
1065 DCHECK(phaseIsEmpty || 1072 DCHECK(phaseIsEmpty ||
1066 m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()); 1073 m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds());
1067 m_paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty( 1074 m_paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(
1068 phaseIsEmpty); 1075 phaseIsEmpty);
1069 } 1076 }
1077 } else {
1078 paints[6]++;
1070 } 1079 }
1071 1080
1072 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || 1081 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() ||
1073 m_paintLayer.needsPaintPhaseFloat()) { 1082 m_paintLayer.needsPaintPhaseFloat()) {
1074 size_t sizeBefore = 1083 size_t sizeBefore =
1075 context.getPaintController().newDisplayItemList().size(); 1084 context.getPaintController().newDisplayItemList().size();
1076 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, 1085 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments,
1077 context, localPaintingInfo, 1086 context, localPaintingInfo,
1078 paintFlags, clipState); 1087 paintFlags, clipState);
1079 bool phaseIsEmpty = 1088 bool phaseIsEmpty =
1080 context.getPaintController().newDisplayItemList().size() == 1089 context.getPaintController().newDisplayItemList().size() ==
1081 sizeBefore; 1090 sizeBefore;
1082 DCHECK(phaseIsEmpty || m_paintLayer.needsPaintPhaseFloat()); 1091 DCHECK(phaseIsEmpty || m_paintLayer.needsPaintPhaseFloat());
1083 m_paintLayer.setPreviousPaintPhaseFloatEmpty(phaseIsEmpty); 1092 m_paintLayer.setPreviousPaintPhaseFloatEmpty(phaseIsEmpty);
1093 } else {
1094 paints[7]++;
1084 } 1095 }
1085 1096
1086 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragments, 1097 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragments,
1087 context, localPaintingInfo, paintFlags, 1098 context, localPaintingInfo, paintFlags,
1088 clipState); 1099 clipState);
1089 1100
1090 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || 1101 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() ||
1091 m_paintLayer.needsPaintPhaseDescendantOutlines()) { 1102 m_paintLayer.needsPaintPhaseDescendantOutlines()) {
1092 size_t sizeBefore = 1103 size_t sizeBefore =
1093 context.getPaintController().newDisplayItemList().size(); 1104 context.getPaintController().newDisplayItemList().size();
1094 paintForegroundForFragmentsWithPhase( 1105 paintForegroundForFragmentsWithPhase(
1095 PaintPhaseDescendantOutlinesOnly, layerFragments, context, 1106 PaintPhaseDescendantOutlinesOnly, layerFragments, context,
1096 localPaintingInfo, paintFlags, clipState); 1107 localPaintingInfo, paintFlags, clipState);
1097 bool phaseIsEmpty = 1108 bool phaseIsEmpty =
1098 context.getPaintController().newDisplayItemList().size() == 1109 context.getPaintController().newDisplayItemList().size() ==
1099 sizeBefore; 1110 sizeBefore;
1100 DCHECK(phaseIsEmpty || m_paintLayer.needsPaintPhaseDescendantOutlines()); 1111 DCHECK(phaseIsEmpty || m_paintLayer.needsPaintPhaseDescendantOutlines());
1101 m_paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(phaseIsEmpty); 1112 m_paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(phaseIsEmpty);
1113 } else {
1114 paints[8]++;
1102 } 1115 }
1116
1117 paints[5]++;
1118 if (sizeBefore == context.getPaintController().newDisplayItemList().size())
1119 paints[4]++;
1103 } 1120 }
1104 } 1121 }
1105 1122
1106 void PaintLayerPainter::paintForegroundForFragmentsWithPhase( 1123 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(
1107 PaintPhase phase, 1124 PaintPhase phase,
1108 const PaintLayerFragments& layerFragments, 1125 const PaintLayerFragments& layerFragments,
1109 GraphicsContext& context, 1126 GraphicsContext& context,
1110 const PaintLayerPaintingInfo& localPaintingInfo, 1127 const PaintLayerPaintingInfo& localPaintingInfo,
1111 PaintLayerFlags paintFlags, 1128 PaintLayerFlags paintFlags,
1112 ClipState clipState) { 1129 ClipState clipState) {
1113 Optional<DisplayItemCacheSkipper> cacheSkipper; 1130 Optional<DisplayItemCacheSkipper> cacheSkipper;
1114 if (layerFragments.size() > 1) 1131 if (layerFragments.size() > 1)
1115 cacheSkipper.emplace(context); 1132 cacheSkipper.emplace(context);
1116 1133
1134 int paintIndex = -1;
1135 switch (phase) {
1136 case PaintPhaseDescendantBlockBackgroundsOnly:
1137 paintIndex = 0;
1138 break;
1139 case PaintPhaseFloat:
1140 paintIndex = 1;
1141 break;
1142 case PaintPhaseForeground:
1143 paintIndex = 2;
1144 break;
1145 case PaintPhaseDescendantOutlinesOnly:
1146 paintIndex = 3;
1147 break;
1148 default:
1149 break;
1150 }
1151
1152 size_t sizeBefore = context.getPaintController().newDisplayItemList().size();
1117 for (auto& fragment : layerFragments) { 1153 for (auto& fragment : layerFragments) {
1118 if (!fragment.foregroundRect.isEmpty()) 1154 if (!fragment.foregroundRect.isEmpty())
1119 paintFragmentWithPhase(phase, fragment, context, fragment.foregroundRect, 1155 paintFragmentWithPhase(phase, fragment, context, fragment.foregroundRect,
1120 localPaintingInfo, paintFlags, clipState); 1156 localPaintingInfo, paintFlags, clipState);
1121 } 1157 }
1158 if (paintIndex != -1 &&
1159 sizeBefore == context.getPaintController().newDisplayItemList().size())
1160 paints[paintIndex]++;
1122 } 1161 }
1123 1162
1124 void PaintLayerPainter::paintSelfOutlineForFragments( 1163 void PaintLayerPainter::paintSelfOutlineForFragments(
1125 const PaintLayerFragments& layerFragments, 1164 const PaintLayerFragments& layerFragments,
1126 GraphicsContext& context, 1165 GraphicsContext& context,
1127 const PaintLayerPaintingInfo& localPaintingInfo, 1166 const PaintLayerPaintingInfo& localPaintingInfo,
1128 PaintLayerFlags paintFlags) { 1167 PaintLayerFlags paintFlags) {
1129 Optional<DisplayItemCacheSkipper> cacheSkipper; 1168 Optional<DisplayItemCacheSkipper> cacheSkipper;
1130 if (layerFragments.size() > 1) 1169 if (layerFragments.size() > 1)
1131 cacheSkipper.emplace(context); 1170 cacheSkipper.emplace(context);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 context, layoutObject, PaintPhaseClippingMask)) 1241 context, layoutObject, PaintPhaseClippingMask))
1203 return; 1242 return;
1204 1243
1205 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 1244 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
1206 LayoutObjectDrawingRecorder drawingRecorder( 1245 LayoutObjectDrawingRecorder drawingRecorder(
1207 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); 1246 context, layoutObject, PaintPhaseClippingMask, snappedClipRect);
1208 context.fillRect(snappedClipRect, Color::black); 1247 context.fillRect(snappedClipRect, Color::black);
1209 } 1248 }
1210 1249
1211 } // namespace blink 1250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698