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

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

Issue 2832603002: Only store previous clip rects for PaintLayers that support subsequences. (Closed)
Patch Set: Created 3 years, 8 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 static bool ShouldCreateSubsequence(const PaintLayer& paint_layer, 162 static bool ShouldCreateSubsequence(const PaintLayer& paint_layer,
163 const GraphicsContext& context, 163 const GraphicsContext& context,
164 const PaintLayerPaintingInfo& painting_info, 164 const PaintLayerPaintingInfo& painting_info,
165 PaintLayerFlags paint_flags) { 165 PaintLayerFlags paint_flags) {
166 // Caching is not needed during printing. 166 // Caching is not needed during printing.
167 if (context.Printing()) 167 if (context.Printing())
168 return false; 168 return false;
169 169
170 if (!paint_layer.SupportsSubsequenceCaching())
171 return false;
172
170 // Don't create subsequence for a composited layer because if it can be 173 // Don't create subsequence for a composited layer because if it can be
171 // cached, we can skip the whole painting in GraphicsLayer::paint() with 174 // cached, we can skip the whole painting in GraphicsLayer::paint() with
172 // CachedDisplayItemList. This also avoids conflict of 175 // CachedDisplayItemList. This also avoids conflict of
173 // PaintLayer::previousXXX() when paintLayer is composited scrolling and is 176 // PaintLayer::previousXXX() when paintLayer is composited scrolling and is
174 // painted twice for GraphicsLayers of container and scrolling contents. 177 // painted twice for GraphicsLayers of container and scrolling contents.
175 if (paint_layer.GetCompositingState() == kPaintsIntoOwnBacking) 178 if (paint_layer.GetCompositingState() == kPaintsIntoOwnBacking)
176 return false; 179 return false;
177 180
178 // Don't create subsequence during special painting to avoid cache conflict 181 // Don't create subsequence during special painting to avoid cache conflict
179 // with normal painting. 182 // with normal painting.
180 if (painting_info.GetGlobalPaintFlags() & 183 if (painting_info.GetGlobalPaintFlags() &
181 kGlobalPaintFlattenCompositingLayers) 184 kGlobalPaintFlattenCompositingLayers)
182 return false; 185 return false;
183 if (paint_flags & 186 if (paint_flags &
184 (kPaintLayerPaintingRootBackgroundOnly | 187 (kPaintLayerPaintingRootBackgroundOnly |
185 kPaintLayerPaintingOverlayScrollbars | kPaintLayerUncachedClipRects)) 188 kPaintLayerPaintingOverlayScrollbars | kPaintLayerUncachedClipRects))
186 return false; 189 return false;
187 190
188 // Create subsequence for only stacking contexts whose painting are atomic.
189 // SVG is also painted atomically.
190 if (!paint_layer.StackingNode()->IsStackingContext() &&
191 !paint_layer.GetLayoutObject().IsSVGRoot())
192 return false;
193
194 // The layer doesn't have children. Subsequence caching is not worth because
195 // normally the actual painting will be cheap.
196 // SVG is also painted atomically.
197 if (!PaintLayerStackingNodeIterator(*paint_layer.StackingNode(), kAllChildren)
198 .Next() &&
199 !paint_layer.GetLayoutObject().IsSVGRoot())
200 return false;
201
202 // When in FOUC-avoidance mode, don't cache any subsequences, to avoid having 191 // When in FOUC-avoidance mode, don't cache any subsequences, to avoid having
203 // to invalidate all of them when leaving this mode. There is an early-out in 192 // to invalidate all of them when leaving this mode. There is an early-out in
204 // BlockPainter::paintContents that may result in nothing getting painted in 193 // BlockPainter::paintContents that may result in nothing getting painted in
205 // this mode, in addition to early-out logic in PaintLayerPainter. 194 // this mode, in addition to early-out logic in PaintLayerPainter.
206 if (paint_layer.GetLayoutObject() 195 if (paint_layer.GetLayoutObject()
207 .GetDocument() 196 .GetDocument()
208 .DidLayoutWithPendingStylesheets()) 197 .DidLayoutWithPendingStylesheets())
209 return false; 198 return false;
210 199
211 return true; 200 return true;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 Optional<SubsequenceRecorder> subsequence_recorder; 328 Optional<SubsequenceRecorder> subsequence_recorder;
340 bool should_clear_empty_paint_phase_flags = false; 329 bool should_clear_empty_paint_phase_flags = false;
341 if (ShouldCreateSubsequence(paint_layer_, context, painting_info_arg, 330 if (ShouldCreateSubsequence(paint_layer_, context, painting_info_arg,
342 paint_flags)) { 331 paint_flags)) {
343 if (!ShouldRepaintSubsequence(paint_layer_, painting_info_arg, 332 if (!ShouldRepaintSubsequence(paint_layer_, painting_info_arg,
344 respect_overflow_clip, subpixel_accumulation, 333 respect_overflow_clip, subpixel_accumulation,
345 should_clear_empty_paint_phase_flags) && 334 should_clear_empty_paint_phase_flags) &&
346 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, 335 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context,
347 paint_layer_)) 336 paint_layer_))
348 return result; 337 return result;
338 DCHECK(paint_layer_.SupportsSubsequenceCaching());
349 subsequence_recorder.emplace(context, paint_layer_); 339 subsequence_recorder.emplace(context, paint_layer_);
350 } else { 340 } else {
351 should_clear_empty_paint_phase_flags = true; 341 should_clear_empty_paint_phase_flags = true;
352 } 342 }
353 343
354 if (should_clear_empty_paint_phase_flags) { 344 if (should_clear_empty_paint_phase_flags) {
355 paint_layer_.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); 345 paint_layer_.SetPreviousPaintPhaseDescendantOutlinesEmpty(false);
356 paint_layer_.SetPreviousPaintPhaseFloatEmpty(false); 346 paint_layer_.SetPreviousPaintPhaseFloatEmpty(false);
357 paint_layer_.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); 347 paint_layer_.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false);
358 } 348 }
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 context, layout_object, kPaintPhaseClippingMask)) 1225 context, layout_object, kPaintPhaseClippingMask))
1236 return; 1226 return;
1237 1227
1238 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 1228 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
1239 LayoutObjectDrawingRecorder drawing_recorder( 1229 LayoutObjectDrawingRecorder drawing_recorder(
1240 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); 1230 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect);
1241 context.FillRect(snapped_clip_rect, Color::kBlack); 1231 context.FillRect(snapped_clip_rect, Color::kBlack);
1242 } 1232 }
1243 1233
1244 } // namespace blink 1234 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | third_party/WebKit/Source/core/paint/PaintLayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698