Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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() | |
| 242 && (m_paintLayer.layoutObject()->hasOverflowClip() || m_paintLayer.layou tObject()->hasClip())) | |
| 243 paintingInfo.disableSubsequenceCache = true; | |
| 244 | |
| 245 // Ensure our lists are up-to-date. | 225 // Ensure our lists are up-to-date. |
| 246 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); | 226 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); |
| 247 | 227 |
| 248 LayoutPoint offsetFromRoot; | 228 LayoutPoint offsetFromRoot; |
| 249 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 229 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
| 250 | 230 |
| 251 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) | 231 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) |
| 252 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); | 232 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); |
| 253 else | 233 else |
| 254 offsetFromRoot.move(paintingInfo.subPixelAccumulation); | 234 offsetFromRoot.move(paintingInfo.subPixelAccumulation); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; | 329 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; |
| 350 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; | 330 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; |
| 351 | 331 |
| 352 if (shouldPaintMask) | 332 if (shouldPaintMask) |
| 353 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags); | 333 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags); |
| 354 if (shouldPaintClippingMask) { | 334 if (shouldPaintClippingMask) { |
| 355 // Paint the border radius mask for the fragments. | 335 // Paint the border radius mask for the fragments. |
| 356 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags); | 336 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags); |
| 357 } | 337 } |
| 358 | 338 |
| 359 // Set subsequence not cacheable if the bounding box of this layer and desce ndants is not fully contained | 339 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 | 340 |
| 364 return result; | 341 return result; |
| 365 } | 342 } |
| 366 | 343 |
| 367 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect) | 344 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting Info& localPaintingInfo, const ClipRect& clipRect) |
| 368 { | 345 { |
| 369 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); | 346 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); |
| 370 } | 347 } |
| 371 | 348 |
| 372 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot ) | 349 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 Loading... | |
| 485 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintChild ren(unsigned childrenToVisit, GraphicsContext* context, const DeprecatedPaintLay erPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 462 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintChild ren(unsigned childrenToVisit, GraphicsContext* context, const DeprecatedPaintLay erPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
| 486 { | 463 { |
| 487 PaintResult result = FullyPainted; | 464 PaintResult result = FullyPainted; |
| 488 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) | 465 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) |
| 489 return result; | 466 return result; |
| 490 | 467 |
| 491 #if ENABLE(ASSERT) | 468 #if ENABLE(ASSERT) |
| 492 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); | 469 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); |
| 493 #endif | 470 #endif |
| 494 | 471 |
| 495 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; | 472 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); |
| 473 DeprecatedPaintLayerStackingNode* child = iterator.next(); | |
| 474 if (!child) | |
| 475 return result; | |
| 476 | |
| 477 DisplayItem::Type subsequenceType; | |
| 478 if (childrenToVisit == NegativeZOrderChildren) { | |
| 479 subsequenceType = DisplayItem::SubsequenceNegativeZOrder; | |
| 480 } else { | |
| 481 ASSERT(childrenToVisit == (NormalFlowChildren | PositiveZOrderChildren)) ; | |
| 482 subsequenceType = DisplayItem::SubsequenceNormalFlowAndPositiveZOrder; | |
| 483 } | |
| 484 | |
| 485 Optional<SubsequenceRecorder> subsequenceRecorder; | |
| 486 if (!paintingInfo.disableSubsequenceCache | |
| 487 && !(paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLaye rs) | |
| 488 && !(paintFlags & PaintLayerPaintingReflection) | |
| 489 && !(paintFlags & PaintLayerPaintingRootBackgroundOnly)) { | |
| 490 if (!m_paintLayer.needsRepaint() | |
| 491 && paintingInfo.scrollOffsetAccumulation == m_paintLayer.previousScr ollOffsetAccumulationForPainting() | |
| 492 && SubsequenceRecorder::useCachedSubsequenceIfPossible(*context, m_p aintLayer, subsequenceType)) | |
| 493 return result; | |
| 494 subsequenceRecorder.emplace(*context, m_paintLayer, subsequenceType); | |
| 495 } | |
| 496 | |
| 497 IntSize scrollOffsetAccumulationForChildren = paintingInfo.scrollOffsetAccum ulation; | |
| 496 if (m_paintLayer.layoutObject()->hasOverflowClip()) | 498 if (m_paintLayer.layoutObject()->hasOverflowClip()) |
| 497 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff set(); | 499 scrollOffsetAccumulationForChildren += m_paintLayer.layoutBox()->scrolle dContentOffset(); |
| 498 | 500 |
| 499 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode (), childrenToVisit); | 501 bool disableChildSubsequenceCache = !RuntimeEnabledFeatures::slimmingPaintV2 Enabled() |
|
pdr.
2015/09/30 23:36:54
Nit: Should this be !RuntimeEnabledFeatures::slimm
Xianzhu
2015/09/30 23:48:48
No. This is to workaround the effect of ancestor c
| |
| 500 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { | 502 && (m_paintLayer.layoutObject()->hasOverflowClip() || m_paintLayer.layou tObject()->hasClip()); |
| 503 | |
| 504 for (; child; child = iterator.next()) { | |
| 501 DeprecatedPaintLayerPainter childPainter(*child->layer()); | 505 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() | 506 // If this Layer should paint into its own backing or a grouped backing, that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() |
| 503 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). | 507 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). |
| 504 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags)) | 508 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain tFlags(), paintFlags)) |
| 505 continue; | 509 continue; |
| 506 | 510 |
| 507 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; | 511 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; |
| 508 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; | 512 childPaintingInfo.disableSubsequenceCache = disableChildSubsequenceCache ; |
| 513 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulationFor Children; | |
| 509 // Rare case: accumulate scroll offset of non-stacking-context ancestors up to m_paintLayer. | 514 // 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()) { | 515 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { |
| 511 if (parentLayer->layoutObject()->hasOverflowClip()) | 516 if (parentLayer->layoutObject()->hasOverflowClip()) |
| 512 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset(); | 517 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou tBox()->scrolledContentOffset(); |
| 513 } | 518 } |
| 514 | 519 |
| 515 if (childPainter.paintLayer(context, childPaintingInfo, paintFlags) == M aybeNotFullyPainted) | 520 if (childPainter.paintLayer(context, childPaintingInfo, paintFlags) == M aybeNotFullyPainted) |
| 516 result = MaybeNotFullyPainted; | 521 result = MaybeNotFullyPainted; |
| 517 } | 522 } |
| 523 | |
| 524 // Set subsequence not cacheable if the bounding box of this layer and desce ndants is not fully contained | |
| 525 // by paintRect, because later paintRect changes may expose new contents whi ch will need repainting. | |
| 526 if (result == MaybeNotFullyPainted && subsequenceRecorder) | |
| 527 subsequenceRecorder->setUncacheable(); | |
| 528 | |
| 518 return result; | 529 return result; |
| 519 } | 530 } |
| 520 | 531 |
| 521 // FIXME: inline this. | 532 // FIXME: inline this. |
| 522 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) | 533 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint LayerFlags paintFlags) |
| 523 { | 534 { |
| 524 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); | 535 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye rPaintingRootBackgroundOnly); |
| 525 } | 536 } |
| 526 | 537 |
| 527 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags) | 538 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai ntFlags globalPaintFlags, PaintLayerFlags paintFlags) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 694 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
| 684 return; | 695 return; |
| 685 | 696 |
| 686 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); | 697 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); |
| 687 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 698 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 688 | 699 |
| 689 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 700 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 690 } | 701 } |
| 691 | 702 |
| 692 } // namespace blink | 703 } // namespace blink |
| OLD | NEW |