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

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

Issue 2274663002: CL for perf tryjob on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/BoxPaintInvalidator.h" 5 #include "core/paint/BoxPaintInvalidator.h"
6 6
7 #include "core/frame/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/ObjectPaintInvalidator.h" 9 #include "core/paint/ObjectPaintInvalidator.h"
10 #include "core/paint/PaintInvalidator.h" 10 #include "core/paint/PaintInvalidator.h"
(...skipping 16 matching lines...) Expand all
27 return map; 27 return map;
28 } 28 }
29 29
30 void BoxPaintInvalidator::boxWillBeDestroyed(const LayoutBox& box) 30 void BoxPaintInvalidator::boxWillBeDestroyed(const LayoutBox& box)
31 { 31 {
32 previousBoxSizesMap().remove(&box); 32 previousBoxSizesMap().remove(&box);
33 } 33 }
34 34
35 bool BoxPaintInvalidator::incrementallyInvalidatePaint() 35 bool BoxPaintInvalidator::incrementallyInvalidatePaint()
36 { 36 {
37 bool result = ObjectPaintInvalidatorWithContext(m_box, m_context).incrementa llyInvalidatePaint(); 37 bool result = false; // ObjectPaintInvalidatorWithContext(m_box, m_context). incrementallyInvalidatePaint();
38 38
39 bool hasBoxDecorations = m_box.styleRef().hasBoxDecorations(); 39 bool hasBoxDecorations = m_box.styleRef().hasBoxDecorations();
40 if (!m_box.styleRef().hasBackground() && !hasBoxDecorations) 40 if (!m_box.styleRef().hasBackground() && !hasBoxDecorations)
41 return result; 41 return result;
42 42
43 const LayoutRect& oldBounds = m_context.oldBounds; 43 const LayoutRect& oldBounds = m_context.oldBounds;
44 const LayoutRect& newBounds = m_context.newBounds; 44 const LayoutRect& newBounds = m_context.newBounds;
45 45
46 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size()) ; 46 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size()) ;
47 LayoutSize newBorderBoxSize = m_box.size(); 47 LayoutSize newBorderBoxSize = m_box.size();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds)) 102 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds))
103 objectPaintInvalidator.invalidatePaintUsingContainer(*m_context.paintInv alidationContainer, rectClippedByOldBounds, PaintInvalidationIncremental); 103 objectPaintInvalidator.invalidatePaintUsingContainer(*m_context.paintInv alidationContainer, rectClippedByOldBounds, PaintInvalidationIncremental);
104 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds)) 104 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds))
105 objectPaintInvalidator.invalidatePaintUsingContainer(*m_context.paintInv alidationContainer, rectClippedByNewBounds, PaintInvalidationIncremental); 105 objectPaintInvalidator.invalidatePaintUsingContainer(*m_context.paintInv alidationContainer, rectClippedByNewBounds, PaintInvalidationIncremental);
106 } 106 }
107 107
108 PaintInvalidationReason BoxPaintInvalidator::computePaintInvalidationReason() 108 PaintInvalidationReason BoxPaintInvalidator::computePaintInvalidationReason()
109 { 109 {
110 PaintInvalidationReason reason = ObjectPaintInvalidatorWithContext(m_box, m_ context).computePaintInvalidationReason(); 110 PaintInvalidationReason reason = ObjectPaintInvalidatorWithContext(m_box, m_ context).computePaintInvalidationReason();
111 111
112 if (isImmediateFullPaintInvalidationReason(reason) || reason == PaintInvalid ationNone) 112 if (reason != PaintInvalidationDelayedFull && isFullPaintInvalidationReason( reason))
113 // isImmediateFullPaintInvalidationReason(reason) || reason == PaintInvalida tionNone)
113 return reason; 114 return reason;
114 115
115 if (m_box.mayNeedPaintInvalidationAnimatedBackgroundImage() && !m_box.backgr oundIsKnownToBeObscured()) 116 if (m_box.mayNeedPaintInvalidationAnimatedBackgroundImage() && !m_box.backgr oundIsKnownToBeObscured())
116 reason = PaintInvalidationDelayedFull; 117 reason = PaintInvalidationDelayedFull;
117 118
118 // If the current paint invalidation reason is PaintInvalidationDelayedFull, then this paint invalidation can delayed if the 119 // If the current paint invalidation reason is PaintInvalidationDelayedFull, then this paint invalidation can delayed if the
119 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original 120 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original
120 // paint invalidation that chose PaintInvalidationDelayedFull. 121 // paint invalidation that chose PaintInvalidationDelayedFull.
121 if (reason == PaintInvalidationDelayedFull) { 122 if (reason == PaintInvalidationDelayedFull) {
122 // Do regular full paint invalidation if the object is onscreen. 123 // Do regular full paint invalidation if the object is onscreen.
123 return m_box.intersectsVisibleViewport() ? PaintInvalidationFull : Paint InvalidationDelayedFull; 124 return m_box.intersectsVisibleViewport() ? PaintInvalidationFull : Paint InvalidationDelayedFull;
124 } 125 }
125 126
126 if (m_box.isLayoutView()) { 127 if (m_box.isLayoutView()) {
127 const LayoutView& layoutView = toLayoutView(m_box); 128 const LayoutView& layoutView = toLayoutView(m_box);
128 // In normal compositing mode, root background doesn't need to be invali dated for 129 // In normal compositing mode, root background doesn't need to be invali dated for
129 // box changes, because the background always covers the whole document rect 130 // box changes, because the background always covers the whole document rect
130 // and clipping is done by compositor()->m_containerLayer. Also the scro llbars 131 // and clipping is done by compositor()->m_containerLayer. Also the scro llbars
131 // are always composited. There are no other box decoration on the Layou tView thus 132 // are always composited. There are no other box decoration on the Layou tView thus
132 // we can safely exit here. 133 // we can safely exit here.
133 if (layoutView.usesCompositing() && (!layoutView.document().settings() | | !layoutView.document().settings()->rootLayerScrolls())) 134 if (layoutView.usesCompositing() && (!layoutView.document().settings() | | !layoutView.document().settings()->rootLayerScrolls()))
134 return reason; 135 return reason;
135 } 136 }
136 137
137 // If the transform is not identity or translation, incremental invalidation is not applicable 138 // If the transform is not identity or translation, incremental invalidation is not applicable
138 // because the difference between oldBounds and newBounds doesn't cover all area needing invalidation. 139 // because the difference between oldBounds and newBounds doesn't cover all area needing invalidation.
139 // FIXME: Should also consider ancestor transforms since paintInvalidationCo ntainer. crbug.com/426111. 140 // FIXME: Should also consider ancestor transforms since paintInvalidationCo ntainer. crbug.com/426111.
140 if (reason == PaintInvalidationIncremental 141 if (reason == PaintInvalidationIncremental
141 && m_context.oldBounds != m_context.newBounds 142 // && m_context.oldBounds != m_context.newBounds
142 && m_context.paintInvalidationContainer != m_box 143 && m_context.paintInvalidationContainer != m_box
143 && m_box.hasLayer() && m_box.layer()->transform() 144 && m_box.hasLayer() && m_box.layer()->transform()
144 && !m_box.layer()->transform()->isIdentityOrTranslation()) 145 && !m_box.layer()->transform()->isIdentityOrTranslation())
145 return PaintInvalidationBoundsChange; 146 return PaintInvalidationBoundsChange;
146 147
147 const ComputedStyle& style = m_box.styleRef(); 148 const ComputedStyle& style = m_box.styleRef();
148 if (style.backgroundLayers().thisOrNextLayersUseContentBox() || style.maskLa yers().thisOrNextLayersUseContentBox() || style.boxSizing() == BoxSizingBorderBo x) { 149 if (style.backgroundLayers().thisOrNextLayersUseContentBox() || style.maskLa yers().thisOrNextLayersUseContentBox() || style.boxSizing() == BoxSizingBorderBo x) {
149 if (previousBoxSizesMap().get(&m_box).contentBoxRect != m_box.contentBox Rect()) 150 if (previousBoxSizesMap().get(&m_box).contentBoxRect != m_box.contentBox Rect())
150 return PaintInvalidationContentBoxChange; 151 return PaintInvalidationContentBoxChange;
151 } 152 }
152 153
153 if (!style.hasBackground() && !style.hasBoxDecorations()) { 154 if (!style.hasBackground() && !style.hasBoxDecorations()) {
154 // We could let incremental invalidation cover non-composited scrollbars , but just 155 // We could let incremental invalidation cover non-composited scrollbars , but just
155 // do a full invalidation because incremental invalidation will go away with slimming paint. 156 // do a full invalidation because incremental invalidation will go away with slimming paint.
156 if (reason == PaintInvalidationIncremental && m_context.oldBounds != m_c ontext.newBounds && m_box.hasNonCompositedScrollbars()) 157 if (reason == PaintInvalidationIncremental && /* m_context.oldBounds != m_context.newBounds && */ m_box.hasNonCompositedScrollbars())
157 return PaintInvalidationBorderBoxChange; 158 return PaintInvalidationBorderBoxChange;
158 return reason; 159 return reason;
159 } 160 }
160 161
161 if (style.backgroundLayers().thisOrNextLayersHaveLocalAttachment()) { 162 if (style.backgroundLayers().thisOrNextLayersHaveLocalAttachment()) {
162 if (previousBoxSizesMap().get(&m_box).layoutOverflowRect != m_box.layout OverflowRect()) 163 if (previousBoxSizesMap().get(&m_box).layoutOverflowRect != m_box.layout OverflowRect())
163 return PaintInvalidationLayoutOverflowBoxChange; 164 return PaintInvalidationLayoutOverflowBoxChange;
164 } 165 }
165 166
166 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(m_context.oldBoun ds.size()); 167 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(m_context.oldBoun ds.size());
(...skipping 16 matching lines...) Expand all
183 FloatRoundedRect newRoundedRect = style.getRoundedBorderFor(LayoutRect(L ayoutPoint(0, 0), newBorderBoxSize)); 184 FloatRoundedRect newRoundedRect = style.getRoundedBorderFor(LayoutRect(L ayoutPoint(0, 0), newBorderBoxSize));
184 if (oldRoundedRect.getRadii() != newRoundedRect.getRadii()) 185 if (oldRoundedRect.getRadii() != newRoundedRect.getRadii())
185 return PaintInvalidationBorderBoxChange; 186 return PaintInvalidationBorderBoxChange;
186 } 187 }
187 188
188 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && m_box.mustInvali dateBackgroundOrBorderPaintOnWidthChange()) 189 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && m_box.mustInvali dateBackgroundOrBorderPaintOnWidthChange())
189 return PaintInvalidationBorderBoxChange; 190 return PaintInvalidationBorderBoxChange;
190 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && m_box.mustInva lidateBackgroundOrBorderPaintOnHeightChange()) 191 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && m_box.mustInva lidateBackgroundOrBorderPaintOnHeightChange())
191 return PaintInvalidationBorderBoxChange; 192 return PaintInvalidationBorderBoxChange;
192 193
194 if (reason == PaintInvalidationNone && (style.hasBackground() || style.hasBo xDecorations()))
195 reason = PaintInvalidationIncremental;
196
193 return reason; 197 return reason;
194 } 198 }
195 199
196 PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded() 200 PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded()
197 { 201 {
202 PaintInvalidationReason reason = ObjectPaintInvalidatorWithContext(m_box, m_ context).invalidatePaintIfNeededWithComputedReason(computePaintInvalidationReaso n());
203
204 if (reason == PaintInvalidationIncremental)
205 incrementallyInvalidatePaint();
206
207 /*
198 PaintInvalidationReason reason = computePaintInvalidationReason(); 208 PaintInvalidationReason reason = computePaintInvalidationReason();
199 if (reason == PaintInvalidationIncremental) { 209 if (reason == PaintInvalidationIncremental) {
200 if (incrementallyInvalidatePaint()) { 210 if (incrementallyInvalidatePaint()) {
201 m_context.paintingLayer->setNeedsRepaint(); 211 m_context.paintingLayer->setNeedsRepaint();
202 m_box.invalidateDisplayItemClients(reason); 212 m_box.invalidateDisplayItemClients(reason);
203 } else { 213 } else {
204 reason = PaintInvalidationNone; 214 reason = PaintInvalidationNone;
205 } 215 }
206 // Though we have done our own version of incremental invalidation, we s till need to call 216 // Though we have done our own version of incremental invalidation, we s till need to call
207 // ObjectPaintInvalidator with PaintInvalidationNone to do any other req uired operations. 217 // ObjectPaintInvalidator with PaintInvalidationNone to do any other req uired operations.
208 reason = std::max(reason, ObjectPaintInvalidatorWithContext(m_box, m_con text).invalidatePaintIfNeededWithComputedReason(PaintInvalidationNone)); 218 reason = std::max(reason, ObjectPaintInvalidatorWithContext(m_box, m_con text).invalidatePaintIfNeededWithComputedReason(PaintInvalidationNone));
209 } else { 219 } else {
210 reason = ObjectPaintInvalidatorWithContext(m_box, m_context).invalidateP aintIfNeededWithComputedReason(reason); 220 reason = ObjectPaintInvalidatorWithContext(m_box, m_context).invalidateP aintIfNeededWithComputedReason(reason);
211 } 221 }
222 */
212 223
213 if (PaintLayerScrollableArea* area = m_box.getScrollableArea()) 224 if (PaintLayerScrollableArea* area = m_box.getScrollableArea())
214 area->invalidatePaintOfScrollControlsIfNeeded(m_context); 225 area->invalidatePaintOfScrollControlsIfNeeded(m_context);
215 226
216 // This is for the next invalidatePaintIfNeeded so must be at the end. 227 // This is for the next invalidatePaintIfNeeded so must be at the end.
217 savePreviousBoxSizesIfNeeded(); 228 savePreviousBoxSizesIfNeeded();
218 229
219 return reason; 230 return reason;
220 } 231 }
221 232
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 284
274 auto it = previousBoxSizesMap().find(&m_box); 285 auto it = previousBoxSizesMap().find(&m_box);
275 if (it != previousBoxSizesMap().end()) 286 if (it != previousBoxSizesMap().end())
276 return it->value.borderBoxSize; 287 return it->value.borderBoxSize;
277 288
278 // We didn't save the old border box size because it was the same as the siz e of oldBounds. 289 // We didn't save the old border box size because it was the same as the siz e of oldBounds.
279 return previousBoundsSize; 290 return previousBoundsSize;
280 } 291 }
281 292
282 } // namespace blink 293 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698