| 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 "core/paint/PaintLayerPainter.h" | 5 #include "core/paint/PaintLayerPainter.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/paint/ClipPathClipper.h" | 9 #include "core/paint/ClipPathClipper.h" |
| 10 #include "core/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer) { | 32 static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer) { |
| 33 // Avoid painting descendants of the root layer when stylesheets haven't | 33 // Avoid painting descendants of the root layer when stylesheets haven't |
| 34 // loaded. This avoids some FOUC. It's ok not to draw, because later on, when | 34 // loaded. This avoids some FOUC. It's ok not to draw, because later on, when |
| 35 // all the stylesheets do load, Document::styleResolverMayHaveChanged() will | 35 // all the stylesheets do load, Document::styleResolverMayHaveChanged() will |
| 36 // invalidate all painted output via a call to | 36 // invalidate all painted output via a call to |
| 37 // LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid | 37 // LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid |
| 38 // caching subsequences in this mode; see shouldCreateSubsequence(). | 38 // caching subsequences in this mode; see shouldCreateSubsequence(). |
| 39 if (layer.layoutObject()->document().didLayoutWithPendingStylesheets() && | 39 if (layer.layoutObject().document().didLayoutWithPendingStylesheets() && |
| 40 !layer.isRootLayer() && !layer.layoutObject()->isDocumentElement()) | 40 !layer.isRootLayer() && !layer.layoutObject().isDocumentElement()) |
| 41 return true; | 41 return true; |
| 42 | 42 |
| 43 return false; | 43 return false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PaintLayerPainter::paint(GraphicsContext& context, | 46 void PaintLayerPainter::paint(GraphicsContext& context, |
| 47 const LayoutRect& damageRect, | 47 const LayoutRect& damageRect, |
| 48 const GlobalPaintFlags globalPaintFlags, | 48 const GlobalPaintFlags globalPaintFlags, |
| 49 PaintLayerFlags paintFlags) { | 49 PaintLayerFlags paintFlags) { |
| 50 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, | 50 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, |
| 51 LayoutRect(enclosingIntRect(damageRect)), | 51 LayoutRect(enclosingIntRect(damageRect)), |
| 52 globalPaintFlags, LayoutSize()); | 52 globalPaintFlags, LayoutSize()); |
| 53 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) | 53 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) |
| 54 paint(context, paintingInfo, paintFlags); | 54 paint(context, paintingInfo, paintFlags); |
| 55 } | 55 } |
| 56 | 56 |
| 57 static ShouldRespectOverflowClipType shouldRespectOverflowClip( | 57 static ShouldRespectOverflowClipType shouldRespectOverflowClip( |
| 58 PaintLayerFlags paintFlags, | 58 PaintLayerFlags paintFlags, |
| 59 const LayoutObject* layoutObject) { | 59 const LayoutObject& layoutObject) { |
| 60 return (paintFlags & PaintLayerPaintingOverflowContents || | 60 return (paintFlags & PaintLayerPaintingOverflowContents || |
| 61 (paintFlags & PaintLayerPaintingChildClippingMaskPhase && | 61 (paintFlags & PaintLayerPaintingChildClippingMaskPhase && |
| 62 layoutObject->hasClipPath())) | 62 layoutObject.hasClipPath())) |
| 63 ? IgnoreOverflowClip | 63 ? IgnoreOverflowClip |
| 64 : RespectOverflowClip; | 64 : RespectOverflowClip; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool PaintLayerPainter::paintedOutputInvisible( | 67 bool PaintLayerPainter::paintedOutputInvisible( |
| 68 const PaintLayerPaintingInfo& paintingInfo) { | 68 const PaintLayerPaintingInfo& paintingInfo) { |
| 69 const LayoutObject& layoutObject = *m_paintLayer.layoutObject(); | 69 const LayoutObject& layoutObject = m_paintLayer.layoutObject(); |
| 70 if (layoutObject.hasBackdropFilter()) | 70 if (layoutObject.hasBackdropFilter()) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 73 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 74 if (layoutObject.styleRef().opacity()) | 74 if (layoutObject.styleRef().opacity()) |
| 75 return false; | 75 return false; |
| 76 | 76 |
| 77 const EffectPaintPropertyNode* effect = | 77 const EffectPaintPropertyNode* effect = |
| 78 layoutObject.paintProperties()->effect(); | 78 layoutObject.paintProperties()->effect(); |
| 79 const TransformPaintPropertyNode* transform = | 79 const TransformPaintPropertyNode* transform = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // Non self-painting layers without self-painting descendants don't need to be | 117 // Non self-painting layers without self-painting descendants don't need to be |
| 118 // painted as their layoutObject() should properly paint itself. | 118 // painted as their layoutObject() should properly paint itself. |
| 119 if (!m_paintLayer.isSelfPaintingLayer() && | 119 if (!m_paintLayer.isSelfPaintingLayer() && |
| 120 !m_paintLayer.hasSelfPaintingLayerDescendant()) | 120 !m_paintLayer.hasSelfPaintingLayerDescendant()) |
| 121 return FullyPainted; | 121 return FullyPainted; |
| 122 | 122 |
| 123 if (shouldSuppressPaintingLayer(m_paintLayer)) | 123 if (shouldSuppressPaintingLayer(m_paintLayer)) |
| 124 return FullyPainted; | 124 return FullyPainted; |
| 125 | 125 |
| 126 if (m_paintLayer.layoutObject()->view()->frame() && | 126 if (m_paintLayer.layoutObject().view()->frame() && |
| 127 m_paintLayer.layoutObject()->view()->frame()->shouldThrottleRendering()) | 127 m_paintLayer.layoutObject().view()->frame()->shouldThrottleRendering()) |
| 128 return FullyPainted; | 128 return FullyPainted; |
| 129 | 129 |
| 130 // If this layer is totally invisible then there is nothing to paint. | 130 // If this layer is totally invisible then there is nothing to paint. |
| 131 if (paintedOutputInvisible(paintingInfo)) | 131 if (paintedOutputInvisible(paintingInfo)) |
| 132 return FullyPainted; | 132 return FullyPainted; |
| 133 | 133 |
| 134 if (m_paintLayer.paintsWithTransparency(paintingInfo.getGlobalPaintFlags())) | 134 if (m_paintLayer.paintsWithTransparency(paintingInfo.getGlobalPaintFlags())) |
| 135 paintFlags |= PaintLayerHaveTransparency; | 135 paintFlags |= PaintLayerHaveTransparency; |
| 136 | 136 |
| 137 if (m_paintLayer.paintsWithTransform(paintingInfo.getGlobalPaintFlags()) && | 137 if (m_paintLayer.paintsWithTransform(paintingInfo.getGlobalPaintFlags()) && |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (paintingInfo.getGlobalPaintFlags() & GlobalPaintFlattenCompositingLayers) | 177 if (paintingInfo.getGlobalPaintFlags() & GlobalPaintFlattenCompositingLayers) |
| 178 return false; | 178 return false; |
| 179 if (paintFlags & | 179 if (paintFlags & |
| 180 (PaintLayerPaintingRootBackgroundOnly | | 180 (PaintLayerPaintingRootBackgroundOnly | |
| 181 PaintLayerPaintingOverlayScrollbars | PaintLayerUncachedClipRects)) | 181 PaintLayerPaintingOverlayScrollbars | PaintLayerUncachedClipRects)) |
| 182 return false; | 182 return false; |
| 183 | 183 |
| 184 // Create subsequence for only stacking contexts whose painting are atomic. | 184 // Create subsequence for only stacking contexts whose painting are atomic. |
| 185 // SVG is also painted atomically. | 185 // SVG is also painted atomically. |
| 186 if (!paintLayer.stackingNode()->isStackingContext() && | 186 if (!paintLayer.stackingNode()->isStackingContext() && |
| 187 !paintLayer.layoutObject()->isSVGRoot()) | 187 !paintLayer.layoutObject().isSVGRoot()) |
| 188 return false; | 188 return false; |
| 189 | 189 |
| 190 // The layer doesn't have children. Subsequence caching is not worth because | 190 // The layer doesn't have children. Subsequence caching is not worth because |
| 191 // normally the actual painting will be cheap. | 191 // normally the actual painting will be cheap. |
| 192 // SVG is also painted atomically. | 192 // SVG is also painted atomically. |
| 193 if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren) | 193 if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren) |
| 194 .next() && | 194 .next() && |
| 195 !paintLayer.layoutObject()->isSVGRoot()) | 195 !paintLayer.layoutObject().isSVGRoot()) |
| 196 return false; | 196 return false; |
| 197 | 197 |
| 198 // When in FOUC-avoidance mode, don't cache any subsequences, to avoid having | 198 // When in FOUC-avoidance mode, don't cache any subsequences, to avoid having |
| 199 // to invalidate all of them when leaving this mode. There is an early-out in | 199 // to invalidate all of them when leaving this mode. There is an early-out in |
| 200 // BlockPainter::paintContents that may result in nothing getting painted in | 200 // BlockPainter::paintContents that may result in nothing getting painted in |
| 201 // this mode, in addition to early-out logic in PaintLayerPainter. | 201 // this mode, in addition to early-out logic in PaintLayerPainter. |
| 202 if (paintLayer.layoutObject()->document().didLayoutWithPendingStylesheets()) | 202 if (paintLayer.layoutObject().document().didLayoutWithPendingStylesheets()) |
| 203 return false; | 203 return false; |
| 204 | 204 |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 | 207 |
| 208 static bool shouldRepaintSubsequence( | 208 static bool shouldRepaintSubsequence( |
| 209 PaintLayer& paintLayer, | 209 PaintLayer& paintLayer, |
| 210 const PaintLayerPaintingInfo& paintingInfo, | 210 const PaintLayerPaintingInfo& paintingInfo, |
| 211 ShouldRespectOverflowClipType respectOverflowClip, | 211 ShouldRespectOverflowClipType respectOverflowClip, |
| 212 const LayoutSize& subpixelAccumulation, | 212 const LayoutSize& subpixelAccumulation, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 262 } |
| 263 | 263 |
| 264 PaintResult PaintLayerPainter::paintLayerContents( | 264 PaintResult PaintLayerPainter::paintLayerContents( |
| 265 GraphicsContext& context, | 265 GraphicsContext& context, |
| 266 const PaintLayerPaintingInfo& paintingInfoArg, | 266 const PaintLayerPaintingInfo& paintingInfoArg, |
| 267 PaintLayerFlags paintFlags, | 267 PaintLayerFlags paintFlags, |
| 268 FragmentPolicy fragmentPolicy) { | 268 FragmentPolicy fragmentPolicy) { |
| 269 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; | 269 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; |
| 270 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 270 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 271 RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 271 RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 272 m_paintLayer.layoutObject() && | 272 m_paintLayer.layoutObject().isLayoutView()) { |
| 273 m_paintLayer.layoutObject()->isLayoutView()) { | |
| 274 const auto* objectPaintProperties = | 273 const auto* objectPaintProperties = |
| 275 m_paintLayer.layoutObject()->paintProperties(); | 274 m_paintLayer.layoutObject().paintProperties(); |
| 276 DCHECK(objectPaintProperties && | 275 DCHECK(objectPaintProperties && |
| 277 objectPaintProperties->localBorderBoxProperties()); | 276 objectPaintProperties->localBorderBoxProperties()); |
| 278 PaintChunkProperties properties( | 277 PaintChunkProperties properties( |
| 279 context.getPaintController().currentPaintChunkProperties()); | 278 context.getPaintController().currentPaintChunkProperties()); |
| 280 properties.propertyTreeState = | 279 properties.propertyTreeState = |
| 281 *objectPaintProperties->localBorderBoxProperties(); | 280 *objectPaintProperties->localBorderBoxProperties(); |
| 282 properties.backfaceHidden = | 281 properties.backfaceHidden = m_paintLayer.layoutObject().hasHiddenBackface(); |
| 283 m_paintLayer.layoutObject()->hasHiddenBackface(); | |
| 284 scopedPaintChunkProperties.emplace(context.getPaintController(), | 282 scopedPaintChunkProperties.emplace(context.getPaintController(), |
| 285 m_paintLayer, properties); | 283 m_paintLayer, properties); |
| 286 } | 284 } |
| 287 | 285 |
| 288 DCHECK(m_paintLayer.isSelfPaintingLayer() || | 286 DCHECK(m_paintLayer.isSelfPaintingLayer() || |
| 289 m_paintLayer.hasSelfPaintingLayerDescendant()); | 287 m_paintLayer.hasSelfPaintingLayerDescendant()); |
| 290 DCHECK(!(paintFlags & PaintLayerAppliedTransform)); | 288 DCHECK(!(paintFlags & PaintLayerAppliedTransform)); |
| 291 | 289 |
| 292 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); | 290 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); |
| 293 bool isPaintingOverlayScrollbars = | 291 bool isPaintingOverlayScrollbars = |
| 294 paintFlags & PaintLayerPaintingOverlayScrollbars; | 292 paintFlags & PaintLayerPaintingOverlayScrollbars; |
| 295 bool isPaintingScrollingContent = | 293 bool isPaintingScrollingContent = |
| 296 paintFlags & PaintLayerPaintingCompositingScrollingPhase; | 294 paintFlags & PaintLayerPaintingCompositingScrollingPhase; |
| 297 bool isPaintingCompositedForeground = | 295 bool isPaintingCompositedForeground = |
| 298 paintFlags & PaintLayerPaintingCompositingForegroundPhase; | 296 paintFlags & PaintLayerPaintingCompositingForegroundPhase; |
| 299 bool isPaintingCompositedBackground = | 297 bool isPaintingCompositedBackground = |
| 300 paintFlags & PaintLayerPaintingCompositingBackgroundPhase; | 298 paintFlags & PaintLayerPaintingCompositingBackgroundPhase; |
| 301 bool isPaintingCompositedDecoration = | 299 bool isPaintingCompositedDecoration = |
| 302 paintFlags & PaintLayerPaintingCompositingDecorationPhase; | 300 paintFlags & PaintLayerPaintingCompositingDecorationPhase; |
| 303 bool isPaintingOverflowContents = | 301 bool isPaintingOverflowContents = |
| 304 paintFlags & PaintLayerPaintingOverflowContents; | 302 paintFlags & PaintLayerPaintingOverflowContents; |
| 305 // Outline always needs to be painted even if we have no visible content. | 303 // Outline always needs to be painted even if we have no visible content. |
| 306 // It is painted as part of the decoration phase which paints content that | 304 // It is painted as part of the decoration phase which paints content that |
| 307 // is not scrolled and should be above scrolled content. | 305 // is not scrolled and should be above scrolled content. |
| 308 bool shouldPaintSelfOutline = | 306 bool shouldPaintSelfOutline = |
| 309 isSelfPaintingLayer && !isPaintingOverlayScrollbars && | 307 isSelfPaintingLayer && !isPaintingOverlayScrollbars && |
| 310 (isPaintingCompositedDecoration || !isPaintingScrollingContent) && | 308 (isPaintingCompositedDecoration || !isPaintingScrollingContent) && |
| 311 m_paintLayer.layoutObject()->styleRef().hasOutline(); | 309 m_paintLayer.layoutObject().styleRef().hasOutline(); |
| 312 | 310 |
| 313 PaintResult result = FullyPainted; | 311 PaintResult result = FullyPainted; |
| 314 | 312 |
| 315 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && | 313 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && |
| 316 !m_paintLayer.layoutObject()->isLayoutView()) | 314 !m_paintLayer.layoutObject().isLayoutView()) |
| 317 return result; | 315 return result; |
| 318 | 316 |
| 319 if (m_paintLayer.layoutObject()->view()->frame() && | 317 if (m_paintLayer.layoutObject().view()->frame() && |
| 320 m_paintLayer.layoutObject()->view()->frame()->shouldThrottleRendering()) | 318 m_paintLayer.layoutObject().view()->frame()->shouldThrottleRendering()) |
| 321 return result; | 319 return result; |
| 322 | 320 |
| 323 // Ensure our lists are up to date. | 321 // Ensure our lists are up to date. |
| 324 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); | 322 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); |
| 325 | 323 |
| 326 LayoutSize subpixelAccumulation = | 324 LayoutSize subpixelAccumulation = |
| 327 m_paintLayer.compositingState() == PaintsIntoOwnBacking | 325 m_paintLayer.compositingState() == PaintsIntoOwnBacking |
| 328 ? m_paintLayer.subpixelAccumulation() | 326 ? m_paintLayer.subpixelAccumulation() |
| 329 : paintingInfoArg.subPixelAccumulation; | 327 : paintingInfoArg.subPixelAccumulation; |
| 330 ShouldRespectOverflowClipType respectOverflowClip = | 328 ShouldRespectOverflowClipType respectOverflowClip = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 result = MayBeClippedByPaintDirtyRect; | 360 result = MayBeClippedByPaintDirtyRect; |
| 363 | 361 |
| 364 // These helpers output clip and compositing operations using a RAII pattern. | 362 // These helpers output clip and compositing operations using a RAII pattern. |
| 365 // Stack-allocated-varibles are destructed in the reverse order of | 363 // Stack-allocated-varibles are destructed in the reverse order of |
| 366 // construction, so they are nested properly. | 364 // construction, so they are nested properly. |
| 367 Optional<ClipPathClipper> clipPathClipper; | 365 Optional<ClipPathClipper> clipPathClipper; |
| 368 // Clip-path, like border radius, must not be applied to the contents of a | 366 // Clip-path, like border radius, must not be applied to the contents of a |
| 369 // composited-scrolling container. It must, however, still be applied to the | 367 // composited-scrolling container. It must, however, still be applied to the |
| 370 // mask layer, so that the compositor can properly mask the | 368 // mask layer, so that the compositor can properly mask the |
| 371 // scrolling contents and scrollbars. | 369 // scrolling contents and scrollbars. |
| 372 if (m_paintLayer.layoutObject()->hasClipPath() && | 370 if (m_paintLayer.layoutObject().hasClipPath() && |
| 373 (!m_paintLayer.needsCompositedScrolling() || | 371 (!m_paintLayer.needsCompositedScrolling() || |
| 374 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | | 372 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
| 375 PaintLayerPaintingAncestorClippingMaskPhase)))) { | 373 PaintLayerPaintingAncestorClippingMaskPhase)))) { |
| 376 paintingInfo.ancestorHasClipPathClipping = true; | 374 paintingInfo.ancestorHasClipPathClipping = true; |
| 377 | 375 |
| 378 LayoutRect referenceBox(m_paintLayer.boxForClipPath()); | 376 LayoutRect referenceBox(m_paintLayer.boxForClipPath()); |
| 379 // Note that this isn't going to work correctly if crossing a column | 377 // Note that this isn't going to work correctly if crossing a column |
| 380 // boundary. The reference box should be determined per-fragment, and hence | 378 // boundary. The reference box should be determined per-fragment, and hence |
| 381 // this ought to be performed after fragmentation. | 379 // this ought to be performed after fragmentation. |
| 382 if (m_paintLayer.enclosingPaginationLayer()) | 380 if (m_paintLayer.enclosingPaginationLayer()) |
| 383 m_paintLayer.convertFromFlowThreadToVisualBoundingBoxInAncestor( | 381 m_paintLayer.convertFromFlowThreadToVisualBoundingBoxInAncestor( |
| 384 paintingInfo.rootLayer, referenceBox); | 382 paintingInfo.rootLayer, referenceBox); |
| 385 else | 383 else |
| 386 referenceBox.moveBy(offsetFromRoot); | 384 referenceBox.moveBy(offsetFromRoot); |
| 387 clipPathClipper.emplace( | 385 clipPathClipper.emplace( |
| 388 context, *m_paintLayer.layoutObject()->styleRef().clipPath(), | 386 context, *m_paintLayer.layoutObject().styleRef().clipPath(), |
| 389 *m_paintLayer.layoutObject(), FloatRect(referenceBox), | 387 m_paintLayer.layoutObject(), FloatRect(referenceBox), |
| 390 FloatPoint(referenceBox.location())); | 388 FloatPoint(referenceBox.location())); |
| 391 } | 389 } |
| 392 | 390 |
| 393 Optional<CompositingRecorder> compositingRecorder; | 391 Optional<CompositingRecorder> compositingRecorder; |
| 394 // FIXME: this should be unified further into | 392 // FIXME: this should be unified further into |
| 395 // PaintLayer::paintsWithTransparency(). | 393 // PaintLayer::paintsWithTransparency(). |
| 396 bool shouldCompositeForBlendMode = | 394 bool shouldCompositeForBlendMode = |
| 397 m_paintLayer.stackingNode()->isStackingContext() && | 395 m_paintLayer.stackingNode()->isStackingContext() && |
| 398 m_paintLayer.hasNonIsolatedDescendantWithBlendMode(); | 396 m_paintLayer.hasNonIsolatedDescendantWithBlendMode(); |
| 399 if (shouldCompositeForBlendMode || | 397 if (shouldCompositeForBlendMode || |
| 400 m_paintLayer.paintsWithTransparency(paintingInfo.getGlobalPaintFlags())) { | 398 m_paintLayer.paintsWithTransparency(paintingInfo.getGlobalPaintFlags())) { |
| 401 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent( | 399 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent( |
| 402 paintingInfo.rootLayer, paintingInfo.subPixelAccumulation, | 400 paintingInfo.rootLayer, paintingInfo.subPixelAccumulation, |
| 403 paintingInfo.getGlobalPaintFlags())); | 401 paintingInfo.getGlobalPaintFlags())); |
| 404 compositingRecorder.emplace( | 402 compositingRecorder.emplace( |
| 405 context, *m_paintLayer.layoutObject(), | 403 context, m_paintLayer.layoutObject(), |
| 406 WebCoreCompositeToSkiaComposite( | 404 WebCoreCompositeToSkiaComposite( |
| 407 CompositeSourceOver, | 405 CompositeSourceOver, |
| 408 m_paintLayer.layoutObject()->style()->blendMode()), | 406 m_paintLayer.layoutObject().style()->blendMode()), |
| 409 m_paintLayer.layoutObject()->opacity(), &compositingBounds); | 407 m_paintLayer.layoutObject().opacity(), &compositingBounds); |
| 410 } | 408 } |
| 411 | 409 |
| 412 PaintLayerPaintingInfo localPaintingInfo(paintingInfo); | 410 PaintLayerPaintingInfo localPaintingInfo(paintingInfo); |
| 413 localPaintingInfo.subPixelAccumulation = subpixelAccumulation; | 411 localPaintingInfo.subPixelAccumulation = subpixelAccumulation; |
| 414 | 412 |
| 415 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && | 413 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && |
| 416 isSelfPaintingLayer && !isPaintingOverlayScrollbars; | 414 isSelfPaintingLayer && !isPaintingOverlayScrollbars; |
| 417 | 415 |
| 418 PaintLayerFragments layerFragments; | 416 PaintLayerFragments layerFragments; |
| 419 if (shouldPaintContent || shouldPaintSelfOutline || | 417 if (shouldPaintContent || shouldPaintSelfOutline || |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 491 } |
| 494 } | 492 } |
| 495 | 493 |
| 496 Optional<ScopedPaintChunkProperties> contentScopedPaintChunkProperties; | 494 Optional<ScopedPaintChunkProperties> contentScopedPaintChunkProperties; |
| 497 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 495 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 498 !scopedPaintChunkProperties.has_value()) { | 496 !scopedPaintChunkProperties.has_value()) { |
| 499 // If layoutObject() is a LayoutView and root layer scrolling is enabled, | 497 // If layoutObject() is a LayoutView and root layer scrolling is enabled, |
| 500 // the LayoutView's paint properties will already have been applied at | 498 // the LayoutView's paint properties will already have been applied at |
| 501 // the top of this method, in scopedPaintChunkProperties. | 499 // the top of this method, in scopedPaintChunkProperties. |
| 502 DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() && | 500 DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() && |
| 503 m_paintLayer.layoutObject() && | 501 m_paintLayer.layoutObject().isLayoutView())); |
| 504 m_paintLayer.layoutObject()->isLayoutView())); | |
| 505 const auto* objectPaintProperties = | 502 const auto* objectPaintProperties = |
| 506 m_paintLayer.layoutObject()->paintProperties(); | 503 m_paintLayer.layoutObject().paintProperties(); |
| 507 DCHECK(objectPaintProperties && | 504 DCHECK(objectPaintProperties && |
| 508 objectPaintProperties->localBorderBoxProperties()); | 505 objectPaintProperties->localBorderBoxProperties()); |
| 509 PaintChunkProperties properties( | 506 PaintChunkProperties properties( |
| 510 context.getPaintController().currentPaintChunkProperties()); | 507 context.getPaintController().currentPaintChunkProperties()); |
| 511 properties.propertyTreeState = | 508 properties.propertyTreeState = |
| 512 *objectPaintProperties->localBorderBoxProperties(); | 509 *objectPaintProperties->localBorderBoxProperties(); |
| 513 properties.backfaceHidden = | 510 properties.backfaceHidden = m_paintLayer.layoutObject().hasHiddenBackface(); |
| 514 m_paintLayer.layoutObject()->hasHiddenBackface(); | |
| 515 contentScopedPaintChunkProperties.emplace(context.getPaintController(), | 511 contentScopedPaintChunkProperties.emplace(context.getPaintController(), |
| 516 m_paintLayer, properties); | 512 m_paintLayer, properties); |
| 517 } | 513 } |
| 518 | 514 |
| 519 bool selectionOnly = | 515 bool selectionOnly = |
| 520 localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSelectionOnly; | 516 localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSelectionOnly; |
| 521 { // Begin block for the lifetime of any filter. | 517 { // Begin block for the lifetime of any filter. |
| 522 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, | 518 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, |
| 523 layerFragments.isEmpty() | 519 layerFragments.isEmpty() |
| 524 ? ClipRect() | 520 ? ClipRect() |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 result = MayBeClippedByPaintDirtyRect; | 565 result = MayBeClippedByPaintDirtyRect; |
| 570 } | 566 } |
| 571 | 567 |
| 572 if (shouldPaintOverlayScrollbars) | 568 if (shouldPaintOverlayScrollbars) |
| 573 paintOverflowControlsForFragments(layerFragments, context, | 569 paintOverflowControlsForFragments(layerFragments, context, |
| 574 localPaintingInfo, paintFlags); | 570 localPaintingInfo, paintFlags); |
| 575 } // FilterPainter block | 571 } // FilterPainter block |
| 576 | 572 |
| 577 bool shouldPaintMask = | 573 bool shouldPaintMask = |
| 578 (paintFlags & PaintLayerPaintingCompositingMaskPhase) && | 574 (paintFlags & PaintLayerPaintingCompositingMaskPhase) && |
| 579 shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && | 575 shouldPaintContent && m_paintLayer.layoutObject().hasMask() && |
| 580 !selectionOnly; | 576 !selectionOnly; |
| 581 bool shouldPaintClippingMask = | 577 bool shouldPaintClippingMask = |
| 582 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | | 578 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | |
| 583 PaintLayerPaintingAncestorClippingMaskPhase)) && | 579 PaintLayerPaintingAncestorClippingMaskPhase)) && |
| 584 shouldPaintContent && !selectionOnly; | 580 shouldPaintContent && !selectionOnly; |
| 585 | 581 |
| 586 if (shouldPaintMask) { | 582 if (shouldPaintMask) { |
| 587 paintMaskForFragments(layerFragments, context, localPaintingInfo, | 583 paintMaskForFragments(layerFragments, context, localPaintingInfo, |
| 588 paintFlags); | 584 paintFlags); |
| 589 } | 585 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 // the layer. | 629 // the layer. |
| 634 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, | 630 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, |
| 635 fragment.backgroundRect.rect(), | 631 fragment.backgroundRect.rect(), |
| 636 newOffsetFromRoot)) | 632 newOffsetFromRoot)) |
| 637 return true; | 633 return true; |
| 638 } | 634 } |
| 639 return false; | 635 return false; |
| 640 } | 636 } |
| 641 | 637 |
| 642 inline bool PaintLayerPainter::isFixedPositionObjectInPagedMedia() { | 638 inline bool PaintLayerPainter::isFixedPositionObjectInPagedMedia() { |
| 643 LayoutObject* object = m_paintLayer.layoutObject(); | 639 LayoutObject& object = m_paintLayer.layoutObject(); |
| 644 LayoutView* view = object->view(); | 640 LayoutView* view = object.view(); |
| 645 return object->styleRef().position() == EPosition::kFixed && | 641 return object.styleRef().position() == EPosition::kFixed && |
| 646 object->container() == view && view->pageLogicalHeight() && | 642 object.container() == view && view->pageLogicalHeight() && |
| 647 // TODO(crbug.com/619094): Figure out the correct behaviour for fixed | 643 // TODO(crbug.com/619094): Figure out the correct behaviour for fixed |
| 648 // position objects in paged media with vertical writing modes. | 644 // position objects in paged media with vertical writing modes. |
| 649 view->isHorizontalWritingMode(); | 645 view->isHorizontalWritingMode(); |
| 650 } | 646 } |
| 651 | 647 |
| 652 void PaintLayerPainter::repeatFixedPositionObjectInPages( | 648 void PaintLayerPainter::repeatFixedPositionObjectInPages( |
| 653 const PaintLayerFragment& singleFragmentIgnoredPagination, | 649 const PaintLayerFragment& singleFragmentIgnoredPagination, |
| 654 const PaintLayerPaintingInfo& paintingInfo, | 650 const PaintLayerPaintingInfo& paintingInfo, |
| 655 PaintLayerFragments& layerFragments) { | 651 PaintLayerFragments& layerFragments) { |
| 656 DCHECK(isFixedPositionObjectInPagedMedia()); | 652 DCHECK(isFixedPositionObjectInPagedMedia()); |
| 657 | 653 |
| 658 LayoutView* view = m_paintLayer.layoutObject()->view(); | 654 LayoutView* view = m_paintLayer.layoutObject().view(); |
| 659 unsigned pages = | 655 unsigned pages = |
| 660 ceilf(view->documentRect().height() / view->pageLogicalHeight()); | 656 ceilf(view->documentRect().height() / view->pageLogicalHeight()); |
| 661 | 657 |
| 662 // The fixed position object is offset from the top of the page, so remove | 658 // The fixed position object is offset from the top of the page, so remove |
| 663 // any scroll offset. | 659 // any scroll offset. |
| 664 LayoutPoint offsetFromRoot; | 660 LayoutPoint offsetFromRoot; |
| 665 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 661 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
| 666 LayoutSize offsetAdjustment = m_paintLayer.location() - offsetFromRoot; | 662 LayoutSize offsetAdjustment = m_paintLayer.location() - offsetFromRoot; |
| 667 layerFragments.push_back(singleFragmentIgnoredPagination); | 663 layerFragments.push_back(singleFragmentIgnoredPagination); |
| 668 layerFragments[0].paginationOffset += offsetAdjustment; | 664 layerFragments[0].paginationOffset += offsetAdjustment; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 if (parentLayer && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 761 if (parentLayer && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 766 ClipRect clipRectForFragment(ancestorBackgroundClipRect); | 762 ClipRect clipRectForFragment(ancestorBackgroundClipRect); |
| 767 // A fixed-position object is repeated on every page instead of paginated, | 763 // A fixed-position object is repeated on every page instead of paginated, |
| 768 // so we should apply the original ancestor clip rect. | 764 // so we should apply the original ancestor clip rect. |
| 769 if (!isFixedPositionObjectInPagedMedia) | 765 if (!isFixedPositionObjectInPagedMedia) |
| 770 clipRectForFragment.moveBy(fragment.paginationOffset); | 766 clipRectForFragment.moveBy(fragment.paginationOffset); |
| 771 clipRectForFragment.intersect(fragment.backgroundRect); | 767 clipRectForFragment.intersect(fragment.backgroundRect); |
| 772 if (clipRectForFragment.isEmpty()) | 768 if (clipRectForFragment.isEmpty()) |
| 773 continue; | 769 continue; |
| 774 if (needsToClip(paintingInfo, clipRectForFragment)) { | 770 if (needsToClip(paintingInfo, clipRectForFragment)) { |
| 775 clipRecorder.emplace(context, *parentLayer->layoutObject(), | 771 clipRecorder.emplace(context, parentLayer->layoutObject(), |
| 776 DisplayItem::kClipLayerParent, clipRectForFragment, | 772 DisplayItem::kClipLayerParent, clipRectForFragment, |
| 777 paintingInfo.rootLayer, fragment.paginationOffset, | 773 paintingInfo.rootLayer, fragment.paginationOffset, |
| 778 paintFlags); | 774 paintFlags); |
| 779 } | 775 } |
| 780 } | 776 } |
| 781 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, | 777 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, |
| 782 fragment.paginationOffset) == | 778 fragment.paginationOffset) == |
| 783 MayBeClippedByPaintDirtyRect) | 779 MayBeClippedByPaintDirtyRect) |
| 784 result = MayBeClippedByPaintDirtyRect; | 780 result = MayBeClippedByPaintDirtyRect; |
| 785 } | 781 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 801 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags())); | 797 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags())); |
| 802 IntPoint roundedDelta = roundedIntPoint(delta); | 798 IntPoint roundedDelta = roundedIntPoint(delta); |
| 803 transform.translateRight(roundedDelta.x(), roundedDelta.y()); | 799 transform.translateRight(roundedDelta.x(), roundedDelta.y()); |
| 804 LayoutSize adjustedSubPixelAccumulation = | 800 LayoutSize adjustedSubPixelAccumulation = |
| 805 paintingInfo.subPixelAccumulation + (delta - roundedDelta); | 801 paintingInfo.subPixelAccumulation + (delta - roundedDelta); |
| 806 | 802 |
| 807 // TODO(jbroman): Put the real transform origin here, instead of using a | 803 // TODO(jbroman): Put the real transform origin here, instead of using a |
| 808 // matrix with the origin baked in. | 804 // matrix with the origin baked in. |
| 809 FloatPoint3D transformOrigin; | 805 FloatPoint3D transformOrigin; |
| 810 Transform3DRecorder transform3DRecorder( | 806 Transform3DRecorder transform3DRecorder( |
| 811 context, *m_paintLayer.layoutObject(), | 807 context, m_paintLayer.layoutObject(), |
| 812 DisplayItem::kTransform3DElementTransform, transform, transformOrigin); | 808 DisplayItem::kTransform3DElementTransform, transform, transformOrigin); |
| 813 | 809 |
| 814 // Now do a paint with the root layer shifted to be us. | 810 // Now do a paint with the root layer shifted to be us. |
| 815 PaintLayerPaintingInfo transformedPaintingInfo( | 811 PaintLayerPaintingInfo transformedPaintingInfo( |
| 816 &m_paintLayer, LayoutRect(enclosingIntRect(transform.inverse().mapRect( | 812 &m_paintLayer, LayoutRect(enclosingIntRect(transform.inverse().mapRect( |
| 817 paintingInfo.paintDirtyRect))), | 813 paintingInfo.paintDirtyRect))), |
| 818 paintingInfo.getGlobalPaintFlags(), adjustedSubPixelAccumulation); | 814 paintingInfo.getGlobalPaintFlags(), adjustedSubPixelAccumulation); |
| 819 transformedPaintingInfo.ancestorHasClipPathClipping = | 815 transformedPaintingInfo.ancestorHasClipPathClipping = |
| 820 paintingInfo.ancestorHasClipPathClipping; | 816 paintingInfo.ancestorHasClipPathClipping; |
| 821 | 817 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 841 #endif | 837 #endif |
| 842 | 838 |
| 843 PaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode(), | 839 PaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode(), |
| 844 childrenToVisit); | 840 childrenToVisit); |
| 845 PaintLayerStackingNode* child = iterator.next(); | 841 PaintLayerStackingNode* child = iterator.next(); |
| 846 if (!child) | 842 if (!child) |
| 847 return result; | 843 return result; |
| 848 | 844 |
| 849 IntSize scrollOffsetAccumulationForChildren = | 845 IntSize scrollOffsetAccumulationForChildren = |
| 850 paintingInfo.scrollOffsetAccumulation; | 846 paintingInfo.scrollOffsetAccumulation; |
| 851 if (m_paintLayer.layoutObject()->hasOverflowClip()) | 847 if (m_paintLayer.layoutObject().hasOverflowClip()) |
| 852 scrollOffsetAccumulationForChildren += | 848 scrollOffsetAccumulationForChildren += |
| 853 m_paintLayer.layoutBox()->scrolledContentOffset(); | 849 m_paintLayer.layoutBox()->scrolledContentOffset(); |
| 854 | 850 |
| 855 for (; child; child = iterator.next()) { | 851 for (; child; child = iterator.next()) { |
| 856 PaintLayerPainter childPainter(*child->layer()); | 852 PaintLayerPainter childPainter(*child->layer()); |
| 857 // If this Layer should paint into its own backing or a grouped backing, | 853 // If this Layer should paint into its own backing or a grouped backing, |
| 858 // that will be done via CompositedLayerMapping::paintContents() and | 854 // that will be done via CompositedLayerMapping::paintContents() and |
| 859 // CompositedLayerMapping::doPaintTask(). | 855 // CompositedLayerMapping::doPaintTask(). |
| 860 if (!childPainter.shouldPaintLayerInSoftwareMode( | 856 if (!childPainter.shouldPaintLayerInSoftwareMode( |
| 861 paintingInfo.getGlobalPaintFlags(), paintFlags)) | 857 paintingInfo.getGlobalPaintFlags(), paintFlags)) |
| 862 continue; | 858 continue; |
| 863 | 859 |
| 864 PaintLayerPaintingInfo childPaintingInfo = paintingInfo; | 860 PaintLayerPaintingInfo childPaintingInfo = paintingInfo; |
| 865 childPaintingInfo.scrollOffsetAccumulation = | 861 childPaintingInfo.scrollOffsetAccumulation = |
| 866 scrollOffsetAccumulationForChildren; | 862 scrollOffsetAccumulationForChildren; |
| 867 // Rare case: accumulate scroll offset of non-stacking-context ancestors up | 863 // Rare case: accumulate scroll offset of non-stacking-context ancestors up |
| 868 // to m_paintLayer. | 864 // to m_paintLayer. |
| 869 for (PaintLayer* parentLayer = child->layer()->parent(); | 865 for (PaintLayer* parentLayer = child->layer()->parent(); |
| 870 parentLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { | 866 parentLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { |
| 871 if (parentLayer->layoutObject()->hasOverflowClip()) | 867 if (parentLayer->layoutObject().hasOverflowClip()) |
| 872 childPaintingInfo.scrollOffsetAccumulation += | 868 childPaintingInfo.scrollOffsetAccumulation += |
| 873 parentLayer->layoutBox()->scrolledContentOffset(); | 869 parentLayer->layoutBox()->scrolledContentOffset(); |
| 874 } | 870 } |
| 875 | 871 |
| 876 if (childPainter.paint(context, childPaintingInfo, paintFlags) == | 872 if (childPainter.paint(context, childPaintingInfo, paintFlags) == |
| 877 MayBeClippedByPaintDirtyRect) | 873 MayBeClippedByPaintDirtyRect) |
| 878 result = MayBeClippedByPaintDirtyRect; | 874 result = MayBeClippedByPaintDirtyRect; |
| 879 } | 875 } |
| 880 | 876 |
| 881 return result; | 877 return result; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 903 if (layerFragments.size() > 1) | 899 if (layerFragments.size() > 1) |
| 904 cacheSkipper.emplace(context); | 900 cacheSkipper.emplace(context); |
| 905 | 901 |
| 906 for (auto& fragment : layerFragments) { | 902 for (auto& fragment : layerFragments) { |
| 907 // We need to apply the same clips and transforms that | 903 // We need to apply the same clips and transforms that |
| 908 // paintFragmentWithPhase would have. | 904 // paintFragmentWithPhase would have. |
| 909 LayoutRect cullRect = fragment.backgroundRect.rect(); | 905 LayoutRect cullRect = fragment.backgroundRect.rect(); |
| 910 | 906 |
| 911 Optional<LayerClipRecorder> clipRecorder; | 907 Optional<LayerClipRecorder> clipRecorder; |
| 912 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { | 908 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { |
| 913 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), | 909 clipRecorder.emplace(context, m_paintLayer.layoutObject(), |
| 914 DisplayItem::kClipLayerOverflowControls, | 910 DisplayItem::kClipLayerOverflowControls, |
| 915 fragment.backgroundRect, localPaintingInfo.rootLayer, | 911 fragment.backgroundRect, localPaintingInfo.rootLayer, |
| 916 fragment.paginationOffset, paintFlags); | 912 fragment.paginationOffset, paintFlags); |
| 917 } | 913 } |
| 918 | 914 |
| 919 Optional<ScrollRecorder> scrollRecorder; | 915 Optional<ScrollRecorder> scrollRecorder; |
| 920 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 916 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 921 !localPaintingInfo.scrollOffsetAccumulation.isZero()) { | 917 !localPaintingInfo.scrollOffsetAccumulation.isZero()) { |
| 922 cullRect.move(localPaintingInfo.scrollOffsetAccumulation); | 918 cullRect.move(localPaintingInfo.scrollOffsetAccumulation); |
| 923 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), | 919 scrollRecorder.emplace(context, m_paintLayer.layoutObject(), |
| 924 DisplayItem::kScrollOverflowControls, | 920 DisplayItem::kScrollOverflowControls, |
| 925 localPaintingInfo.scrollOffsetAccumulation); | 921 localPaintingInfo.scrollOffsetAccumulation); |
| 926 } | 922 } |
| 927 | 923 |
| 928 // We pass IntPoint() as the paint offset here, because | 924 // We pass IntPoint() as the paint offset here, because |
| 929 // ScrollableArea::paintOverflowControls just ignores it and uses the | 925 // ScrollableArea::paintOverflowControls just ignores it and uses the |
| 930 // offset found in a previous pass. | 926 // offset found in a previous pass. |
| 931 CullRect snappedCullRect(pixelSnappedIntRect(cullRect)); | 927 CullRect snappedCullRect(pixelSnappedIntRect(cullRect)); |
| 932 ScrollableAreaPainter(*scrollableArea) | 928 ScrollableAreaPainter(*scrollableArea) |
| 933 .paintOverflowControls(context, IntPoint(), snappedCullRect, true); | 929 .paintOverflowControls(context, IntPoint(), snappedCullRect, true); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 958 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; | 954 clippingRule = LayerClipRecorder::DoNotIncludeSelfForBorderRadius; |
| 959 break; | 955 break; |
| 960 default: | 956 default: |
| 961 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; | 957 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; |
| 962 break; | 958 break; |
| 963 } | 959 } |
| 964 | 960 |
| 965 // TODO(schenney): Nested border-radius clips are not applied to composited | 961 // TODO(schenney): Nested border-radius clips are not applied to composited |
| 966 // children, probably due to an incorrect clipRoot. | 962 // children, probably due to an incorrect clipRoot. |
| 967 // https://bugs.chromium.org/p/chromium/issues/detail?id=672561 | 963 // https://bugs.chromium.org/p/chromium/issues/detail?id=672561 |
| 968 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, | 964 clipRecorder.emplace(context, m_paintLayer.layoutObject(), clipType, |
| 969 clipRect, paintingInfo.rootLayer, | 965 clipRect, paintingInfo.rootLayer, |
| 970 fragment.paginationOffset, paintFlags, clippingRule); | 966 fragment.paginationOffset, paintFlags, clippingRule); |
| 971 } | 967 } |
| 972 | 968 |
| 973 // If we are painting a mask for any reason and we have already processed the | 969 // If we are painting a mask for any reason and we have already processed the |
| 974 // clips, there is no need to go through the remaining painting pipeline. | 970 // clips, there is no need to go through the remaining painting pipeline. |
| 975 // We know that the mask just needs the area bounded by the clip rects to be | 971 // We know that the mask just needs the area bounded by the clip rects to be |
| 976 // filled with black. | 972 // filled with black. |
| 977 if (clipRecorder && phase == PaintPhaseClippingMask) { | 973 if (clipRecorder && phase == PaintPhaseClippingMask) { |
| 978 fillMaskingFragment(context, clipRect); | 974 fillMaskingFragment(context, clipRect); |
| 979 return; | 975 return; |
| 980 } | 976 } |
| 981 | 977 |
| 982 LayoutRect newCullRect(clipRect.rect()); | 978 LayoutRect newCullRect(clipRect.rect()); |
| 983 Optional<ScrollRecorder> scrollRecorder; | 979 Optional<ScrollRecorder> scrollRecorder; |
| 984 LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation(); | 980 LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation(); |
| 985 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 981 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 986 const auto* objectPaintProperties = | 982 const auto* objectPaintProperties = |
| 987 m_paintLayer.layoutObject()->paintProperties(); | 983 m_paintLayer.layoutObject().paintProperties(); |
| 988 DCHECK(objectPaintProperties && | 984 DCHECK(objectPaintProperties && |
| 989 objectPaintProperties->localBorderBoxProperties()); | 985 objectPaintProperties->localBorderBoxProperties()); |
| 990 paintOffset += m_paintLayer.layoutObject()->paintOffset(); | 986 paintOffset += m_paintLayer.layoutObject().paintOffset(); |
| 991 newCullRect.move(paintingInfo.scrollOffsetAccumulation); | 987 newCullRect.move(paintingInfo.scrollOffsetAccumulation); |
| 992 } else { | 988 } else { |
| 993 paintOffset += toSize(fragment.layerBounds.location()); | 989 paintOffset += toSize(fragment.layerBounds.location()); |
| 994 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { | 990 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { |
| 995 // As a descendant of the root layer, m_paintLayer's painting is not | 991 // As a descendant of the root layer, m_paintLayer's painting is not |
| 996 // controlled by the ScrollRecorders created by BlockPainter of the | 992 // controlled by the ScrollRecorders created by BlockPainter of the |
| 997 // ancestor layers up to the root layer, so we need to issue | 993 // ancestor layers up to the root layer, so we need to issue |
| 998 // ScrollRecorder for this layer seperately, with the scroll offset | 994 // ScrollRecorder for this layer seperately, with the scroll offset |
| 999 // accumulated from the root layer to the parent of this layer, to get the | 995 // accumulated from the root layer to the parent of this layer, to get the |
| 1000 // same result as ScrollRecorder in BlockPainter. | 996 // same result as ScrollRecorder in BlockPainter. |
| 1001 paintOffset += paintingInfo.scrollOffsetAccumulation; | 997 paintOffset += paintingInfo.scrollOffsetAccumulation; |
| 1002 | 998 |
| 1003 newCullRect.move(paintingInfo.scrollOffsetAccumulation); | 999 newCullRect.move(paintingInfo.scrollOffsetAccumulation); |
| 1004 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, | 1000 scrollRecorder.emplace(context, m_paintLayer.layoutObject(), phase, |
| 1005 paintingInfo.scrollOffsetAccumulation); | 1001 paintingInfo.scrollOffsetAccumulation); |
| 1006 } | 1002 } |
| 1007 } | 1003 } |
| 1008 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, | 1004 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, |
| 1009 paintingInfo.getGlobalPaintFlags(), paintFlags, | 1005 paintingInfo.getGlobalPaintFlags(), paintFlags, |
| 1010 paintingInfo.rootLayer->layoutObject()); | 1006 &paintingInfo.rootLayer->layoutObject()); |
| 1011 | 1007 |
| 1012 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); | 1008 m_paintLayer.layoutObject().paint(paintInfo, paintOffset); |
| 1013 } | 1009 } |
| 1014 | 1010 |
| 1015 void PaintLayerPainter::paintBackgroundForFragments( | 1011 void PaintLayerPainter::paintBackgroundForFragments( |
| 1016 const PaintLayerFragments& layerFragments, | 1012 const PaintLayerFragments& layerFragments, |
| 1017 GraphicsContext& context, | 1013 GraphicsContext& context, |
| 1018 const LayoutRect& transparencyPaintDirtyRect, | 1014 const LayoutRect& transparencyPaintDirtyRect, |
| 1019 const PaintLayerPaintingInfo& localPaintingInfo, | 1015 const PaintLayerPaintingInfo& localPaintingInfo, |
| 1020 PaintLayerFlags paintFlags) { | 1016 PaintLayerFlags paintFlags) { |
| 1021 Optional<DisplayItemCacheSkipper> cacheSkipper; | 1017 Optional<DisplayItemCacheSkipper> cacheSkipper; |
| 1022 if (layerFragments.size() > 1) | 1018 if (layerFragments.size() > 1) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1038 DCHECK(!(paintFlags & PaintLayerPaintingRootBackgroundOnly)); | 1034 DCHECK(!(paintFlags & PaintLayerPaintingRootBackgroundOnly)); |
| 1039 | 1035 |
| 1040 // Optimize clipping for the single fragment case. | 1036 // Optimize clipping for the single fragment case. |
| 1041 bool shouldClip = localPaintingInfo.clipToDirtyRect && | 1037 bool shouldClip = localPaintingInfo.clipToDirtyRect && |
| 1042 layerFragments.size() == 1 && | 1038 layerFragments.size() == 1 && |
| 1043 !layerFragments[0].foregroundRect.isEmpty(); | 1039 !layerFragments[0].foregroundRect.isEmpty(); |
| 1044 ClipState clipState = HasNotClipped; | 1040 ClipState clipState = HasNotClipped; |
| 1045 Optional<LayerClipRecorder> clipRecorder; | 1041 Optional<LayerClipRecorder> clipRecorder; |
| 1046 if (shouldClip && | 1042 if (shouldClip && |
| 1047 needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { | 1043 needsToClip(localPaintingInfo, layerFragments[0].foregroundRect)) { |
| 1048 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), | 1044 clipRecorder.emplace( |
| 1049 DisplayItem::kClipLayerForeground, | 1045 context, m_paintLayer.layoutObject(), DisplayItem::kClipLayerForeground, |
| 1050 layerFragments[0].foregroundRect, | 1046 layerFragments[0].foregroundRect, localPaintingInfo.rootLayer, |
| 1051 localPaintingInfo.rootLayer, | 1047 layerFragments[0].paginationOffset, paintFlags); |
| 1052 layerFragments[0].paginationOffset, paintFlags); | |
| 1053 clipState = HasClipped; | 1048 clipState = HasClipped; |
| 1054 } | 1049 } |
| 1055 | 1050 |
| 1056 // We have to loop through every fragment multiple times, since we have to | 1051 // We have to loop through every fragment multiple times, since we have to |
| 1057 // issue paint invalidations in each specific phase in order for interleaving | 1052 // issue paint invalidations in each specific phase in order for interleaving |
| 1058 // of the fragments to work properly. | 1053 // of the fragments to work properly. |
| 1059 if (selectionOnly) { | 1054 if (selectionOnly) { |
| 1060 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments, | 1055 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments, |
| 1061 context, localPaintingInfo, paintFlags, | 1056 context, localPaintingInfo, paintFlags, |
| 1062 clipState); | 1057 clipState); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 GraphicsContext& context, | 1149 GraphicsContext& context, |
| 1155 const PaintLayerPaintingInfo& localPaintingInfo, | 1150 const PaintLayerPaintingInfo& localPaintingInfo, |
| 1156 PaintLayerFlags paintFlags) { | 1151 PaintLayerFlags paintFlags) { |
| 1157 Optional<DisplayItemCacheSkipper> cacheSkipper; | 1152 Optional<DisplayItemCacheSkipper> cacheSkipper; |
| 1158 if (layerFragments.size() > 1) | 1153 if (layerFragments.size() > 1) |
| 1159 cacheSkipper.emplace(context); | 1154 cacheSkipper.emplace(context); |
| 1160 | 1155 |
| 1161 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; | 1156 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; |
| 1162 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1157 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1163 const auto* objectPaintProperties = | 1158 const auto* objectPaintProperties = |
| 1164 m_paintLayer.layoutObject()->paintProperties(); | 1159 m_paintLayer.layoutObject().paintProperties(); |
| 1165 DCHECK(objectPaintProperties && objectPaintProperties->mask()); | 1160 DCHECK(objectPaintProperties && objectPaintProperties->mask()); |
| 1166 PaintChunkProperties properties( | 1161 PaintChunkProperties properties( |
| 1167 context.getPaintController().currentPaintChunkProperties()); | 1162 context.getPaintController().currentPaintChunkProperties()); |
| 1168 properties.propertyTreeState.setEffect(objectPaintProperties->mask()); | 1163 properties.propertyTreeState.setEffect(objectPaintProperties->mask()); |
| 1169 scopedPaintChunkProperties.emplace(context.getPaintController(), | 1164 scopedPaintChunkProperties.emplace(context.getPaintController(), |
| 1170 m_paintLayer, properties); | 1165 m_paintLayer, properties); |
| 1171 } | 1166 } |
| 1172 | 1167 |
| 1173 for (auto& fragment : layerFragments) | 1168 for (auto& fragment : layerFragments) |
| 1174 paintFragmentWithPhase(PaintPhaseMask, fragment, context, | 1169 paintFragmentWithPhase(PaintPhaseMask, fragment, context, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1201 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, | 1196 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, |
| 1202 LayoutRect(enclosingIntRect(damageRect)), | 1197 LayoutRect(enclosingIntRect(damageRect)), |
| 1203 paintFlags, LayoutSize()); | 1198 paintFlags, LayoutSize()); |
| 1204 paint(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 1199 paint(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 1205 | 1200 |
| 1206 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 1201 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 1207 } | 1202 } |
| 1208 | 1203 |
| 1209 void PaintLayerPainter::fillMaskingFragment(GraphicsContext& context, | 1204 void PaintLayerPainter::fillMaskingFragment(GraphicsContext& context, |
| 1210 const ClipRect& clipRect) { | 1205 const ClipRect& clipRect) { |
| 1211 const LayoutObject& layoutObject = *m_paintLayer.layoutObject(); | 1206 const LayoutObject& layoutObject = m_paintLayer.layoutObject(); |
| 1212 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 1207 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
| 1213 context, layoutObject, PaintPhaseClippingMask)) | 1208 context, layoutObject, PaintPhaseClippingMask)) |
| 1214 return; | 1209 return; |
| 1215 | 1210 |
| 1216 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); | 1211 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
| 1217 LayoutObjectDrawingRecorder drawingRecorder( | 1212 LayoutObjectDrawingRecorder drawingRecorder( |
| 1218 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); | 1213 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); |
| 1219 context.fillRect(snappedClipRect, Color::black); | 1214 context.fillRect(snappedClipRect, Color::black); |
| 1220 } | 1215 } |
| 1221 | 1216 |
| 1222 } // namespace blink | 1217 } // namespace blink |
| OLD | NEW |