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

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

Issue 1584903002: Improvement handling of background and outline paint phases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PaintPhaseRename
Patch Set: Fix TablePainter and TableRowPainter 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
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) 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)
609 { 609 {
610 ASSERT(m_paintLayer.isSelfPaintingLayer()); 610 ASSERT(m_paintLayer.isSelfPaintingLayer());
611 611
612 Optional<LayerClipRecorder> clipRecorder; 612 Optional<LayerClipRecorder> clipRecorder;
613 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 613 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
614 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 614 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
615 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 615 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
616 switch (phase) { 616 switch (phase) {
617 case PaintPhaseSelfBlockBackground: // Background painting will handle c lipping to self. 617 case PaintPhaseSelfBlockBackgroundOnly: // Background painting will hand le clipping to self.
618 case PaintPhaseSelfOutline: 618 case PaintPhaseSelfOutlineOnly:
619 case PaintPhaseMask: // Mask painting will handle clipping to self. 619 case PaintPhaseMask: // Mask painting will handle clipping to self.
620 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 620 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
621 break; 621 break;
622 default: 622 default:
623 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 623 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
624 break; 624 break;
625 } 625 }
626 626
627 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); 627 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule);
628 } 628 }
(...skipping 19 matching lines...) Expand all
648 648
649 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context, 649 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context,
650 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo, 650 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo,
651 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 651 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
652 { 652 {
653 bool needsScope = layerFragments.size() > 1; 653 bool needsScope = layerFragments.size() > 1;
654 for (auto& fragment : layerFragments) { 654 for (auto& fragment : layerFragments) {
655 Optional<ScopeRecorder> scopeRecorder; 655 Optional<ScopeRecorder> scopeRecorder;
656 if (needsScope) 656 if (needsScope)
657 scopeRecorder.emplace(context); 657 scopeRecorder.emplace(context);
658 paintFragmentWithPhase(PaintPhaseSelfBlockBackground, fragment, context, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintF lags, HasNotClipped); 658 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, pa intFlags, HasNotClipped);
659 } 659 }
660 } 660 }
661 661
662 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context, 662 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context,
663 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo, 663 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo,
664 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags) 664 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags)
665 { 665 {
666 // Optimize clipping for the single fragment case. 666 // Optimize clipping for the single fragment case.
667 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 667 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
668 ClipState clipState = HasNotClipped; 668 ClipState clipState = HasNotClipped;
669 Optional<LayerClipRecorder> clipRecorder; 669 Optional<LayerClipRecorder> clipRecorder;
670 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 670 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); 671 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags);
672 clipState = HasClipped; 672 clipState = HasClipped;
673 } 673 }
674 674
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 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
676 // interleaving of the fragments to work properly. 676 // interleaving of the fragments to work properly.
677 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseDescendantBlockBackgrounds, layerFragments, 677 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseDescendantBlockBackgroundsOnly, layerFragments,
678 context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, cli pState); 678 context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, cli pState);
679 679
680 if (!selectionOnly) { 680 if (!selectionOnly) {
681 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 681 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState);
682 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipStat e); 682 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipStat e);
683 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlines, layer Fragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 683 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnly, l ayerFragments, context, localPaintingInfo, paintingRootForLayoutObject, paintFla gs, clipState);
684 } 684 }
685 } 685 }
686 686
687 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, c onst PaintLayerFragments& layerFragments, GraphicsContext& context, 687 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, c onst PaintLayerFragments& layerFragments, GraphicsContext& context,
688 const PaintLayerPaintingInfo& localPaintingInfo, LayoutObject* paintingRootF orLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 688 const PaintLayerPaintingInfo& localPaintingInfo, LayoutObject* paintingRootF orLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
689 { 689 {
690 bool needsScope = layerFragments.size() > 1; 690 bool needsScope = layerFragments.size() > 1;
691 for (auto& fragment : layerFragments) { 691 for (auto& fragment : layerFragments) {
692 if (!fragment.foregroundRect.isEmpty()) { 692 if (!fragment.foregroundRect.isEmpty()) {
693 Optional<ScopeRecorder> scopeRecorder; 693 Optional<ScopeRecorder> scopeRecorder;
694 if (needsScope) 694 if (needsScope)
695 scopeRecorder.emplace(context); 695 scopeRecorder.emplace(context);
696 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 696 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState);
697 } 697 }
698 } 698 }
699 } 699 }
700 700
701 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintin gInfo, 701 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintin gInfo,
702 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 702 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
703 { 703 {
704 bool needsScope = layerFragments.size() > 1; 704 bool needsScope = layerFragments.size() > 1;
705 for (auto& fragment : layerFragments) { 705 for (auto& fragment : layerFragments) {
706 if (!fragment.backgroundRect.isEmpty()) { 706 if (!fragment.backgroundRect.isEmpty()) {
707 Optional<ScopeRecorder> scopeRecorder; 707 Optional<ScopeRecorder> scopeRecorder;
708 if (needsScope) 708 if (needsScope)
709 scopeRecorder.emplace(context); 709 scopeRecorder.emplace(context);
710 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags , HasNotClipped); 710 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintF lags, HasNotClipped);
711 } 711 }
712 } 712 }
713 } 713 }
714 714
715 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingIn fo, 715 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingIn fo,
716 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 716 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
717 { 717 {
718 bool needsScope = layerFragments.size() > 1; 718 bool needsScope = layerFragments.size() > 1;
719 for (auto& fragment : layerFragments) { 719 for (auto& fragment : layerFragments) {
720 Optional<ScopeRecorder> scopeRecorder; 720 Optional<ScopeRecorder> scopeRecorder;
(...skipping 20 matching lines...) Expand all
741 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 741 if (!m_paintLayer.containsDirtyOverlayScrollbars())
742 return; 742 return;
743 743
744 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize(), paintingRoot); 744 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize(), paintingRoot);
745 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 745 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
746 746
747 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 747 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
748 } 748 }
749 749
750 } // namespace blink 750 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698