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

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

Issue 1512803004: Use refs for GraphicsContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Created 5 years 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 "config.h" 5 #include "config.h"
6 #include "core/paint/PaintLayerPainter.h" 6 #include "core/paint/PaintLayerPainter.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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 { 42 {
43 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 43 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
44 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 44 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
45 // will do a full paintInvalidationForWholeLayoutObject(). 45 // will do a full paintInvalidationForWholeLayoutObject().
46 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement()) 46 if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && ! layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
47 return true; 47 return true;
48 48
49 return false; 49 return false;
50 } 50 }
51 51
52 void PaintLayerPainter::paint(GraphicsContext* context, const LayoutRect& damage Rect, const GlobalPaintFlags globalPaintFlags, LayoutObject* paintingRoot, Paint LayerFlags paintFlags) 52 void PaintLayerPainter::paint(GraphicsContext& context, const LayoutRect& damage Rect, const GlobalPaintFlags globalPaintFlags, LayoutObject* paintingRoot, Paint LayerFlags paintFlags)
53 { 53 {
54 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), globalPaintFlags, LayoutSize(), paintingRoot); 54 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), globalPaintFlags, LayoutSize(), paintingRoot);
55 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) 55 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags))
56 paintLayer(context, paintingInfo, paintFlags); 56 paintLayer(context, paintingInfo, paintFlags);
57 } 57 }
58 58
59 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject) 59 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const LayoutObject* layoutObject)
60 { 60 {
61 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip; 61 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO verflowClip : RespectOverflowClip;
62 } 62 }
63 63
64 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext* co ntext, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 64 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext& co ntext, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
65 { 65 {
66 // https://code.google.com/p/chromium/issues/detail?id=343772 66 // https://code.google.com/p/chromium/issues/detail?id=343772
67 DisableCompositingQueryAsserts disabler; 67 DisableCompositingQueryAsserts disabler;
68 68
69 if (m_paintLayer.compositingState() != NotComposited) { 69 if (m_paintLayer.compositingState() != NotComposited) {
70 if (paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLayer s) { 70 if (paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLayer s) {
71 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? Th at's for printing and drag-image. 71 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? Th at's for printing and drag-image.
72 // FIXME: why isn't the code here global, as opposed to being set on each paintLayer() call? 72 // FIXME: why isn't the code here global, as opposed to being set on each paintLayer() call?
73 paintFlags |= PaintLayerUncachedClipRects; 73 paintFlags |= PaintLayerUncachedClipRects;
74 } 74 }
(...skipping 11 matching lines...) Expand all
86 if (m_paintLayer.layoutObject()->isLayoutPart() && toLayoutPart(m_paintLayer .layoutObject())->isThrottledFrameView()) 86 if (m_paintLayer.layoutObject()->isLayoutPart() && toLayoutPart(m_paintLayer .layoutObject())->isThrottledFrameView())
87 return FullyPainted; 87 return FullyPainted;
88 88
89 // If this layer is totally invisible then there is nothing to paint. 89 // If this layer is totally invisible then there is nothing to paint.
90 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()- >hasBackdropFilter()) 90 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()- >hasBackdropFilter())
91 return FullyPainted; 91 return FullyPainted;
92 92
93 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags())) 93 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags()))
94 paintFlags |= PaintLayerHaveTransparency; 94 paintFlags |= PaintLayerHaveTransparency;
95 95
96 LayerFixedPositionRecorder fixedPositionRecorder(*context, *m_paintLayer.lay outObject()); 96 LayerFixedPositionRecorder fixedPositionRecorder(context, *m_paintLayer.layo utObject());
97 97
98 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice. 98 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice.
99 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p aintFlags & PaintLayerAppliedTransform)) 99 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p aintFlags & PaintLayerAppliedTransform))
100 return paintLayerWithTransform(context, paintingInfo, paintFlags); 100 return paintLayerWithTransform(context, paintingInfo, paintFlags);
101 101
102 return paintLayerContentsAndReflection(context, paintingInfo, paintFlags); 102 return paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
103 } 103 }
104 104
105 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContentsAndReflectio n(GraphicsContext* context, const PaintLayerPaintingInfo& paintingInfo, PaintLay erFlags paintFlags, FragmentPolicy fragmentPolicy) 105 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContentsAndReflectio n(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLay erFlags paintFlags, FragmentPolicy fragmentPolicy)
106 { 106 {
107 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant()); 107 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant());
108 108
109 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; 109 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ;
110 110
111 PaintResult result = FullyPainted; 111 PaintResult result = FullyPainted;
112 112
113 // Paint the reflection first if we have one. 113 // Paint the reflection first if we have one.
114 if (m_paintLayer.reflectionInfo()) { 114 if (m_paintLayer.reflectionInfo()) {
115 ScopeRecorder scopeRecorder(*context); 115 ScopeRecorder scopeRecorder(context);
116 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl ags); 116 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl ags);
117 result = MaybeNotFullyPainted; 117 result = MaybeNotFullyPainted;
118 } 118 }
119 119
120 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; 120 localPaintFlags |= PaintLayerPaintingCompositingAllPhases;
121 if (paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolic y) == MaybeNotFullyPainted) 121 if (paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolic y) == MaybeNotFullyPainted)
122 result = MaybeNotFullyPainted; 122 result = MaybeNotFullyPainted;
123 123
124 return result; 124 return result;
125 } 125 }
126 126
127 class ClipPathHelper { 127 class ClipPathHelper {
128 public: 128 public:
129 ClipPathHelper(GraphicsContext* context, const PaintLayer& paintLayer, Paint LayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBounds, bool& rootRelat iveBoundsComputed, 129 ClipPathHelper(GraphicsContext& context, const PaintLayer& paintLayer, Paint LayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBounds, bool& rootRelat iveBoundsComputed,
130 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) 130 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags)
131 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) 131 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context)
132 { 132 {
133 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); 133 const ComputedStyle& style = paintLayer.layoutObject()->styleRef();
134 134
135 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container. 135 // Clip-path, like border radius, must not be applied to the contents of a composited-scrolling container.
136 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the 136 // It must, however, still be applied to the mask layer, so that the com positor can properly mask the
137 // scrolling contents and scrollbars. 137 // scrolling contents and scrollbars.
138 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) 138 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)))
139 return; 139 return;
140 140
141 m_clipperState = SVGClipPainter::ClipperNotApplied; 141 m_clipperState = SVGClipPainter::ClipperNotApplied;
142 142
143 paintingInfo.ancestorHasClipPathClipping = true; 143 paintingInfo.ancestorHasClipPathClipping = true;
144 144
145 ASSERT(style.clipPath()); 145 ASSERT(style.clipPath());
146 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { 146 if (style.clipPath()->type() == ClipPathOperation::SHAPE) {
147 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl ipPath()); 147 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl ipPath());
148 if (clipPath->isValid()) { 148 if (clipPath->isValid()) {
149 if (!rootRelativeBoundsComputed) { 149 if (!rootRelativeBoundsComputed) {
150 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot); 150 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot);
151 rootRelativeBoundsComputed = true; 151 rootRelativeBoundsComputed = true;
152 } 152 }
153 m_clipPathRecorder.emplace(*context, *paintLayer.layoutObject(), clipPath->path(FloatRect(rootRelativeBounds))); 153 m_clipPathRecorder.emplace(context, *paintLayer.layoutObject(), clipPath->path(FloatRect(rootRelativeBounds)));
154 } 154 }
155 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { 155 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) {
156 ReferenceClipPathOperation* referenceClipPathOperation = toReference ClipPathOperation(style.clipPath()); 156 ReferenceClipPathOperation* referenceClipPathOperation = toReference ClipPathOperation(style.clipPath());
157 Document& document = paintLayer.layoutObject()->document(); 157 Document& document = paintLayer.layoutObject()->document();
158 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405) 158 // FIXME: It doesn't work with forward or external SVG references (h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
159 Element* element = document.getElementById(referenceClipPathOperatio n->fragment()); 159 Element* element = document.getElementById(referenceClipPathOperatio n->fragment());
160 if (isSVGClipPathElement(element) && element->layoutObject()) { 160 if (isSVGClipPathElement(element) && element->layoutObject()) {
161 if (!rootRelativeBoundsComputed) { 161 if (!rootRelativeBoundsComputed) {
162 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot); 162 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding ReflectionAndStackingChildren(offsetFromRoot);
163 rootRelativeBoundsComputed = true; 163 rootRelativeBoundsComputed = true;
(...skipping 12 matching lines...) Expand all
176 ~ClipPathHelper() 176 ~ClipPathHelper()
177 { 177 {
178 if (m_resourceClipper) 178 if (m_resourceClipper)
179 SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layout Object(), m_context, m_clipperState); 179 SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layout Object(), m_context, m_clipperState);
180 } 180 }
181 private: 181 private:
182 LayoutSVGResourceClipper* m_resourceClipper; 182 LayoutSVGResourceClipper* m_resourceClipper;
183 Optional<ClipPathRecorder> m_clipPathRecorder; 183 Optional<ClipPathRecorder> m_clipPathRecorder;
184 SVGClipPainter::ClipperState m_clipperState; 184 SVGClipPainter::ClipperState m_clipperState;
185 const PaintLayer& m_paintLayer; 185 const PaintLayer& m_paintLayer;
186 GraphicsContext* m_context; 186 GraphicsContext& m_context;
187 }; 187 };
188 188
189 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon text* context, const PaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags pa intFlags, FragmentPolicy fragmentPolicy) 189 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents(GraphicsCon text& context, const PaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags pa intFlags, FragmentPolicy fragmentPolicy)
190 { 190 {
191 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant()); 191 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant());
192 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); 192 ASSERT(!(paintFlags & PaintLayerAppliedTransform));
193 193
194 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); 194 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer();
195 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars; 195 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr ollbars;
196 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing ScrollingPhase; 196 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing ScrollingPhase;
197 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi tingForegroundPhase; 197 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi tingForegroundPhase;
198 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi tingBackgroundPhase; 198 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi tingBackgroundPhase;
199 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon tents; 199 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon tents;
(...skipping 29 matching lines...) Expand all
229 ClipRects* clipRects = m_paintLayer.clipper().paintingClipRects(painting InfoArg.rootLayer, respectOverflowClip, subpixelAccumulation); 229 ClipRects* clipRects = m_paintLayer.clipper().paintingClipRects(painting InfoArg.rootLayer, respectOverflowClip, subpixelAccumulation);
230 if (!m_paintLayer.needsRepaint()) { 230 if (!m_paintLayer.needsRepaint()) {
231 ClipRects* previousClipRects = m_paintLayer.previousPaintingClipRect s(); 231 ClipRects* previousClipRects = m_paintLayer.previousPaintingClipRect s();
232 if (clipRects != previousClipRects && (!clipRects || !previousClipRe cts || *clipRects != *previousClipRects)) 232 if (clipRects != previousClipRects && (!clipRects || !previousClipRe cts || *clipRects != *previousClipRects))
233 clipRectsChanged = true; 233 clipRectsChanged = true;
234 } 234 }
235 m_paintLayer.setPreviousPaintingClipRects(clipRects); 235 m_paintLayer.setPreviousPaintingClipRects(clipRects);
236 } 236 }
237 237
238 Optional<SubsequenceRecorder> subsequenceRecorder; 238 Optional<SubsequenceRecorder> subsequenceRecorder;
239 if (!context->printing() 239 if (!context.printing()
240 && !(paintingInfoArg.globalPaintFlags() & GlobalPaintFlattenCompositingL ayers) 240 && !(paintingInfoArg.globalPaintFlags() & GlobalPaintFlattenCompositingL ayers)
241 && !(paintFlags & (PaintLayerPaintingReflection | PaintLayerPaintingRoot BackgroundOnly | PaintLayerPaintingOverlayScrollbars | PaintLayerUncachedClipRec ts)) 241 && !(paintFlags & (PaintLayerPaintingReflection | PaintLayerPaintingRoot BackgroundOnly | PaintLayerPaintingOverlayScrollbars | PaintLayerUncachedClipRec ts))
242 && m_paintLayer.stackingNode()->isStackingContext() 242 && m_paintLayer.stackingNode()->isStackingContext()
243 && PaintLayerStackingNodeIterator(*m_paintLayer.stackingNode(), AllChild ren).next()) { 243 && PaintLayerStackingNodeIterator(*m_paintLayer.stackingNode(), AllChild ren).next()) {
244 if (!m_paintLayer.needsRepaint() 244 if (!m_paintLayer.needsRepaint()
245 && !clipRectsChanged 245 && !clipRectsChanged
246 && paintingInfoArg.scrollOffsetAccumulation == m_paintLayer.previous ScrollOffsetAccumulationForPainting() 246 && paintingInfoArg.scrollOffsetAccumulation == m_paintLayer.previous ScrollOffsetAccumulationForPainting()
247 && SubsequenceRecorder::useCachedSubsequenceIfPossible(*context, m_p aintLayer)) 247 && SubsequenceRecorder::useCachedSubsequenceIfPossible(context, m_pa intLayer))
248 return result; 248 return result;
249 subsequenceRecorder.emplace(*context, m_paintLayer); 249 subsequenceRecorder.emplace(context, m_paintLayer);
250 } 250 }
251 251
252 PaintLayerPaintingInfo paintingInfo = paintingInfoArg; 252 PaintLayerPaintingInfo paintingInfo = paintingInfoArg;
253 253
254 LayoutPoint offsetFromRoot; 254 LayoutPoint offsetFromRoot;
255 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 255 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
256 offsetFromRoot.move(subpixelAccumulation); 256 offsetFromRoot.move(subpixelAccumulation);
257 257
258 LayoutRect bounds = m_paintLayer.physicalBoundingBox(offsetFromRoot); 258 LayoutRect bounds = m_paintLayer.physicalBoundingBox(offsetFromRoot);
259 if (!paintingInfo.paintDirtyRect.contains(bounds)) 259 if (!paintingInfo.paintDirtyRect.contains(bounds))
260 result = MaybeNotFullyPainted; 260 result = MaybeNotFullyPainted;
261 261
262 LayoutRect rootRelativeBounds; 262 LayoutRect rootRelativeBounds;
263 bool rootRelativeBoundsComputed = false; 263 bool rootRelativeBoundsComputed = false;
264 264
265 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()- >isPositioned()) 265 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()- >isPositioned())
266 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C lipPathOfPositionedElement); 266 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C lipPathOfPositionedElement);
267 267
268 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction, 268 // These helpers output clip and compositing operations using a RAII pattern . Stack-allocated-varibles are destructed in the reverse order of construction,
269 // so they are nested properly. 269 // so they are nested properly.
270 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); 270 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags);
271 271
272 Optional<CompositingRecorder> compositingRecorder; 272 Optional<CompositingRecorder> compositingRecorder;
273 // Blending operations must be performed only with the nearest ancestor stac king context. 273 // Blending operations must be performed only with the nearest ancestor stac king context.
274 // Note that there is no need to composite if we're painting the root. 274 // Note that there is no need to composite if we're painting the root.
275 // FIXME: this should be unified further into PaintLayer::paintsWithTranspar ency(). 275 // FIXME: this should be unified further into PaintLayer::paintsWithTranspar ency().
276 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode (); 276 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode ();
277 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.globalPaintFlags())) { 277 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint ingInfo.globalPaintFlags())) {
278 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(pain tingInfo.rootLayer, paintingInfo.subPixelAccumulation, paintingInfo.globalPaintF lags())); 278 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(pain tingInfo.rootLayer, paintingInfo.subPixelAccumulation, paintingInfo.globalPaintF lags()));
279 compositingRecorder.emplace(*context, *m_paintLayer.layoutObject(), 279 compositingRecorder.emplace(context, *m_paintLayer.layoutObject(),
280 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()), 280 WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_paintLayer.la youtObject()->style()->blendMode()),
281 m_paintLayer.layoutObject()->opacity(), &compositingBounds); 281 m_paintLayer.layoutObject()->opacity(), &compositingBounds);
282 } 282 }
283 283
284 PaintLayerPaintingInfo localPaintingInfo(paintingInfo); 284 PaintLayerPaintingInfo localPaintingInfo(paintingInfo);
285 localPaintingInfo.subPixelAccumulation = subpixelAccumulation; 285 localPaintingInfo.subPixelAccumulation = subpixelAccumulation;
286 286
287 PaintLayerFragments layerFragments; 287 PaintLayerFragments layerFragments;
288 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) { 288 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
289 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 289 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
(...skipping 19 matching lines...) Expand all
309 if (localPaintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescen dantOf(localPaintingInfo.paintingRoot)) 309 if (localPaintingInfo.paintingRoot && !m_paintLayer.layoutObject()->isDescen dantOf(localPaintingInfo.paintingRoot))
310 paintingRootForLayoutObject = localPaintingInfo.paintingRoot; 310 paintingRootForLayoutObject = localPaintingInfo.paintingRoot;
311 311
312 { // Begin block for the lifetime of any filter. 312 { // Begin block for the lifetime of any filter.
313 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags, 313 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags,
314 rootRelativeBounds, rootRelativeBoundsComputed); 314 rootRelativeBounds, rootRelativeBoundsComputed);
315 315
316 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; 316 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
317 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 317 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
318 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) { 318 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) {
319 PaintChunkProperties properties(context->paintController().curre ntPaintChunkProperties()); 319 PaintChunkProperties properties(context.paintController().curren tPaintChunkProperties());
320 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents()) 320 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents())
321 properties.transform = transform; 321 properties.transform = transform;
322 if (EffectPaintPropertyNode* effect = objectProperties->effect() ) 322 if (EffectPaintPropertyNode* effect = objectProperties->effect() )
323 properties.effect = effect; 323 properties.effect = effect;
324 scopedPaintChunkProperties.emplace(context->paintController(), p roperties); 324 scopedPaintChunkProperties.emplace(context.paintController(), pr operties);
325 } 325 }
326 } 326 }
327 327
328 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 328 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
329 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 329 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
330 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent; 330 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent;
331 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound; 331 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound;
332 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; 332 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
333 333
334 if (shouldPaintBackground) { 334 if (shouldPaintBackground) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // overflow and a subsequent fragment doesn't intersect with the border box of the layer 397 // overflow and a subsequent fragment doesn't intersect with the border box of the layer
398 // (i.e. only contains an overflow portion of the layer), intersection w ill fail. The reason 398 // (i.e. only contains an overflow portion of the layer), intersection w ill fail. The reason
399 // for this is that fragment.layerBounds is set to the border box, not t he bounding box, of 399 // for this is that fragment.layerBounds is set to the border box, not t he bounding box, of
400 // the layer. 400 // the layer.
401 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac kgroundRect.rect(), newOffsetFromRoot)) 401 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac kgroundRect.rect(), newOffsetFromRoot))
402 return true; 402 return true;
403 } 403 }
404 return false; 404 return false;
405 } 405 }
406 406
407 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform(Graphi csContext* context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 407 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform(Graphi csContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
408 { 408 {
409 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint ingInfo.globalPaintFlags()); 409 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint ingInfo.globalPaintFlags());
410 // If the transform can't be inverted, then don't paint anything. 410 // If the transform can't be inverted, then don't paint anything.
411 if (!layerTransform.isInvertible()) 411 if (!layerTransform.isInvertible())
412 return FullyPainted; 412 return FullyPainted;
413 413
414 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer here. 414 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer here.
415 // m_paintLayer may be the "root", and then we should avoid looking at its p arent. 415 // m_paintLayer may be the "root", and then we should avoid looking at its p arent.
416 PaintLayer* parentLayer = m_paintLayer.parent(); 416 PaintLayer* parentLayer = m_paintLayer.parent();
417 417
(...skipping 27 matching lines...) Expand all
445 PaintLayerFragment fragment; 445 PaintLayerFragment fragment;
446 fragment.backgroundRect = paintingInfo.paintDirtyRect; 446 fragment.backgroundRect = paintingInfo.paintDirtyRect;
447 fragments.append(fragment); 447 fragments.append(fragment);
448 } 448 }
449 449
450 bool needsScope = fragments.size() > 1; 450 bool needsScope = fragments.size() > 1;
451 PaintResult result = FullyPainted; 451 PaintResult result = FullyPainted;
452 for (const auto& fragment : fragments) { 452 for (const auto& fragment : fragments) {
453 Optional<ScopeRecorder> scopeRecorder; 453 Optional<ScopeRecorder> scopeRecorder;
454 if (needsScope) 454 if (needsScope)
455 scopeRecorder.emplace(*context); 455 scopeRecorder.emplace(context);
456 Optional<LayerClipRecorder> clipRecorder; 456 Optional<LayerClipRecorder> clipRecorder;
457 if (parentLayer) { 457 if (parentLayer) {
458 ClipRect clipRectForFragment(ancestorBackgroundClipRect); 458 ClipRect clipRectForFragment(ancestorBackgroundClipRect);
459 clipRectForFragment.moveBy(fragment.paginationOffset); 459 clipRectForFragment.moveBy(fragment.paginationOffset);
460 clipRectForFragment.intersect(fragment.backgroundRect); 460 clipRectForFragment.intersect(fragment.backgroundRect);
461 if (clipRectForFragment.isEmpty()) 461 if (clipRectForFragment.isEmpty())
462 continue; 462 continue;
463 if (needsToClip(paintingInfo, clipRectForFragment)) { 463 if (needsToClip(paintingInfo, clipRectForFragment)) {
464 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr agment.isClippedByClipCss()) 464 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr agment.isClippedByClipCss())
465 UseCounter::count(m_paintLayer.layoutObject()->document(), U seCounter::ClipCssOfPositionedElement); 465 UseCounter::count(m_paintLayer.layoutObject()->document(), U seCounter::ClipCssOfPositionedElement);
466 clipRecorder.emplace(*context, *parentLayer->layoutObject(), Dis playItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati onOffset, paintFlags); 466 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp layItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginatio nOffset, paintFlags);
467 } 467 }
468 } 468 }
469 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset) == MaybeNotFullyPainted) 469 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset) == MaybeNotFullyPainted)
470 result = MaybeNotFullyPainted; 470 result = MaybeNotFullyPainted;
471 } 471 }
472 return result; 472 return result;
473 } 473 }
474 474
475 PaintLayerPainter::PaintResult PaintLayerPainter::paintFragmentByApplyingTransfo rm(GraphicsContext* context, const PaintLayerPaintingInfo& paintingInfo, PaintLa yerFlags paintFlags, const LayoutPoint& fragmentTranslation) 475 PaintLayerPainter::PaintResult PaintLayerPainter::paintFragmentByApplyingTransfo rm(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLa yerFlags paintFlags, const LayoutPoint& fragmentTranslation)
476 { 476 {
477 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving 477 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving
478 // the accumulated error for sub-pixel layout. 478 // the accumulated error for sub-pixel layout.
479 LayoutPoint delta; 479 LayoutPoint delta;
480 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); 480 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta);
481 delta.moveBy(fragmentTranslation); 481 delta.moveBy(fragmentTranslation);
482 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo .globalPaintFlags())); 482 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo .globalPaintFlags()));
483 IntPoint roundedDelta = roundedIntPoint(delta); 483 IntPoint roundedDelta = roundedIntPoint(delta);
484 transform.translateRight(roundedDelta.x(), roundedDelta.y()); 484 transform.translateRight(roundedDelta.x(), roundedDelta.y());
485 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); 485 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta);
486 486
487 // TODO(jbroman): Put the real transform origin here, instead of using a 487 // TODO(jbroman): Put the real transform origin here, instead of using a
488 // matrix with the origin baked in. 488 // matrix with the origin baked in.
489 FloatPoint3D transformOrigin; 489 FloatPoint3D transformOrigin;
490 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject (), DisplayItem::Transform3DElementTransform, transform, transformOrigin); 490 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject( ), DisplayItem::Transform3DElementTransform, transform, transformOrigin);
491 491
492 // Now do a paint with the root layer shifted to be us. 492 // Now do a paint with the root layer shifted to be us.
493 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti ngInfo.globalPaintFlags(), 493 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti ngInfo.globalPaintFlags(),
494 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); 494 adjustedSubPixelAccumulation, paintingInfo.paintingRoot);
495 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH asClipPathClipping; 495 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH asClipPathClipping;
496 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai ntFlags, ForceSingleFragment); 496 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai ntFlags, ForceSingleFragment);
497 } 497 }
498 498
499 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre nToVisit, GraphicsContext* context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 499 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren(unsigned childre nToVisit, GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
500 { 500 {
501 PaintResult result = FullyPainted; 501 PaintResult result = FullyPainted;
502 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) 502 if (!m_paintLayer.hasSelfPaintingLayerDescendant())
503 return result; 503 return result;
504 504
505 #if ENABLE(ASSERT) 505 #if ENABLE(ASSERT)
506 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); 506 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode());
507 #endif 507 #endif
508 508
509 PaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode(), childr enToVisit); 509 PaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode(), childr enToVisit);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 bool PaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPaintFlags gl obalPaintFlags, PaintLayerFlags paintFlags) 546 bool PaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPaintFlags gl obalPaintFlags, PaintLayerFlags paintFlags)
547 { 547 {
548 DisableCompositingQueryAsserts disabler; 548 DisableCompositingQueryAsserts disabler;
549 549
550 return m_paintLayer.compositingState() == NotComposited 550 return m_paintLayer.compositingState() == NotComposited
551 || (globalPaintFlags & GlobalPaintFlattenCompositingLayers) 551 || (globalPaintFlags & GlobalPaintFlattenCompositingLayers)
552 || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTr ansform()) 552 || ((paintFlags & PaintLayerPaintingReflection) && !m_paintLayer.has3DTr ansform())
553 || paintForFixedRootBackground(&m_paintLayer, paintFlags); 553 || paintForFixedRootBackground(&m_paintLayer, paintFlags);
554 } 554 }
555 555
556 void PaintLayerPainter::paintOverflowControlsForFragments(const PaintLayerFragme nts& layerFragments, GraphicsContext* context, const PaintLayerPaintingInfo& loc alPaintingInfo, PaintLayerFlags paintFlags) 556 void PaintLayerPainter::paintOverflowControlsForFragments(const PaintLayerFragme nts& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& loc alPaintingInfo, PaintLayerFlags paintFlags)
557 { 557 {
558 bool needsScope = layerFragments.size() > 1; 558 bool needsScope = layerFragments.size() > 1;
559 for (auto& fragment : layerFragments) { 559 for (auto& fragment : layerFragments) {
560 Optional<ScopeRecorder> scopeRecorder; 560 Optional<ScopeRecorder> scopeRecorder;
561 if (needsScope) 561 if (needsScope)
562 scopeRecorder.emplace(*context); 562 scopeRecorder.emplace(context);
563 563
564 Optional<LayerClipRecorder> clipRecorder; 564 Optional<LayerClipRecorder> clipRecorder;
565 565
566 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) 566 if (needsToClip(localPaintingInfo, fragment.backgroundRect))
567 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), Display Item::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr agment.paginationOffset, paintFlags); 567 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra gment.paginationOffset, paintFlags);
568 if (PaintLayerScrollableArea* scrollableArea = m_paintLayer.scrollableAr ea()) { 568 if (PaintLayerScrollableArea* scrollableArea = m_paintLayer.scrollableAr ea()) {
569 CullRect cullRect(pixelSnappedIntRect(fragment.backgroundRect.rect() )); 569 CullRect cullRect(pixelSnappedIntRect(fragment.backgroundRect.rect() ));
570 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(*contex t, roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layout BoxLocation())), cullRect, true); 570 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context , roundedIntPoint(toPoint(fragment.layerBounds.location() - m_paintLayer.layoutB oxLocation())), cullRect, true);
571 } 571 }
572 } 572 }
573 } 573 }
574 574
575 void PaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const PaintLaye rFragment& fragment, GraphicsContext* context, const ClipRect& clipRect, const P aintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 575 void PaintLayerPainter::paintFragmentWithPhase(PaintPhase phase, const PaintLaye rFragment& fragment, GraphicsContext& context, const ClipRect& clipRect, const P aintLayerPaintingInfo& paintingInfo, LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
576 { 576 {
577 ASSERT(m_paintLayer.isSelfPaintingLayer()); 577 ASSERT(m_paintLayer.isSelfPaintingLayer());
578 578
579 Optional<LayerClipRecorder> clipRecorder; 579 Optional<LayerClipRecorder> clipRecorder;
580 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) { 580 if (clipState != HasClipped && paintingInfo.clipToDirtyRect && needsToClip(p aintingInfo, clipRect)) {
581 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase); 581 DisplayItem::Type clipType = DisplayItem::paintPhaseToClipLayerFragmentT ype(phase);
582 LayerClipRecorder::BorderRadiusClippingRule clippingRule; 582 LayerClipRecorder::BorderRadiusClippingRule clippingRule;
583 switch (phase) { 583 switch (phase) {
584 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self. 584 case PaintPhaseBlockBackground: // Background painting will handle clipp ing to self.
585 case PaintPhaseSelfOutline: 585 case PaintPhaseSelfOutline:
586 case PaintPhaseMask: // Mask painting will handle clipping to self. 586 case PaintPhaseMask: // Mask painting will handle clipping to self.
587 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; 587 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius;
588 break; 588 break;
589 default: 589 default:
590 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 590 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
591 break; 591 break;
592 } 592 }
593 593
594 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), clipType, c lipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); 594 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule);
595 } 595 }
596 596
597 LayoutRect newCullRect(clipRect.rect()); 597 LayoutRect newCullRect(clipRect.rect());
598 Optional<ScrollRecorder> scrollRecorder; 598 Optional<ScrollRecorder> scrollRecorder;
599 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation()); 599 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation());
600 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { 600 if (!paintingInfo.scrollOffsetAccumulation.isZero()) {
601 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders 601 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders
602 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder 602 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder
603 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this 603 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this
604 // layer, to get the same result as ScrollRecorder in BlockPainter. 604 // layer, to get the same result as ScrollRecorder in BlockPainter.
605 paintOffset += paintingInfo.scrollOffsetAccumulation; 605 paintOffset += paintingInfo.scrollOffsetAccumulation;
606 606
607 newCullRect.move(paintingInfo.scrollOffsetAccumulation); 607 newCullRect.move(paintingInfo.scrollOffsetAccumulation);
608 scrollRecorder.emplace(*context, *m_paintLayer.layoutObject(), phase, pa intingInfo.scrollOffsetAccumulation); 608 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, pai ntingInfo.scrollOffsetAccumulation);
609 } 609 }
610 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, painti ngInfo.globalPaintFlags(), paintFlags, 610 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, painti ngInfo.globalPaintFlags(), paintFlags,
611 paintingRootForLayoutObject, paintingInfo.rootLayer->layoutObject()); 611 paintingRootForLayoutObject, paintingInfo.rootLayer->layoutObject());
612 612
613 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 613 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
614 } 614 }
615 615
616 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext* context, 616 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context,
617 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo, 617 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo,
618 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 618 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
619 { 619 {
620 bool needsScope = layerFragments.size() > 1; 620 bool needsScope = layerFragments.size() > 1;
621 for (auto& fragment : layerFragments) { 621 for (auto& fragment : layerFragments) {
622 Optional<ScopeRecorder> scopeRecorder; 622 Optional<ScopeRecorder> scopeRecorder;
623 if (needsScope) 623 if (needsScope)
624 scopeRecorder.emplace(*context); 624 scopeRecorder.emplace(context);
625 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags , HasNotClipped); 625 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags , HasNotClipped);
626 } 626 }
627 } 627 }
628 628
629 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext* context, 629 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l ayerFragments, GraphicsContext& context,
630 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo, 630 const LayoutRect& transparencyPaintDirtyRect, const PaintLayerPaintingInfo& localPaintingInfo,
631 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags) 631 LayoutObject* paintingRootForLayoutObject, bool selectionOnly, PaintLayerFla gs paintFlags)
632 { 632 {
633 // Optimize clipping for the single fragment case. 633 // Optimize clipping for the single fragment case.
634 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 634 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
635 ClipState clipState = HasNotClipped; 635 ClipState clipState = HasNotClipped;
636 Optional<LayerClipRecorder> clipRecorder; 636 Optional<LayerClipRecorder> clipRecorder;
637 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 637 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
638 clipRecorder.emplace(*context, *m_paintLayer.layoutObject(), DisplayItem ::ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, lay erFragments[0].paginationOffset, paintFlags); 638 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem: :ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye rFragments[0].paginationOffset, paintFlags);
639 clipState = HasClipped; 639 clipState = HasClipped;
640 } 640 }
641 641
642 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 642 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
643 // interleaving of the fragments to work properly. 643 // interleaving of the fragments to work properly.
644 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments, 644 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments,
645 context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, cli pState); 645 context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, cli pState);
646 646
647 if (!selectionOnly) { 647 if (!selectionOnly) {
648 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 648 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState);
649 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipStat e); 649 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipStat e);
650 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipS tate); 650 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipS tate);
651 } 651 }
652 } 652 }
653 653
654 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, c onst PaintLayerFragments& layerFragments, GraphicsContext* context, 654 void PaintLayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, c onst PaintLayerFragments& layerFragments, GraphicsContext& context,
655 const PaintLayerPaintingInfo& localPaintingInfo, LayoutObject* paintingRootF orLayoutObject, PaintLayerFlags paintFlags, ClipState clipState) 655 const PaintLayerPaintingInfo& localPaintingInfo, LayoutObject* paintingRootF orLayoutObject, PaintLayerFlags paintFlags, ClipState clipState)
656 { 656 {
657 bool needsScope = layerFragments.size() > 1; 657 bool needsScope = layerFragments.size() > 1;
658 for (auto& fragment : layerFragments) { 658 for (auto& fragment : layerFragments) {
659 if (!fragment.foregroundRect.isEmpty()) { 659 if (!fragment.foregroundRect.isEmpty()) {
660 Optional<ScopeRecorder> scopeRecorder; 660 Optional<ScopeRecorder> scopeRecorder;
661 if (needsScope) 661 if (needsScope)
662 scopeRecorder.emplace(*context); 662 scopeRecorder.emplace(context);
663 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState); 663 paintFragmentWithPhase(phase, fragment, context, fragment.foreground Rect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, clipState);
664 } 664 }
665 } 665 }
666 } 666 }
667 667
668 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, GraphicsContext* context, const PaintLayerPaintingInfo& localPaintin gInfo, 668 void PaintLayerPainter::paintOutlineForFragments(const PaintLayerFragments& laye rFragments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintin gInfo,
669 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 669 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
670 { 670 {
671 bool needsScope = layerFragments.size() > 1; 671 bool needsScope = layerFragments.size() > 1;
672 for (auto& fragment : layerFragments) { 672 for (auto& fragment : layerFragments) {
673 if (!fragment.backgroundRect.isEmpty()) { 673 if (!fragment.backgroundRect.isEmpty()) {
674 Optional<ScopeRecorder> scopeRecorder; 674 Optional<ScopeRecorder> scopeRecorder;
675 if (needsScope) 675 if (needsScope)
676 scopeRecorder.emplace(*context); 676 scopeRecorder.emplace(context);
677 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags , HasNotClipped); 677 paintFragmentWithPhase(PaintPhaseSelfOutline, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags , HasNotClipped);
678 } 678 }
679 } 679 }
680 } 680 }
681 681
682 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, GraphicsContext* context, const PaintLayerPaintingInfo& localPaintingIn fo, 682 void PaintLayerPainter::paintMaskForFragments(const PaintLayerFragments& layerFr agments, GraphicsContext& context, const PaintLayerPaintingInfo& localPaintingIn fo,
683 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 683 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
684 { 684 {
685 bool needsScope = layerFragments.size() > 1; 685 bool needsScope = layerFragments.size() > 1;
686 for (auto& fragment : layerFragments) { 686 for (auto& fragment : layerFragments) {
687 Optional<ScopeRecorder> scopeRecorder; 687 Optional<ScopeRecorder> scopeRecorder;
688 if (needsScope) 688 if (needsScope)
689 scopeRecorder.emplace(*context); 689 scopeRecorder.emplace(context);
690 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, HasNotCli pped); 690 paintFragmentWithPhase(PaintPhaseMask, fragment, context, fragment.backg roundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, HasNotCli pped);
691 } 691 }
692 } 692 }
693 693
694 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments, GraphicsContext* context, const PaintLayerPaintingInfo& lo calPaintingInfo, 694 void PaintLayerPainter::paintChildClippingMaskForFragments(const PaintLayerFragm ents& layerFragments, GraphicsContext& context, const PaintLayerPaintingInfo& lo calPaintingInfo,
695 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags) 695 LayoutObject* paintingRootForLayoutObject, PaintLayerFlags paintFlags)
696 { 696 {
697 bool needsScope = layerFragments.size() > 1; 697 bool needsScope = layerFragments.size() > 1;
698 for (auto& fragment: layerFragments) { 698 for (auto& fragment: layerFragments) {
699 Optional<ScopeRecorder> scopeRecorder; 699 Optional<ScopeRecorder> scopeRecorder;
700 if (needsScope) 700 if (needsScope)
701 scopeRecorder.emplace(*context); 701 scopeRecorder.emplace(context);
702 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, H asNotClipped); 702 paintFragmentWithPhase(PaintPhaseClippingMask, fragment, context, fragme nt.foregroundRect, localPaintingInfo, paintingRootForLayoutObject, paintFlags, H asNotClipped);
703 } 703 }
704 } 704 }
705 705
706 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext* context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags, LayoutObject* painting Root) 706 void PaintLayerPainter::paintOverlayScrollbars(GraphicsContext& context, const L ayoutRect& damageRect, const GlobalPaintFlags paintFlags, LayoutObject* painting Root)
707 { 707 {
708 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 708 if (!m_paintLayer.containsDirtyOverlayScrollbars())
709 return; 709 return;
710 710
711 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize(), paintingRoot); 711 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize(), paintingRoot);
712 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 712 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
713 713
714 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 714 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
715 } 715 }
716 716
717 } // namespace blink 717 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698