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

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

Issue 2022563002: Remove display item scope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/FrameView.h" 7 #include "core/frame/FrameView.h"
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"
11 #include "core/layout/LayoutView.h" 11 #include "core/layout/LayoutView.h"
12 #include "core/layout/svg/LayoutSVGResourceClipper.h" 12 #include "core/layout/svg/LayoutSVGResourceClipper.h"
13 #include "core/page/Page.h" 13 #include "core/page/Page.h"
14 #include "core/paint/FilterPainter.h" 14 #include "core/paint/FilterPainter.h"
15 #include "core/paint/LayerClipRecorder.h" 15 #include "core/paint/LayerClipRecorder.h"
16 #include "core/paint/ObjectPaintProperties.h" 16 #include "core/paint/ObjectPaintProperties.h"
17 #include "core/paint/PaintInfo.h" 17 #include "core/paint/PaintInfo.h"
18 #include "core/paint/PaintLayer.h" 18 #include "core/paint/PaintLayer.h"
19 #include "core/paint/SVGClipPainter.h" 19 #include "core/paint/SVGClipPainter.h"
20 #include "core/paint/ScopeRecorder.h"
21 #include "core/paint/ScrollRecorder.h" 20 #include "core/paint/ScrollRecorder.h"
22 #include "core/paint/ScrollableAreaPainter.h" 21 #include "core/paint/ScrollableAreaPainter.h"
23 #include "core/paint/Transform3DRecorder.h" 22 #include "core/paint/Transform3DRecorder.h"
24 #include "platform/RuntimeEnabledFeatures.h" 23 #include "platform/RuntimeEnabledFeatures.h"
25 #include "platform/geometry/FloatPoint3D.h" 24 #include "platform/geometry/FloatPoint3D.h"
26 #include "platform/graphics/GraphicsLayer.h" 25 #include "platform/graphics/GraphicsLayer.h"
27 #include "platform/graphics/paint/ClipPathRecorder.h" 26 #include "platform/graphics/paint/ClipPathRecorder.h"
28 #include "platform/graphics/paint/ClipRecorder.h" 27 #include "platform/graphics/paint/ClipRecorder.h"
29 #include "platform/graphics/paint/CompositingRecorder.h" 28 #include "platform/graphics/paint/CompositingRecorder.h"
29 #include "platform/graphics/paint/DisplayItemCacheSkipper.h"
30 #include "platform/graphics/paint/PaintChunkProperties.h" 30 #include "platform/graphics/paint/PaintChunkProperties.h"
31 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" 31 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
32 #include "platform/graphics/paint/SubsequenceRecorder.h" 32 #include "platform/graphics/paint/SubsequenceRecorder.h"
33 #include "platform/graphics/paint/Transform3DDisplayItem.h" 33 #include "platform/graphics/paint/Transform3DDisplayItem.h"
34 #include "wtf/Optional.h" 34 #include "wtf/Optional.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer) 38 static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer)
39 { 39 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContentsAndReflectio n(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLay erFlags paintFlags, FragmentPolicy fragmentPolicy) 101 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContentsAndReflectio n(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLay erFlags paintFlags, FragmentPolicy fragmentPolicy)
102 { 102 {
103 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant()); 103 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant());
104 104
105 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; 105 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ;
106 106
107 PaintResult result = FullyPainted; 107 PaintResult result = FullyPainted;
108 108
109 // Paint the reflection first if we have one. 109 // Paint the reflection first if we have one.
110 if (m_paintLayer.reflectionInfo() && !RuntimeEnabledFeatures::cssBoxReflectF ilterEnabled()) { 110 if (m_paintLayer.reflectionInfo() && !RuntimeEnabledFeatures::cssBoxReflectF ilterEnabled()) {
111 ScopeRecorder scopeRecorder(context); 111 DisplayItemCacheSkipper skipper(context);
112 if (m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPai ntFlags) == MayBeClippedByPaintDirtyRect) 112 if (m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPai ntFlags) == MayBeClippedByPaintDirtyRect)
113 result = MayBeClippedByPaintDirtyRect; 113 result = MayBeClippedByPaintDirtyRect;
114 } 114 }
115 115
116 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; 116 localPaintFlags |= PaintLayerPaintingCompositingAllPhases;
117 if (paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolic y) == MayBeClippedByPaintDirtyRect) 117 if (paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolic y) == MayBeClippedByPaintDirtyRect)
118 result = MayBeClippedByPaintDirtyRect; 118 result = MayBeClippedByPaintDirtyRect;
119 119
120 return result; 120 return result;
121 } 121 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } else { 509 } else {
510 // We don't need to collect any fragments in the regular way here. We ha ve already 510 // We don't need to collect any fragments in the regular way here. We ha ve already
511 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this 511 // calculated a clip rectangle for the ancestry if it was needed, and cl ipping this
512 // layer is something that can be done further down the path, when the t ransform has 512 // layer is something that can be done further down the path, when the t ransform has
513 // been applied. 513 // been applied.
514 PaintLayerFragment fragment; 514 PaintLayerFragment fragment;
515 fragment.backgroundRect = paintingInfo.paintDirtyRect; 515 fragment.backgroundRect = paintingInfo.paintDirtyRect;
516 fragments.append(fragment); 516 fragments.append(fragment);
517 } 517 }
518 518
519 bool needsScope = fragments.size() > 1; 519 Optional<DisplayItemCacheSkipper> cacheSkipper;
520 if (fragments.size() > 1)
521 cacheSkipper.emplace(context);
522
520 PaintResult result = FullyPainted; 523 PaintResult result = FullyPainted;
521 for (const auto& fragment : fragments) { 524 for (const auto& fragment : fragments) {
522 Optional<ScopeRecorder> scopeRecorder;
523 if (needsScope)
524 scopeRecorder.emplace(context);
525 Optional<LayerClipRecorder> clipRecorder; 525 Optional<LayerClipRecorder> clipRecorder;
526 if (parentLayer) { 526 if (parentLayer) {
527 ClipRect clipRectForFragment(ancestorBackgroundClipRect); 527 ClipRect clipRectForFragment(ancestorBackgroundClipRect);
528 // A fixed-position object is repeated on every page, but if it is c lipped by an ancestor layer then 528 // A fixed-position object is repeated on every page, but if it is c lipped by an ancestor layer then
529 // the repetitions are clipped out. 529 // the repetitions are clipped out.
530 if (!isFixedPosObjectInPagedMedia) 530 if (!isFixedPosObjectInPagedMedia)
531 clipRectForFragment.moveBy(fragment.paginationOffset); 531 clipRectForFragment.moveBy(fragment.paginationOffset);
532 clipRectForFragment.intersect(fragment.backgroundRect); 532 clipRectForFragment.intersect(fragment.backgroundRect);
533 if (clipRectForFragment.isEmpty()) 533 if (clipRectForFragment.isEmpty())
534 continue; 534 continue;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTr ansform()) 627 || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTr ansform())
628 || paintForFixedRootBackground(&m_paintLayer, paintFlags); 628 || paintForFixedRootBackground(&m_paintLayer, paintFlags);
629 } 629 }
630 630
631 void PaintLayerPainter::paintOverflowControlsForFragments(const PaintLayerFragme nts& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& loc alPaintingInfo, PaintLayerFlags paintFlags) 631 void PaintLayerPainter::paintOverflowControlsForFragments(const PaintLayerFragme nts& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& loc alPaintingInfo, PaintLayerFlags paintFlags)
632 { 632 {
633 PaintLayerScrollableArea* scrollableArea = m_paintLayer.getScrollableArea(); 633 PaintLayerScrollableArea* scrollableArea = m_paintLayer.getScrollableArea();
634 if (!scrollableArea) 634 if (!scrollableArea)
635 return; 635 return;
636 636
637 bool needsScope = layerFragments.size() > 1; 637 Optional<DisplayItemCacheSkipper> cacheSkipper;
638 if (layerFragments.size() > 1)
639 cacheSkipper.emplace(context);
640
638 for (auto& fragment : layerFragments) { 641 for (auto& fragment : layerFragments) {
639 Optional<ScopeRecorder> scopeRecorder;
640 if (needsScope)
641 scopeRecorder.emplace(context);
642
643 // We need to apply the same clips and transforms that 642 // We need to apply the same clips and transforms that
644 // paintFragmentWithPhase would have. 643 // paintFragmentWithPhase would have.
645 LayoutRect cullRect = fragment.backgroundRect.rect(); 644 LayoutRect cullRect = fragment.backgroundRect.rect();
646 645
647 Optional<LayerClipRecorder> clipRecorder; 646 Optional<LayerClipRecorder> clipRecorder;
648 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) 647 if (needsToClip(localPaintingInfo, fragment.backgroundRect))
649 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags); 648 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags);
650 649
651 Optional<ScrollRecorder> scrollRecorder; 650 Optional<ScrollRecorder> scrollRecorder;
652 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !localPaintingI nfo.scrollOffsetAccumulation.isZero()) { 651 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !localPaintingI nfo.scrollOffsetAccumulation.isZero()) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, 706 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase,
708 paintingInfo.getGlobalPaintFlags(), paintFlags, paintingInfo.rootLayer-> layoutObject()); 707 paintingInfo.getGlobalPaintFlags(), paintFlags, paintingInfo.rootLayer-> layoutObject());
709 708
710 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 709 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
711 } 710 }
712 711
713 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, 712 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments,
714 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, 713 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
715 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 714 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
716 { 715 {
717 bool needsScope = layerFragments.size() > 1; 716 Optional<DisplayItemCacheSkipper> cacheSkipper;
718 for (auto& fragment : layerFragments) { 717 if (layerFragments.size() > 1)
719 Optional<ScopeRecorder> scopeRecorder; 718 cacheSkipper.emplace(context);
720 if (needsScope) 719
721 scopeRecorder.emplace(context); 720 for (auto& fragment : layerFragments)
722 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped); 721 paintFragmentWithPhase(PaintPhaseSelfBlockBackgroundOnly, fragment, cont ext, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped);
723 }
724 } 722 }
725 723
726 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, 724 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments,
727 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, 725 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
728 const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLa yerFlags paintFlags) 726 const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLa yerFlags paintFlags)
729 { 727 {
730 // Optimize clipping for the single fragment case. 728 // Optimize clipping for the single fragment case.
731 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 729 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
732 ClipState clipState = HasNotClipped; 730 ClipState clipState = HasNotClipped;
733 Optional<LayerClipRecorder> clipRecorder; 731 Optional<LayerClipRecorder> clipRecorder;
(...skipping 14 matching lines...) Expand all
748 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintFlags, clipState); 746 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintFlags, clipState);
749 if (!RuntimeEnabledFeatures::paintOptimizationsEnabled() || m_paintLayer .needsPaintPhaseDescendantOutlines()) 747 if (!RuntimeEnabledFeatures::paintOptimizationsEnabled() || m_paintLayer .needsPaintPhaseDescendantOutlines())
750 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnl y, layerFragments, context, localPaintingInfo, paintFlags, clipState); 748 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantOutlinesOnl y, layerFragments, context, localPaintingInfo, paintFlags, clipState);
751 } 749 }
752 } 750 }
753 751
754 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, 752 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase,
755 const PaintLayerFragments& layerFragments, GraphicsContext& context, 753 const PaintLayerFragments& layerFragments, GraphicsContext& context,
756 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags, ClipState clipState) 754 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags, ClipState clipState)
757 { 755 {
758 bool needsScope = layerFragments.size() > 1; 756 Optional<DisplayItemCacheSkipper> cacheSkipper;
757 if (layerFragments.size() > 1)
758 cacheSkipper.emplace(context);
759
759 for (auto& fragment : layerFragments) { 760 for (auto& fragment : layerFragments) {
760 if (!fragment.foregroundRect.isEmpty()) { 761 if (!fragment.foregroundRect.isEmpty())
761 Optional<ScopeRecorder> scopeRecorder;
762 if (needsScope)
763 scopeRecorder.emplace(context);
764 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintFlags, clipState); 762 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintFlags, clipState);
765 }
766 } 763 }
767 } 764 }
768 765
769 void PaintLayerPainter::paintSelfOutlineForFragments(const PaintLayerFragments& layerFragments, 766 void PaintLayerPainter::paintSelfOutlineForFragments(const PaintLayerFragments& layerFragments,
770 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags) 767 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags)
771 { 768 {
772 bool needsScope = layerFragments.size() > 1; 769 Optional<DisplayItemCacheSkipper> cacheSkipper;
770 if (layerFragments.size() > 1)
771 cacheSkipper.emplace(context);
772
773 for (auto& fragment : layerFragments) { 773 for (auto& fragment : layerFragments) {
774 if (!fragment.backgroundRect.isEmpty()) { 774 if (!fragment.backgroundRect.isEmpty())
775 Optional<ScopeRecorder> scopeRecorder;
776 if (needsScope)
777 scopeRecorder.emplace(context);
778 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped); 775 paintFragmentWithPhase(PaintPhaseSelfOutlineOnly, fragment, context, fragment.backgroundRect, localPaintingInfo, paintFlags, HasNotClipped);
779 }
780 } 776 }
781 } 777 }
782 778
783 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, 779 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments,
784 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags) 780 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags)
785 { 781 {
786 bool needsScope = layerFragments.size() > 1; 782 Optional<DisplayItemCacheSkipper> cacheSkipper;
787 for (auto& fragment : layerFragments) { 783 if (layerFragments.size() > 1)
788 Optional<ScopeRecorder> scopeRecorder; 784 cacheSkipper.emplace(context);
789 if (needsScope) 785
790 scopeRecorder.emplace(context); 786 for (auto& fragment : layerFragments)
791 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintFlags, HasNotClipped); 787 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintFlags, HasNotClipped);
792 }
793 } 788 }
794 789
795 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments, 790 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments,
796 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags) 791 GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingInfo, P aintLayerFlags paintFlags)
797 { 792 {
798 bool needsScope = layerFragments.size() > 1; 793 Optional<DisplayItemCacheSkipper> cacheSkipper;
799 for (auto& fragment: layerFragments) { 794 if (layerFragments.size() > 1)
800 Optional<ScopeRecorder> scopeRecorder; 795 cacheSkipper.emplace(context);
801 if (needsScope) 796
802 scopeRecorder.emplace(context); 797 for (auto& fragment: layerFragments)
803 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintFlags, HasNotClipped); 798 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintFlags, HasNotClipped);
804 }
805 } 799 }
806 800
807 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags) 801 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags)
808 { 802 {
809 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 803 if (!m_paintLayer.containsDirtyOverlayScrollbars())
810 return; 804 return;
811 805
812 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); 806 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize());
813 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 807 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
814 808
815 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 809 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
816 } 810 }
817 811
818 } // namespace blink 812 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/paint/ScopeRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698