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

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

Issue 1610233002: [Reland] Remove PaintInfo's paintingRoot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/layout/ClipPathOperation.h" 8 #include "core/layout/ClipPathOperation.h"
9 #include "core/layout/LayoutBlock.h" 9 #include "core/layout/LayoutBlock.h"
10 #include "core/layout/LayoutFrame.h" 10 #include "core/layout/LayoutFrame.h"
(...skipping 29 matching lines...) Expand all
40 { 40 {
41 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 41 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
42 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 42 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
43 // will do a full paintInvalidationForWholeLayoutObject(). 43 // will do a full paintInvalidationForWholeLayoutObject().
44 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement()) 44 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
45 return true; 45 return true;
46 46
47 return false; 47 return false;
48 } 48 }
49 49
50 void PaintLayerPainter::paint(GraphicsContext& context, const LayoutRect& damage Rect, const GlobalPaintFlags globalPaintFlags, LayoutObject* paintingRoot, Paint LayerFlags paintFlags) 50 void PaintLayerPainter::paint(GraphicsContext& context, const LayoutRect& damage Rect, const GlobalPaintFlags globalPaintFlags, PaintLayerFlags paintFlags)
51 { 51 {
52 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), globalPaintFlags, LayoutSize(), paintingRoot); 52 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), globalPaintFlags, LayoutSize());
53 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) 53 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags))
54 paintLayer(context, paintingInfo, paintFlags); 54 paintLayer(context, paintingInfo, paintFlags);
55 } 55 }
56 56
57 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject) 57 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject)
58 { 58 {
59 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip; 59 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip;
60 } 60 }
61 61
62 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext& co ntext, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 62 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext& co ntext, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 332 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
333 if (shouldPaintContent) { 333 if (shouldPaintContent) {
334 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi lar optimization for slimming paint v2. 334 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi lar optimization for slimming paint v2.
335 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); 335 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot);
336 if (!shouldPaintContent) 336 if (!shouldPaintContent)
337 result = MayBeClippedByPaintDirtyRect; 337 result = MayBeClippedByPaintDirtyRect;
338 } 338 }
339 } 339 }
340 340
341 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly; 341 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly;
342 // If this layer's layoutObject is a child of the paintingRoot, we paint unc onditionally, which
343 // is done by passing a nil paintingRoot down to our layoutObject (as if no paintingRoot was ever set).
344 // Else, our layout tree may or may not contain the painting root, so we pas s that root along
345 // so it will be tested against as we descend through the layoutObjects.
346 LayoutObject* paintingRootForLayoutObject = 0;
347 if (localPaintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescen dantOf(localPaintingInfo.paintingRoot))
348 paintingRootForLayoutObject = localPaintingInfo.paintingRoot;
349 342
350 { // Begin block for the lifetime of any filter. 343 { // Begin block for the lifetime of any filter.
351 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags, 344 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags,
352 rootRelativeBounds, rootRelativeBoundsComputed); 345 rootRelativeBounds, rootRelativeBoundsComputed);
353 346
354 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; 347 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
355 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 348 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
356 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) { 349 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) {
357 PaintChunkProperties properties(context.paintController().curren tPaintChunkProperties()); 350 PaintChunkProperties properties(context.paintController().curren tPaintChunkProperties());
358 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents()) 351 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents())
359 properties.transform = transform; 352 properties.transform = transform;
360 if (EffectPaintPropertyNode* effect = objectProperties->effect() ) 353 if (EffectPaintPropertyNode* effect = objectProperties->effect() )
361 properties.effect = effect; 354 properties.effect = effect;
362 scopedPaintChunkProperties.emplace(context.paintController(), pr operties); 355 scopedPaintChunkProperties.emplace(context.paintController(), pr operties);
363 } 356 }
364 } 357 }
365 358
366 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 359 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
367 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 360 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
368 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent; 361 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent;
369 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound; 362 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound;
370 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; 363 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
371 364
372 if (shouldPaintBackground) { 365 if (shouldPaintBackground) {
373 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 366 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect,
374 localPaintingInfo, paintingRootForLayoutObject, paintFlags); 367 localPaintingInfo, paintFlags);
375 } 368 }
376 369
377 if (shouldPaintNegZOrderList) { 370 if (shouldPaintNegZOrderList) {
378 if (paintChildren(NegativeZOrderChildren, context, paintingInfo, pai ntFlags) == MayBeClippedByPaintDirtyRect) 371 if (paintChildren(NegativeZOrderChildren, context, paintingInfo, pai ntFlags) == MayBeClippedByPaintDirtyRect)
379 result = MayBeClippedByPaintDirtyRect; 372 result = MayBeClippedByPaintDirtyRect;
380 } 373 }
381 374
382 if (shouldPaintOwnContents) { 375 if (shouldPaintOwnContents) {
383 paintForegroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 376 paintForegroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect,
384 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p aintFlags); 377 localPaintingInfo, selectionOnly, paintFlags);
385 } 378 }
386 379
387 if (shouldPaintOutline) 380 if (shouldPaintOutline)
388 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags); 381 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintFlags);
389 382
390 if (shouldPaintNormalFlowAndPosZOrderLists) { 383 if (shouldPaintNormalFlowAndPosZOrderLists) {
391 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte xt, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect) 384 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte xt, paintingInfo, paintFlags) == MayBeClippedByPaintDirtyRect)
392 result = MayBeClippedByPaintDirtyRect; 385 result = MayBeClippedByPaintDirtyRect;
393 } 386 }
394 387
395 if (shouldPaintOverlayScrollbars) 388 if (shouldPaintOverlayScrollbars)
396 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags); 389 paintOverflowControlsForFragments(layerFragments, context, localPain tingInfo, paintFlags);
397 } // FilterPainter block 390 } // FilterPainter block
398 391
399 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly; 392 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase) && shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn ly;
400 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly; 393 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping MaskPhase) && shouldPaintContent && !selectionOnly;
401 394
402 if (shouldPaintMask) 395 if (shouldPaintMask)
403 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti ngRootForLayoutObject, paintFlags); 396 paintMaskForFragments(layerFragments, context, localPaintingInfo, paintF lags);
404 if (shouldPaintClippingMask) { 397 if (shouldPaintClippingMask) {
405 // Paint the border radius mask for the fragments. 398 // Paint the border radius mask for the fragments.
406 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintingRootForLayoutObject, paintFlags); 399 paintChildClippingMaskForFragments(layerFragments, context, localPaintin gInfo, paintFlags);
407 } 400 }
408 401
409 if (subsequenceRecorder) 402 if (subsequenceRecorder)
410 m_paintLayer.setPreviousPaintResult(result); 403 m_paintLayer.setPreviousPaintResult(result);
411 return result; 404 return result;
412 } 405 }
413 406
414 bool PaintLayerPainter::needsToClip(const PaintLayerPaintingInfo& localPaintingI nfo, const ClipRect& clipRect) 407 bool PaintLayerPainter::needsToClip(const PaintLayerPaintingInfo& localPaintingI nfo, const ClipRect& clipRect)
415 { 408 {
416 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius(); 409 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa dius();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 transform.translateRight(roundedDelta.x(), roundedDelta.y()); 510 transform.translateRight(roundedDelta.x(), roundedDelta.y());
518 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); 511 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta);
519 512
520 // TODO(jbroman): Put the real transform origin here, instead of using a 513 // TODO(jbroman): Put the real transform origin here, instead of using a
521 // matrix with the origin baked in. 514 // matrix with the origin baked in.
522 FloatPoint3D transformOrigin; 515 FloatPoint3D transformOrigin;
523 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject( ), DisplayItem::Transform3DElementTransform, transform, transformOrigin); 516 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject( ), DisplayItem::Transform3DElementTransform, transform, transformOrigin);
524 517
525 // Now do a paint with the root layer shifted to be us. 518 // Now do a paint with the root layer shifted to be us.
526 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti ngInfo.globalPaintFlags(), 519 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti ngInfo.globalPaintFlags(),
527 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); 520 adjustedSubPixelAccumulation);
528 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH asClipPathClipping; 521 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH asClipPathClipping;
529 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai ntFlags, ForceSingleFragment); 522 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai ntFlags, ForceSingleFragment);
530 } 523 }
531 524
532 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre nToVisit, GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 525 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre nToVisit, GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
533 { 526 {
534 PaintResult result = FullyPainted; 527 PaintResult result = FullyPainted;
535 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 528 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
536 return result; 529 return result;
537 530
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 591
599 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) 592 if (needsToClip(localPaintingInfo, fragment.backgroundRect))
600 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags); 593 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags);
601 if (PaintLayerScrollableArea* scrollableArea = m_paintLayer.scrollableAr ea()) { 594 if (PaintLayerScrollableArea* scrollableArea = m_paintLayer.scrollableAr ea()) {
602 CullRect cullRect(pixelSnappedIntRect(fragment.backgroundRect.rect() )); 595 CullRect cullRect(pixelSnappedIntRect(fragment.backgroundRect.rect() ));
603 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), cullRect, true); 596 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), cullRect, true);
604 } 597 }
605 } 598 }
606 } 599 }
607 600
608 void PaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const PaintLaye rFragment& fragment, GraphicsContext& context, const ClipRect& clipRect, const P aintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 601 void PaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const PaintLaye rFragment& fragment, GraphicsContext& context, const ClipRect& clipRect, const P aintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, ClipState clipS tate)
609 { 602 {
610 ASSERT(m_paintLayer.isSelfPaintingLayer()); 603 ASSERT(m_paintLayer.isSelfPaintingLayer());
611 604
612 Optional<LayerClipRecorder> clipRecorder; 605 Optional<LayerClipRecorder> clipRecorder;
613 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 606 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
614 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 607 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
615 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 608 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
616 switch (phase) { 609 switch (phase) {
617 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self. 610 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self.
618 case PaintPhaseSelfOutlineOnly: 611 case PaintPhaseSelfOutlineOnly:
(...skipping 14 matching lines...) Expand all
633 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { 626 if (!paintingInfo.scrollOffsetAccumulation.isZero()) {
634 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders 627 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders
635 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder 628 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder
636 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this 629 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this
637 // layer, to get the same result as ScrollRecorder in BlockPainter. 630 // layer, to get the same result as ScrollRecorder in BlockPainter.
638 paintOffset += paintingInfo.scrollOffsetAccumulation; 631 paintOffset += paintingInfo.scrollOffsetAccumulation;
639 632
640 newCullRect.move(paintingInfo.scrollOffsetAccumulation); 633 newCullRect.move(paintingInfo.scrollOffsetAccumulation);
641 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, pai ntingInfo.scrollOffsetAccumulation); 634 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, pai ntingInfo.scrollOffsetAccumulation);
642 } 635 }
643 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, painti ngInfo.globalPaintFlags(), paintFlags, 636 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase,
644 paintingRootForLayoutObject, paintingInfo.rootLayer->layoutObject()); 637 paintingInfo.globalPaintFlags(), paintFlags, paintingInfo.rootLayer->lay outObject());
645 638
646 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 639 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
647 } 640 }
648 641
649 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context, 642 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments,
650 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo, 643 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
651 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 644 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
652 { 645 {
653 bool needsScope = layerFragments.size() > 1; 646 bool needsScope = layerFragments.size() > 1;
654 for (auto& fragment : layerFragments) { 647 for (auto& fragment : layerFragments) {
655 Optional<ScopeRecorder> scopeRecorder; 648 Optional<ScopeRecorder> scopeRecorder;
656 if (needsScope) 649 if (needsScope)
657 scopeRecorder.emplace(context); 650 scopeRecorder.emplace(context);
658 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, pa intFlags, HasNotClipped); 651 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped);
659 } 652 }
660 } 653 }
661 654
662 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context, 655 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments,
663 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo, 656 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
664 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags) 657 const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLa yerFlags paintFlags)
665 { 658 {
666 // Optimize clipping for the single fragment case. 659 // Optimize clipping for the single fragment case.
667 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 660 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
668 ClipState clipState = HasNotClipped; 661 ClipState clipState = HasNotClipped;
669 Optional<LayerClipRecorder> clipRecorder; 662 Optional<LayerClipRecorder> clipRecorder;
670 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 663 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
671 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags); 664 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags);
672 clipState = HasClipped; 665 clipState = HasClipped;
673 } 666 }
674 667
675 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 668 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
676 // interleaving of the fragments to work properly. 669 // interleaving of the fragments to work properly.
677 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseDescendantBlockBackgroundsOnly, layerFragments, 670 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseDescendantBlockBackgroundsOnly,
678 context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, cli pState); 671 layerFragments, context, localPaintingInfo, paintFlags, clipState);
679 672
680 if (!selectionOnly) { 673 if (!selectionOnly) {
681 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 674 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintFlags, clipState);
682 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipStat e); 675 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintFlags, clipState);
683 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnly, l ayerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFla gs, clipState); 676 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnly, l ayerFragments, context, localPaintingInfo, paintFlags, clipState);
684 } 677 }
685 } 678 }
686 679
687 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, c onst PaintLayerFragments& layerFragments, GraphicsContext& context, 680 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase,
688 const PaintLayerPaintingInfo& localPaintingInfo, LayoutObject* paintingRootF orLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 681 const PaintLayerFragments& layerFragments, GraphicsContext& context,
682 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags, ClipState clipState)
689 { 683 {
690 bool needsScope = layerFragments.size() > 1; 684 bool needsScope = layerFragments.size() > 1;
691 for (auto& fragment : layerFragments) { 685 for (auto& fragment : layerFragments) {
692 if (!fragment.foregroundRect.isEmpty()) { 686 if (!fragment.foregroundRect.isEmpty()) {
693 Optional<ScopeRecorder> scopeRecorder; 687 Optional<ScopeRecorder> scopeRecorder;
694 if (needsScope) 688 if (needsScope)
695 scopeRecorder.emplace(context); 689 scopeRecorder.emplace(context);
696 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 690 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintFlags, clipState);
697 } 691 }
698 } 692 }
699 } 693 }
700 694
701 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintin gInfo, 695 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments,
702 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 696 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags)
703 { 697 {
704 bool needsScope = layerFragments.size() > 1; 698 bool needsScope = layerFragments.size() > 1;
705 for (auto& fragment : layerFragments) { 699 for (auto& fragment : layerFragments) {
706 if (!fragment.backgroundRect.isEmpty()) { 700 if (!fragment.backgroundRect.isEmpty()) {
707 Optional<ScopeRecorder> scopeRecorder; 701 Optional<ScopeRecorder> scopeRecorder;
708 if (needsScope) 702 if (needsScope)
709 scopeRecorder.emplace(context); 703 scopeRecorder.emplace(context);
710 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintF lags, HasNotClipped); 704 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped);
711 } 705 }
712 } 706 }
713 } 707 }
714 708
715 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingIn fo, 709 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments,
716 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 710 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags)
717 { 711 {
718 bool needsScope = layerFragments.size() > 1; 712 bool needsScope = layerFragments.size() > 1;
719 for (auto& fragment : layerFragments) { 713 for (auto& fragment : layerFragments) {
720 Optional<ScopeRecorder> scopeRecorder; 714 Optional<ScopeRecorder> scopeRecorder;
721 if (needsScope) 715 if (needsScope)
722 scopeRecorder.emplace(context); 716 scopeRecorder.emplace(context);
723 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, HasNotCli pped); 717 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintFlags, HasNotClipped);
724 } 718 }
725 } 719 }
726 720
727 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& lo calPaintingInfo, 721 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments,
728 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 722 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags)
729 { 723 {
730 bool needsScope = layerFragments.size() > 1; 724 bool needsScope = layerFragments.size() > 1;
731 for (auto& fragment: layerFragments) { 725 for (auto& fragment: layerFragments) {
732 Optional<ScopeRecorder> scopeRecorder; 726 Optional<ScopeRecorder> scopeRecorder;
733 if (needsScope) 727 if (needsScope)
734 scopeRecorder.emplace(context); 728 scopeRecorder.emplace(context);
735 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, H asNotClipped); 729 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintFlags, HasNotClipped);
736 } 730 }
737 } 731 }
738 732
739 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags, LayoutObject* painting Root) 733 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags)
740 { 734 {
741 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 735 if (!m_paintLayer.containsDirtyOverlayScrollbars())
742 return; 736 return;
743 737
744 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize(), paintingRoot); 738 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize());
745 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 739 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
746 740
747 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 741 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
748 } 742 }
749 743
750 } // namespace blink 744 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerPainter.h ('k') | third_party/WebKit/Source/core/paint/ReplacedPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698