OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/paint/LayerPainter.h" | 6 #include "core/paint/LayerPainter.h" |
7 | 7 |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
10 #include "core/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th
e transform twice. | 71 // PaintLayerAppliedTransform is used in RenderReplica, to avoid applying th
e transform twice. |
72 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint
Flags & PaintLayerAppliedTransform)) { | 72 if (m_renderLayer.paintsWithTransform(paintingInfo.paintBehavior) && !(paint
Flags & PaintLayerAppliedTransform)) { |
73 TransformationMatrix layerTransform = m_renderLayer.renderableTransform(
paintingInfo.paintBehavior); | 73 TransformationMatrix layerTransform = m_renderLayer.renderableTransform(
paintingInfo.paintBehavior); |
74 // If the transform can't be inverted, then don't paint anything. | 74 // If the transform can't be inverted, then don't paint anything. |
75 if (!layerTransform.isInvertible()) | 75 if (!layerTransform.isInvertible()) |
76 return; | 76 return; |
77 | 77 |
78 // If we have a transparency layer enclosing us and we are the root of a
transform, then we need to establish the transparency | 78 // If we have a transparency layer enclosing us and we are the root of a
transform, then we need to establish the transparency |
79 // layer from the parent now, assuming there is a parent | 79 // layer from the parent now, assuming there is a parent |
80 if (paintFlags & PaintLayerHaveTransparency) { | 80 if (paintFlags & PaintLayerHaveTransparency) { |
| 81 // FIXME: can we get rid of this? It would mean transparency starts
after clipping in these cases. |
81 if (m_renderLayer.parent()) | 82 if (m_renderLayer.parent()) |
82 beginTransparencyLayers(context, *m_renderLayer.parent(), painti
ngInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation
, paintingInfo.paintBehavior); | 83 LayerPainter(*m_renderLayer.parent()).beginTransparencyLayers(co
ntext, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixe
lAccumulation, paintingInfo.paintBehavior); |
83 else | 84 else |
84 beginTransparencyLayers(context, m_renderLayer, paintingInfo.roo
tLayer, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, painting
Info.paintBehavior); | 85 beginTransparencyLayers(context, paintingInfo.rootLayer, paintin
gInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehav
ior); |
85 } | 86 } |
86 | 87 |
87 if (m_renderLayer.enclosingPaginationLayer()) { | 88 if (m_renderLayer.enclosingPaginationLayer()) { |
88 paintTransformedLayerIntoFragments(context, paintingInfo, paintFlags
); | 89 paintTransformedLayerIntoFragments(context, paintingInfo, paintFlags
); |
89 return; | 90 return; |
90 } | 91 } |
91 | 92 |
92 // Make sure the parent's clip rects have been calculated. | 93 // Make sure the parent's clip rects have been calculated. |
93 ClipRect clipRect = paintingInfo.paintDirtyRect; | 94 ClipRect clipRect = paintingInfo.paintDirtyRect; |
94 | 95 |
(...skipping 13 matching lines...) Expand all Loading... |
108 } | 109 } |
109 | 110 |
110 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); | 111 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); |
111 | 112 |
112 return; | 113 return; |
113 } | 114 } |
114 | 115 |
115 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); | 116 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); |
116 } | 117 } |
117 | 118 |
118 void LayerPainter::beginTransparencyLayers(GraphicsContext* context, RenderLayer
& renderLayer, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, c
onst LayoutSize& subPixelAccumulation, PaintBehavior paintBehavior) | 119 bool LayerPainter::shouldCreateTransparencyLayerForBlendMode() |
119 { | 120 { |
120 bool createTransparencyLayerForBlendMode = renderLayer.stackingNode()->isSta
ckingContext() && renderLayer.hasNonIsolatedDescendantWithBlendMode(); | 121 return !m_renderLayer.renderer()->isDocumentElement() && m_renderLayer.stack
ingNode()->isStackingContext() && m_renderLayer.hasNonIsolatedDescendantWithBlen
dMode(); |
121 if ((renderLayer.paintsWithTransparency(paintBehavior) || createTransparency
LayerForBlendMode) && renderLayer.usedTransparency()) | 122 } |
| 123 |
| 124 void LayerPainter::beginTransparencyLayers(GraphicsContext* context, const Rende
rLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelA
ccumulation, PaintBehavior paintBehavior) |
| 125 { |
| 126 // Blending operations must be performed only with the nearest ancestor stac
king context. |
| 127 // Note that there is no need to create a transparency layer if we're painti
ng the root. |
| 128 // FIXME: this should be unified further into RenderLayer::paintsWithTranspa
rency(). |
| 129 if (!m_renderLayer.paintsWithTransparency(paintBehavior) && !shouldCreateTra
nsparencyLayerForBlendMode()) |
122 return; | 130 return; |
123 | 131 |
124 RenderLayer* ancestor = renderLayer.transparentPaintingAncestor(); | 132 // FIXME: refactor to remove this. |
125 if (ancestor) | 133 if (m_renderLayer.usedTransparency()) |
126 beginTransparencyLayers(context, *ancestor, rootLayer, paintDirtyRect, s
ubPixelAccumulation, paintBehavior); | 134 return; |
127 | 135 |
128 if (renderLayer.paintsWithTransparency(paintBehavior) || createTransparencyL
ayerForBlendMode) { | 136 m_renderLayer.setUsedTransparency(true); |
129 renderLayer.setUsedTransparency(true); | 137 context->save(); |
130 context->save(); | 138 LayoutRect clipRect = m_renderLayer.paintingExtent(rootLayer, paintDirtyRect
, subPixelAccumulation, paintBehavior); |
131 LayoutRect clipRect = renderLayer.paintingExtent(rootLayer, paintDirtyRe
ct, subPixelAccumulation, paintBehavior); | 139 context->clip(clipRect); |
132 context->clip(clipRect); | |
133 | 140 |
134 if (renderLayer.renderer()->hasBlendMode()) | 141 if (m_renderLayer.renderer()->hasBlendMode()) |
135 context->setCompositeOperation(context->compositeOperation(), render
Layer.renderer()->style()->blendMode()); | 142 context->setCompositeOperation(context->compositeOperation(), m_renderLa
yer.renderer()->style()->blendMode()); |
136 | 143 |
137 context->beginTransparencyLayer(renderLayer.renderer()->opacity()); | 144 context->beginTransparencyLayer(m_renderLayer.renderer()->opacity()); |
138 | 145 |
139 if (renderLayer.renderer()->hasBlendMode()) | 146 if (m_renderLayer.renderer()->hasBlendMode()) |
140 context->setCompositeOperation(context->compositeOperation(), WebBle
ndModeNormal); | 147 context->setCompositeOperation(context->compositeOperation(), WebBlendMo
deNormal); |
141 #ifdef REVEAL_TRANSPARENCY_LAYERS | 148 #ifdef REVEAL_TRANSPARENCY_LAYERS |
142 context->fillRect(clipRect, Color(0.0f, 0.0f, 0.5f, 0.2f)); | 149 context->fillRect(clipRect, Color(0.0f, 0.0f, 0.5f, 0.2f)); |
143 #endif | 150 #endif |
144 } | |
145 } | 151 } |
146 | 152 |
147 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con
st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 153 void LayerPainter::paintLayerContentsAndReflection(GraphicsContext* context, con
st LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
148 { | 154 { |
149 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); | 155 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); |
150 | 156 |
151 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform)
; | 157 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform)
; |
152 | 158 |
153 // Paint the reflection first if we have one. | 159 // Paint the reflection first if we have one. |
154 if (m_renderLayer.reflectionInfo()) | 160 if (m_renderLayer.reflectionInfo()) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 RenderSVGResourceClipper::ClipperState m_clipperState; | 228 RenderSVGResourceClipper::ClipperState m_clipperState; |
223 const RenderLayer& m_renderLayer; | 229 const RenderLayer& m_renderLayer; |
224 GraphicsContext* m_context; | 230 GraphicsContext* m_context; |
225 }; | 231 }; |
226 | 232 |
227 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags) | 233 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags) |
228 { | 234 { |
229 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); | 235 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); |
230 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); | 236 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); |
231 | 237 |
232 bool haveTransparency = paintFlags & PaintLayerHaveTransparency; | |
233 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); | 238 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); |
234 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr
ollbars; | 239 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr
ollbars; |
235 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing
ScrollingPhase; | 240 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing
ScrollingPhase; |
236 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi
tingForegroundPhase; | 241 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi
tingForegroundPhase; |
237 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi
tingBackgroundPhase; | 242 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi
tingBackgroundPhase; |
238 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon
tents; | 243 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon
tents; |
239 // Outline always needs to be painted even if we have no visible content. Al
so, | 244 // Outline always needs to be painted even if we have no visible content. Al
so, |
240 // the outline is painted in the background phase during composited scrollin
g. | 245 // the outline is painted in the background phase during composited scrollin
g. |
241 // If it were painted in the foreground phase, it would move with the scroll
ed | 246 // If it were painted in the foreground phase, it would move with the scroll
ed |
242 // content. When not composited scrolling, the outline is painted in the | 247 // content. When not composited scrolling, the outline is painted in the |
(...skipping 17 matching lines...) Expand all Loading... |
260 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 265 m_renderLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
261 | 266 |
262 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) | 267 if (m_renderLayer.compositingState() == PaintsIntoOwnBacking) |
263 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); | 268 offsetFromRoot.move(m_renderLayer.subpixelAccumulation()); |
264 | 269 |
265 LayoutRect rootRelativeBounds; | 270 LayoutRect rootRelativeBounds; |
266 bool rootRelativeBoundsComputed = false; | 271 bool rootRelativeBoundsComputed = false; |
267 | 272 |
268 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela
tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); | 273 ClipPathHelper clipPathHelper(context, m_renderLayer, paintingInfo, rootRela
tiveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); |
269 | 274 |
270 // Blending operations must be performed only with the nearest ancestor stac
king context. | 275 beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.paintD
irtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); |
271 // Note that there is no need to create a transparency layer if we're painti
ng the root. | |
272 bool createTransparencyLayerForBlendMode = !m_renderLayer.renderer()->isDocu
mentElement() && m_renderLayer.stackingNode()->isStackingContext() && m_renderLa
yer.hasNonIsolatedDescendantWithBlendMode(); | |
273 | |
274 if (createTransparencyLayerForBlendMode) | |
275 beginTransparencyLayers(context, m_renderLayer, paintingInfo.rootLayer,
paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.pai
ntBehavior); | |
276 | 276 |
277 LayerPaintingInfo localPaintingInfo(paintingInfo); | 277 LayerPaintingInfo localPaintingInfo(paintingInfo); |
278 | 278 |
279 LayerFragments layerFragments; | 279 LayerFragments layerFragments; |
280 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars)
{ | 280 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars)
{ |
281 // Collect the fragments. This will compute the clip rectangles and pain
t offsets for each layer fragment. | 281 // Collect the fragments. This will compute the clip rectangles and pain
t offsets for each layer fragment. |
282 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay
er, localPaintingInfo.paintDirtyRect, | 282 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay
er, localPaintingInfo.paintDirtyRect, |
283 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai
ntingClipRects, IgnoreOverlayScrollbarSize, | 283 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai
ntingClipRects, IgnoreOverlayScrollbarSize, |
284 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of
fsetFromRoot, localPaintingInfo.subPixelAccumulation); | 284 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of
fsetFromRoot, localPaintingInfo.subPixelAccumulation); |
285 if (shouldPaintContent) | 285 if (shouldPaintContent) |
(...skipping 21 matching lines...) Expand all Loading... |
307 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr
ound; | 307 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr
ound; |
308 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; | 308 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; |
309 | 309 |
310 PaintBehavior paintBehavior = PaintBehaviorNormal; | 310 PaintBehavior paintBehavior = PaintBehaviorNormal; |
311 if (paintFlags & PaintLayerPaintingSkipRootBackground) | 311 if (paintFlags & PaintLayerPaintingSkipRootBackground) |
312 paintBehavior |= PaintBehaviorSkipRootBackground; | 312 paintBehavior |= PaintBehaviorSkipRootBackground; |
313 else if (paintFlags & PaintLayerPaintingRootBackgroundOnly) | 313 else if (paintFlags & PaintLayerPaintingRootBackgroundOnly) |
314 paintBehavior |= PaintBehaviorRootBackgroundOnly; | 314 paintBehavior |= PaintBehaviorRootBackgroundOnly; |
315 | 315 |
316 if (shouldPaintBackground) { | 316 if (shouldPaintBackground) { |
317 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, haveTransparency, | 317 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, |
318 localPaintingInfo, paintBehavior, paintingRootForRenderer, paint
Flags); | 318 localPaintingInfo, paintBehavior, paintingRootForRenderer, paint
Flags); |
319 } | 319 } |
320 | 320 |
321 if (shouldPaintNegZOrderList) | 321 if (shouldPaintNegZOrderList) |
322 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFl
ags); | 322 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFl
ags); |
323 | 323 |
324 if (shouldPaintOwnContents) { | 324 if (shouldPaintOwnContents) { |
325 paintForegroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, haveTransparency, | 325 paintForegroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, |
326 localPaintingInfo, paintBehavior, paintingRootForRenderer, selec
tionOnly, paintFlags); | 326 localPaintingInfo, paintBehavior, paintingRootForRenderer, selec
tionOnly, paintFlags); |
327 } | 327 } |
328 | 328 |
329 if (shouldPaintOutline) | 329 if (shouldPaintOutline) |
330 paintOutlineForFragments(layerFragments, context, localPaintingInfo,
paintBehavior, paintingRootForRenderer, paintFlags); | 330 paintOutlineForFragments(layerFragments, context, localPaintingInfo,
paintBehavior, paintingRootForRenderer, paintFlags); |
331 | 331 |
332 if (shouldPaintNormalFlowAndPosZOrderLists) | 332 if (shouldPaintNormalFlowAndPosZOrderLists) |
333 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context,
paintingInfo, paintFlags); | 333 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context,
paintingInfo, paintFlags); |
334 | 334 |
335 if (shouldPaintOverlayScrollbars) | 335 if (shouldPaintOverlayScrollbars) |
336 paintOverflowControlsForFragments(layerFragments, context, localPain
tingInfo, paintFlags); | 336 paintOverflowControlsForFragments(layerFragments, context, localPain
tingInfo, paintFlags); |
337 } // Filter painter block | 337 } // Filter painter block |
338 | 338 |
339 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase)
&& shouldPaintContent && m_renderLayer.renderer()->hasMask() && !selectionOnly; | 339 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase)
&& shouldPaintContent && m_renderLayer.renderer()->hasMask() && !selectionOnly; |
340 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping
MaskPhase) && shouldPaintContent && !selectionOnly; | 340 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping
MaskPhase) && shouldPaintContent && !selectionOnly; |
341 | 341 |
342 if (shouldPaintMask) | 342 if (shouldPaintMask) |
343 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer, paintFlags); | 343 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer, paintFlags); |
344 | 344 |
345 if (shouldPaintClippingMask) { | 345 if (shouldPaintClippingMask) { |
346 // Paint the border radius mask for the fragments. | 346 // Paint the border radius mask for the fragments. |
347 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForRenderer, paintFlags); | 347 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForRenderer, paintFlags); |
348 } | 348 } |
349 | 349 |
350 // End our transparency layer | 350 // End our transparency layer |
351 if ((haveTransparency || createTransparencyLayerForBlendMode) && m_renderLay
er.usedTransparency() | 351 if (((paintFlags & PaintLayerHaveTransparency) || shouldCreateTransparencyLa
yerForBlendMode()) && m_renderLayer.usedTransparency() |
352 && !(m_renderLayer.reflectionInfo() && m_renderLayer.reflectionInfo()->i
sPaintingInsideReflection())) { | 352 && !(m_renderLayer.reflectionInfo() && m_renderLayer.reflectionInfo()->i
sPaintingInsideReflection())) { |
353 context->endLayer(); | 353 context->endLayer(); |
354 context->restore(); | 354 context->restore(); |
355 m_renderLayer.setUsedTransparency(false); | 355 m_renderLayer.setUsedTransparency(false); |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
359 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye
r) | 359 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye
r) |
360 { | 360 { |
361 if (startLayer == endLayer) | 361 if (startLayer == endLayer) |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, clipTy
pe, clipRect)); | 695 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, clipTy
pe, clipRect)); |
696 if (clipRect.hasRadius()) | 696 if (clipRect.hasRadius()) |
697 applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFla
gs, *clipRecorder, clippingRule); | 697 applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFla
gs, *clipRecorder, clippingRule); |
698 } | 698 } |
699 | 699 |
700 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa
intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); | 700 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa
intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); |
701 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca
tion() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(painti
ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 701 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca
tion() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(painti
ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
702 } | 702 } |
703 | 703 |
704 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, | 704 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, |
705 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, | 705 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local
PaintingInfo, PaintBehavior paintBehavior, |
706 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | 706 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) |
707 { | 707 { |
708 for (const auto& fragment: layerFragments) { | 708 for (const auto& fragment: layerFragments) { |
709 // Begin transparency layers lazily now that we know we have to paint so
mething. | |
710 if (haveTransparency) | |
711 beginTransparencyLayers(context, m_renderLayer, localPaintingInfo.ro
otLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, loc
alPaintingInfo.paintBehavior); | |
712 | |
713 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra
gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer,
paintFlags, HasNotClipped); | 709 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra
gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer,
paintFlags, HasNotClipped); |
714 } | 710 } |
715 } | 711 } |
716 | 712 |
717 void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, | 713 void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, |
718 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, | 714 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local
PaintingInfo, PaintBehavior paintBehavior, |
719 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p
aintFlags) | 715 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p
aintFlags) |
720 { | 716 { |
721 // Begin transparency if we have something to paint. | |
722 if (haveTransparency) { | |
723 for (size_t i = 0; i < layerFragments.size(); ++i) { | |
724 const LayerFragment& fragment = layerFragments.at(i); | |
725 if (!fragment.foregroundRect.isEmpty()) { | |
726 beginTransparencyLayers(context, m_renderLayer, localPaintingInf
o.rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation,
localPaintingInfo.paintBehavior); | |
727 break; | |
728 } | |
729 } | |
730 } | |
731 | |
732 // Optimize clipping for the single fragment case. | 717 // Optimize clipping for the single fragment case. |
733 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && !layerFragments[0].foregroundRect.isEmpty(); | 718 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && !layerFragments[0].foregroundRect.isEmpty(); |
734 ClipState clipState = HasNotClipped; | 719 ClipState clipState = HasNotClipped; |
735 OwnPtr<ClipRecorder> clipRecorder; | 720 OwnPtr<ClipRecorder> clipRecorder; |
736 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun
dRect)) { | 721 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun
dRect)) { |
737 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, Displa
yItem::ClipLayerForeground, layerFragments[0].foregroundRect)); | 722 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, Displa
yItem::ClipLayerForeground, layerFragments[0].foregroundRect)); |
738 if (layerFragments[0].foregroundRect.hasRadius()) | 723 if (layerFragments[0].foregroundRect.hasRadius()) |
739 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, pai
ntFlags, *clipRecorder); | 724 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, pai
ntFlags, *clipRecorder); |
740 clipState = HasClipped; | 725 clipState = HasClipped; |
741 } | 726 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 | 810 |
826 OwnPtr<ClipRecorder> clipRecorder; | 811 OwnPtr<ClipRecorder> clipRecorder; |
827 if (needsToClip(paintingInfo, clipRect)) | 812 if (needsToClip(paintingInfo, clipRect)) |
828 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(), con
text, DisplayItem::ClipLayerFragmentParent, clipRect)); | 813 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(), con
text, DisplayItem::ClipLayerFragmentParent, clipRect)); |
829 | 814 |
830 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); | 815 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); |
831 } | 816 } |
832 } | 817 } |
833 | 818 |
834 } // namespace blink | 819 } // namespace blink |
OLD | NEW |