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

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

Issue 1375393002: Output subsequence for children layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 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/DeprecatedPaintLayerPainterTest.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 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 "config.h" 5 #include "config.h"
6 #include "core/paint/DeprecatedPaintLayerPainter.h" 6 #include "core/paint/DeprecatedPaintLayerPainter.h"
7 7
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar s 213 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar s
214 && ((isPaintingScrollingContent && isPaintingCompositedBackground) 214 && ((isPaintingScrollingContent && isPaintingCompositedBackground)
215 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); 215 || (!isPaintingScrollingContent && isPaintingCompositedForeground));
216 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting Layer && !isPaintingOverlayScrollbars; 216 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting Layer && !isPaintingOverlayScrollbars;
217 217
218 PaintResult result = FullyPainted; 218 PaintResult result = FullyPainted;
219 219
220 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) 220 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement())
221 return result; 221 return result;
222 222
223 Optional<SubsequenceRecorder> subsequenceRecorder;
224
225 bool scrollOffsetAccumulationChanged = paintingInfoArg.scrollOffsetAccumulat ion != m_paintLayer.previousScrollOffsetAccumulationForPainting();
226 if (scrollOffsetAccumulationChanged)
227 m_paintLayer.setPreviousScrollOffsetAccumulationForPainting(paintingInfo Arg.scrollOffsetAccumulation);
228
229 if (!isPaintingOverlayScrollbars
230 && !paintingInfoArg.disableSubsequenceCache
231 && !(paintingInfoArg.globalPaintFlags() & GlobalPaintFlattenCompositingL ayers)
232 && !(paintFlags & PaintLayerPaintingReflection)
233 && !(paintFlags & PaintLayerPaintingRootBackgroundOnly)) {
234 if (!scrollOffsetAccumulationChanged && !m_paintLayer.needsRepaint() && SubsequenceRecorder::useCachedSubsequenceIfPossible(*context, m_paintLayer))
235 return result;
236 subsequenceRecorder.emplace(*context, m_paintLayer);
237 }
238
239 DeprecatedPaintLayerPaintingInfo paintingInfo = paintingInfoArg; 223 DeprecatedPaintLayerPaintingInfo paintingInfo = paintingInfoArg;
240 224
241 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() 225 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()
242 && (m_paintLayer.layoutObject()->hasOverflowClip() || m_paintLayer.layou tObject()->hasClip())) 226 && (m_paintLayer.layoutObject()->hasOverflowClip() || m_paintLayer.layou tObject()->hasClip()))
243 paintingInfo.disableSubsequenceCache = true; 227 paintingInfo.disableSubsequenceCache = true;
pdr. 2015/09/30 23:11:56 Does this need to be moved too?
Xianzhu 2015/09/30 23:29:47 Yes. This should control child subsequences. If no
244 228
245 // Ensure our lists are up-to-date. 229 // Ensure our lists are up-to-date.
246 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); 230 m_paintLayer.stackingNode()->updateLayerListsIfNeeded();
247 231
248 LayoutPoint offsetFromRoot; 232 LayoutPoint offsetFromRoot;
249 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 233 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
250 234
251 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) 235 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking)
252 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); 236 offsetFromRoot.move(m_paintLayer.subpixelAccumulation());
253 else 237 else
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; 333 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly;
350 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 334 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly;
351 335
352 if (shouldPaintMask) 336 if (shouldPaintMask)
353 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags); 337 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags);
354 if (shouldPaintClippingMask) { 338 if (shouldPaintClippingMask) {
355 // Paint the border radius mask for the fragments. 339 // Paint the border radius mask for the fragments.
356 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags); 340 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags);
357 } 341 }
358 342
359 // Set subsequence not cacheable if the bounding box of this layer and desce ndants is not fully contained 343 m_paintLayer.setPreviousScrollOffsetAccumulationForPainting(paintingInfoArg. scrollOffsetAccumulation);
360 // by paintRect, because later paintRect changes may expose new contents whi ch will need repainting.
361 if (result == MaybeNotFullyPainted && subsequenceRecorder)
362 subsequenceRecorder->setUncacheable();
363 344
364 return result; 345 return result;
365 } 346 }
366 347
367 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect) 348 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect)
368 { 349 {
369 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); 350 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius();
370 } 351 }
371 352
372 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot ) 353 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot )
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintChild ren(unsigned childrenToVisit, GraphicsContext* context, const DeprecatedPaintLay erPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 466 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintChild ren(unsigned childrenToVisit, GraphicsContext* context, const DeprecatedPaintLay erPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
486 { 467 {
487 PaintResult result = FullyPainted; 468 PaintResult result = FullyPainted;
488 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 469 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
489 return result; 470 return result;
490 471
491 #if ENABLE(ASSERT) 472 #if ENABLE(ASSERT)
492 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); 473 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode());
493 #endif 474 #endif
494 475
495 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; 476 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit);
477 DeprecatedPaintLayerStackingNode* child = iterator.next();
478 if (!child)
479 return result;
480
481 DisplayItem::Type subsequenceType;
482 if (childrenToVisit == NegativeZOrderChildren) {
483 subsequenceType = DisplayItem::SubsequenceNegativeZOrder;
484 } else {
485 ASSERT(childrenToVisit == (NormalFlowChildren | PositiveZOrderChildren)) ;
486 subsequenceType = DisplayItem::SubsequenceNormalFlowAndPositiveZOrder;
487 }
488
489 Optional<SubsequenceRecorder> subsequenceRecorder;
490 if (!paintingInfo.disableSubsequenceCache
491 && !(paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLaye rs)
492 && !(paintFlags & PaintLayerPaintingReflection)
493 && !(paintFlags & PaintLayerPaintingRootBackgroundOnly)) {
494 if (!m_paintLayer.needsRepaint()
495 && paintingInfo.scrollOffsetAccumulation == m_paintLayer.previousScr ollOffsetAccumulationForPainting()
496 && SubsequenceRecorder::useCachedSubsequenceIfPossible(*context, m_p aintLayer, subsequenceType))
497 return result;
498 subsequenceRecorder.emplace(*context, m_paintLayer, subsequenceType);
499 }
500
501 IntSize scrollOffsetAccumulationForChildren = paintingInfo.scrollOffsetAccum ulation;
496 if (m_paintLayer.layoutObject()->hasOverflowClip()) 502 if (m_paintLayer.layoutObject()->hasOverflowClip())
497 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set(); 503 scrollOffsetAccumulationForChildren += m_paintLayer.layoutBox()->scrolle dContentOffset();
498 504
499 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); 505 for (; child; child = iterator.next()) {
500 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) {
501 DeprecatedPaintLayerPainter childPainter(*child->layer()); 506 DeprecatedPaintLayerPainter childPainter(*child->layer());
502 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() 507 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents()
503 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). 508 // and CompositedDeprecatedPaintLayerMapping::doPaintTask().
504 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags)) 509 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags)) {
pdr. 2015/09/30 23:11:56 Nit: extra curly braces.
Xianzhu 2015/09/30 23:29:47 Done.
505 continue; 510 continue;
511 }
506 512
507 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; 513 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo;
508 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; 514 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulationFor Children;
509 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer. 515 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer.
510 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { 516 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) {
511 if (parentLayer->layoutObject()->hasOverflowClip()) 517 if (parentLayer->layoutObject()->hasOverflowClip())
512 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset(); 518 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset();
513 } 519 }
514 520
515 if (childPainter.paintLayer(context, childPaintingInfo, paintFlags) == M aybeNotFullyPainted) 521 if (childPainter.paintLayer(context, childPaintingInfo, paintFlags) == M aybeNotFullyPainted)
516 result = MaybeNotFullyPainted; 522 result = MaybeNotFullyPainted;
517 } 523 }
524
525 // Set subsequence not cacheable if the bounding box of this layer and desce ndants is not fully contained
526 // by paintRect, because later paintRect changes may expose new contents whi ch will need repainting.
527 if (result == MaybeNotFullyPainted && subsequenceRecorder)
528 subsequenceRecorder->setUncacheable();
529
518 return result; 530 return result;
519 } 531 }
520 532
521 // FIXME: inline this. 533 // FIXME: inline this.
522 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) 534 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags)
523 { 535 {
524 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); 536 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly);
525 } 537 }
526 538
527 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags) 539 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 695 if (!m_paintLayer.containsDirtyOverlayScrollbars())
684 return; 696 return;
685 697
686 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); 698 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot);
687 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 699 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
688 700
689 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 701 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
690 } 702 }
691 703
692 } // namespace blink 704 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/DeprecatedPaintLayerPainterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698