| 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/DeprecatedPaintLayerPainter.h" | 6 #include "core/paint/DeprecatedPaintLayerPainter.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl
osingIntRect(damageRect)), globalPaintFlags, LayoutSize(), paintingRoot); | 48 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl
osingIntRect(damageRect)), globalPaintFlags, LayoutSize(), paintingRoot); |
| 49 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) | 49 if (shouldPaintLayerInSoftwareMode(globalPaintFlags, paintFlags)) |
| 50 paintLayer(context, paintingInfo, paintFlags); | 50 paintLayer(context, paintingInfo, paintFlags); |
| 51 } | 51 } |
| 52 | 52 |
| 53 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint
Flags, const LayoutObject* layoutObject) | 53 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint
Flags, const LayoutObject* layoutObject) |
| 54 { | 54 { |
| 55 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai
ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO
verflowClip : RespectOverflowClip; | 55 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai
ntLayerPaintingChildClippingMaskPhase && layoutObject->hasClipPath())) ? IgnoreO
verflowClip : RespectOverflowClip; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void DeprecatedPaintLayerPainter::paintLayer(GraphicsContext* context, const Dep
recatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 58 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintLayer
(GraphicsContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo,
PaintLayerFlags paintFlags) |
| 59 { |
| 60 PaintResult result = paintLayerInternal(context, paintingInfo, paintFlags); |
| 61 m_paintLayer.clearNeedsRepaint(); |
| 62 return result; |
| 63 } |
| 64 |
| 65 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintLayer
Internal(GraphicsContext* context, const DeprecatedPaintLayerPaintingInfo& paint
ingInfo, PaintLayerFlags paintFlags) |
| 59 { | 66 { |
| 60 // https://code.google.com/p/chromium/issues/detail?id=343772 | 67 // https://code.google.com/p/chromium/issues/detail?id=343772 |
| 61 DisableCompositingQueryAsserts disabler; | 68 DisableCompositingQueryAsserts disabler; |
| 62 | 69 |
| 63 if (m_paintLayer.compositingState() != NotComposited) { | 70 if (m_paintLayer.compositingState() != NotComposited) { |
| 64 if (paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLayer
s) { | 71 if (paintingInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLayer
s) { |
| 65 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? Th
at's for printing and drag-image. | 72 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? Th
at's for printing and drag-image. |
| 66 // FIXME: why isn't the code here global, as opposed to being set on
each paintLayer() call? | 73 // FIXME: why isn't the code here global, as opposed to being set on
each paintLayer() call? |
| 67 paintFlags |= PaintLayerUncachedClipRects; | 74 paintFlags |= PaintLayerUncachedClipRects; |
| 68 } | 75 } |
| 69 } | 76 } |
| 70 | 77 |
| 71 // Non self-painting leaf layers don't need to be painted as their layoutObj
ect() should properly paint itself. | 78 // Non self-painting leaf layers don't need to be painted as their layoutObj
ect() should properly paint itself. |
| 72 if (!m_paintLayer.isSelfPaintingLayer() && !m_paintLayer.hasSelfPaintingLaye
rDescendant()) { | 79 if (!m_paintLayer.isSelfPaintingLayer() && !m_paintLayer.hasSelfPaintingLaye
rDescendant()) { |
| 73 ASSERT(!m_paintLayer.needsRepaint()); | 80 ASSERT(!m_paintLayer.needsRepaint()); |
| 74 return; | 81 return FullyPainted; |
| 75 } | 82 } |
| 76 | 83 |
| 77 bool needsRepaint = m_paintLayer.needsRepaint(); | |
| 78 m_paintLayer.clearNeedsRepaint(); | |
| 79 | |
| 80 if (shouldSuppressPaintingLayer(&m_paintLayer)) | 84 if (shouldSuppressPaintingLayer(&m_paintLayer)) |
| 81 return; | 85 return FullyPainted; |
| 82 | 86 |
| 83 // If this layer is totally invisible then there is nothing to paint. | 87 // If this layer is totally invisible then there is nothing to paint. |
| 84 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()-
>hasBackdropFilter()) | 88 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()-
>hasBackdropFilter()) |
| 85 return; | 89 return FullyPainted; |
| 86 | |
| 87 if (!needsRepaint && SubsequenceRecorder::useCachedSubsequenceIfPossible(*co
ntext, m_paintLayer)) | |
| 88 return; | |
| 89 SubsequenceRecorder subsequenceRecorder(*context, m_paintLayer); | |
| 90 | 90 |
| 91 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags())) | 91 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags())) |
| 92 paintFlags |= PaintLayerHaveTransparency; | 92 paintFlags |= PaintLayerHaveTransparency; |
| 93 | 93 |
| 94 LayerFixedPositionRecorder fixedPositionRecorder(*context, *m_paintLayer.lay
outObject()); | 94 LayerFixedPositionRecorder fixedPositionRecorder(*context, *m_paintLayer.lay
outObject()); |
| 95 | 95 |
| 96 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th
e transform twice. | 96 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th
e transform twice. |
| 97 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p
aintFlags & PaintLayerAppliedTransform)) { | 97 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p
aintFlags & PaintLayerAppliedTransform)) |
| 98 paintLayerWithTransform(context, paintingInfo, paintFlags); | 98 return paintLayerWithTransform(context, paintingInfo, paintFlags); |
| 99 return; | |
| 100 } | |
| 101 | 99 |
| 102 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); | 100 return paintLayerContentsAndReflection(context, paintingInfo, paintFlags); |
| 103 } | 101 } |
| 104 | 102 |
| 105 void DeprecatedPaintLayerPainter::paintLayerContentsAndReflection(GraphicsContex
t* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlag
s paintFlags, FragmentPolicy fragmentPolicy) | 103 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintLayer
ContentsAndReflection(GraphicsContext* context, const DeprecatedPaintLayerPainti
ngInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy) |
| 106 { | 104 { |
| 107 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay
erDescendant()); | 105 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay
erDescendant()); |
| 108 | 106 |
| 109 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform)
; | 107 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform)
; |
| 110 | 108 |
| 111 // Paint the reflection first if we have one. | 109 // Paint the reflection first if we have one. |
| 112 if (m_paintLayer.reflectionInfo()) { | 110 if (m_paintLayer.reflectionInfo()) { |
| 113 ScopeRecorder scopeRecorder(*context); | 111 ScopeRecorder scopeRecorder(*context); |
| 114 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl
ags | PaintLayerPaintingReflection); | 112 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl
ags | PaintLayerPaintingReflection); |
| 115 } | 113 } |
| 116 | 114 |
| 117 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; | 115 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; |
| 118 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); | 116 return paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPo
licy); |
| 119 } | 117 } |
| 120 | 118 |
| 121 class ClipPathHelper { | 119 class ClipPathHelper { |
| 122 public: | 120 public: |
| 123 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa
yer, DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBou
nds, bool& rootRelativeBoundsComputed, | 121 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa
yer, DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBou
nds, bool& rootRelativeBoundsComputed, |
| 124 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) | 122 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) |
| 125 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) | 123 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) |
| 126 { | 124 { |
| 127 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); | 125 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); |
| 128 | 126 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layout
Object(), m_context, m_clipperState); | 171 SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layout
Object(), m_context, m_clipperState); |
| 174 } | 172 } |
| 175 private: | 173 private: |
| 176 LayoutSVGResourceClipper* m_resourceClipper; | 174 LayoutSVGResourceClipper* m_resourceClipper; |
| 177 Optional<ClipPathRecorder> m_clipPathRecorder; | 175 Optional<ClipPathRecorder> m_clipPathRecorder; |
| 178 SVGClipPainter::ClipperState m_clipperState; | 176 SVGClipPainter::ClipperState m_clipperState; |
| 179 const DeprecatedPaintLayer& m_paintLayer; | 177 const DeprecatedPaintLayer& m_paintLayer; |
| 180 GraphicsContext* m_context; | 178 GraphicsContext* m_context; |
| 181 }; | 179 }; |
| 182 | 180 |
| 183 void DeprecatedPaintLayerPainter::paintLayerContents(GraphicsContext* context, c
onst DeprecatedPaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags paintFla
gs, FragmentPolicy fragmentPolicy) | 181 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintLayer
Contents(GraphicsContext* context, const DeprecatedPaintLayerPaintingInfo& paint
ingInfoArg, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy) |
| 184 { | 182 { |
| 185 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay
erDescendant()); | 183 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay
erDescendant()); |
| 186 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); | 184 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); |
| 187 | 185 |
| 188 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); | 186 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); |
| 189 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr
ollbars; | 187 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr
ollbars; |
| 190 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing
ScrollingPhase; | 188 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing
ScrollingPhase; |
| 191 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi
tingForegroundPhase; | 189 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi
tingForegroundPhase; |
| 192 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi
tingBackgroundPhase; | 190 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi
tingBackgroundPhase; |
| 193 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon
tents; | 191 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon
tents; |
| 194 // Outline always needs to be painted even if we have no visible content. Al
so, | 192 // Outline always needs to be painted even if we have no visible content. Al
so, |
| 195 // the outline is painted in the background phase during composited scrollin
g. | 193 // the outline is painted in the background phase during composited scrollin
g. |
| 196 // If it were painted in the foreground phase, it would move with the scroll
ed | 194 // If it were painted in the foreground phase, it would move with the scroll
ed |
| 197 // content. When not composited scrolling, the outline is painted in the | 195 // content. When not composited scrolling, the outline is painted in the |
| 198 // foreground phase. Since scrolled contents are moved by paint invalidation
in this | 196 // foreground phase. Since scrolled contents are moved by paint invalidation
in this |
| 199 // case, the outline won't get 'dragged along'. | 197 // case, the outline won't get 'dragged along'. |
| 200 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar
s | 198 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar
s |
| 201 && ((isPaintingScrollingContent && isPaintingCompositedBackground) | 199 && ((isPaintingScrollingContent && isPaintingCompositedBackground) |
| 202 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); | 200 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); |
| 203 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting
Layer && !isPaintingOverlayScrollbars; | 201 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting
Layer && !isPaintingOverlayScrollbars; |
| 204 | 202 |
| 203 bool needsRepaint = m_paintLayer.needsRepaint(); |
| 204 m_paintLayer.clearNeedsRepaint(); |
| 205 |
| 206 PaintResult result = FullyPainted; |
| 207 |
| 205 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou
tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) | 208 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou
tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) |
| 206 return; | 209 return result; |
| 210 |
| 211 Optional<SubsequenceRecorder> subsequenceRecorder; |
| 212 if (isPaintingOverlayScrollbars) { |
| 213 // We should have cleared the repaint flag in the first pass. |
| 214 ASSERT(!needsRepaint); |
| 215 } else { |
| 216 if (!needsRepaint && SubsequenceRecorder::useCachedSubsequenceIfPossible
(*context, m_paintLayer)) |
| 217 return result; |
| 218 subsequenceRecorder.emplace(*context, m_paintLayer); |
| 219 } |
| 207 | 220 |
| 208 DeprecatedPaintLayerPaintingInfo paintingInfo = paintingInfoArg; | 221 DeprecatedPaintLayerPaintingInfo paintingInfo = paintingInfoArg; |
| 209 | 222 |
| 210 // Ensure our lists are up-to-date. | 223 // Ensure our lists are up-to-date. |
| 211 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); | 224 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); |
| 212 | 225 |
| 213 LayoutPoint offsetFromRoot; | 226 LayoutPoint offsetFromRoot; |
| 214 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 227 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
| 215 | 228 |
| 216 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) | 229 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) |
| 217 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); | 230 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); |
| 218 else | 231 else |
| 219 offsetFromRoot.move(paintingInfo.subPixelAccumulation); | 232 offsetFromRoot.move(paintingInfo.subPixelAccumulation); |
| 220 | 233 |
| 234 LayoutRect bounds = m_paintLayer.physicalBoundingBox(offsetFromRoot); |
| 235 if (!paintingInfo.paintDirtyRect.contains(bounds)) |
| 236 result = NotFullyPainted; |
| 237 |
| 221 LayoutRect rootRelativeBounds; | 238 LayoutRect rootRelativeBounds; |
| 222 bool rootRelativeBoundsComputed = false; | 239 bool rootRelativeBoundsComputed = false; |
| 223 | 240 |
| 224 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()-
>style()->position() != StaticPosition) | 241 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()-
>style()->position() != StaticPosition) |
| 225 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C
lipPathOfPositionedElement); | 242 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C
lipPathOfPositionedElement); |
| 226 | 243 |
| 227 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, | 244 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, |
| 228 // so they are nested properly. | 245 // so they are nested properly. |
| 229 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat
iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); | 246 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat
iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); |
| 230 | 247 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin
gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr
ound); | 291 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin
gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr
ound); |
| 275 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa
intContent; | 292 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa
intContent; |
| 276 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr
ound; | 293 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr
ound; |
| 277 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; | 294 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; |
| 278 | 295 |
| 279 if (shouldPaintBackground) { | 296 if (shouldPaintBackground) { |
| 280 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, | 297 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, |
| 281 localPaintingInfo, paintingRootForLayoutObject, paintFlags); | 298 localPaintingInfo, paintingRootForLayoutObject, paintFlags); |
| 282 } | 299 } |
| 283 | 300 |
| 284 if (shouldPaintNegZOrderList) | 301 if (shouldPaintNegZOrderList) { |
| 285 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFl
ags); | 302 if (paintChildren(NegativeZOrderChildren, context, paintingInfo, pai
ntFlags) == NotFullyPainted) |
| 303 result = NotFullyPainted; |
| 304 } |
| 286 | 305 |
| 287 if (shouldPaintOwnContents) { | 306 if (shouldPaintOwnContents) { |
| 288 paintForegroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, | 307 paintForegroundForFragments(layerFragments, context, paintingInfo.pa
intDirtyRect, |
| 289 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p
aintFlags); | 308 localPaintingInfo, paintingRootForLayoutObject, selectionOnly, p
aintFlags); |
| 290 } | 309 } |
| 291 | 310 |
| 292 if (shouldPaintOutline) | 311 if (shouldPaintOutline) |
| 293 paintOutlineForFragments(layerFragments, context, localPaintingInfo,
paintingRootForLayoutObject, paintFlags); | 312 paintOutlineForFragments(layerFragments, context, localPaintingInfo,
paintingRootForLayoutObject, paintFlags); |
| 294 | 313 |
| 295 if (shouldPaintNormalFlowAndPosZOrderLists) | 314 if (shouldPaintNormalFlowAndPosZOrderLists) { |
| 296 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context,
paintingInfo, paintFlags); | 315 if (paintChildren(NormalFlowChildren | PositiveZOrderChildren, conte
xt, paintingInfo, paintFlags) == NotFullyPainted) |
| 316 result = NotFullyPainted; |
| 317 } |
| 297 | 318 |
| 298 if (shouldPaintOverlayScrollbars) | 319 if (shouldPaintOverlayScrollbars) |
| 299 paintOverflowControlsForFragments(layerFragments, context, localPain
tingInfo, paintFlags); | 320 paintOverflowControlsForFragments(layerFragments, context, localPain
tingInfo, paintFlags); |
| 300 } // FilterPainter block | 321 } // FilterPainter block |
| 301 | 322 |
| 302 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase)
&& shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn
ly; | 323 bool shouldPaintMask = (paintFlags & PaintLayerPaintingCompositingMaskPhase)
&& shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && !selectionOn
ly; |
| 303 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping
MaskPhase) && shouldPaintContent && !selectionOnly; | 324 bool shouldPaintClippingMask = (paintFlags & PaintLayerPaintingChildClipping
MaskPhase) && shouldPaintContent && !selectionOnly; |
| 304 | 325 |
| 305 if (shouldPaintMask) | 326 if (shouldPaintMask) |
| 306 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForLayoutObject, paintFlags); | 327 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForLayoutObject, paintFlags); |
| 307 if (shouldPaintClippingMask) { | 328 if (shouldPaintClippingMask) { |
| 308 // Paint the border radius mask for the fragments. | 329 // Paint the border radius mask for the fragments. |
| 309 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForLayoutObject, paintFlags); | 330 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForLayoutObject, paintFlags); |
| 310 } | 331 } |
| 332 |
| 333 // Set subsequence not cacheable if the bounding box of this layer and desce
ndants is not fully contained |
| 334 // by paintRect, because later paintRect changes may expose new contents whi
ch will need repainting. |
| 335 if (result == NotFullyPainted && subsequenceRecorder) |
| 336 subsequenceRecorder->setUncacheable(); |
| 337 |
| 338 return result; |
| 311 } | 339 } |
| 312 | 340 |
| 313 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting
Info& localPaintingInfo, const ClipRect& clipRect) | 341 bool DeprecatedPaintLayerPainter::needsToClip(const DeprecatedPaintLayerPainting
Info& localPaintingInfo, const ClipRect& clipRect) |
| 314 { | 342 { |
| 315 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa
dius(); | 343 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa
dius(); |
| 316 } | 344 } |
| 317 | 345 |
| 318 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca
tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local
PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot
) | 346 bool DeprecatedPaintLayerPainter::atLeastOneFragmentIntersectsDamageRect(Depreca
tedPaintLayerFragments& fragments, const DeprecatedPaintLayerPaintingInfo& local
PaintingInfo, PaintLayerFlags localPaintFlags, const LayoutPoint& offsetFromRoot
) |
| 319 { | 347 { |
| 320 if (m_paintLayer.enclosingPaginationLayer()) | 348 if (m_paintLayer.enclosingPaginationLayer()) |
| 321 return true; // The fragments created have already been found to interse
ct with the damage rect. | 349 return true; // The fragments created have already been found to interse
ct with the damage rect. |
| 322 | 350 |
| 323 if (&m_paintLayer == localPaintingInfo.rootLayer && (localPaintFlags & Paint
LayerPaintingOverflowContents)) | 351 if (&m_paintLayer == localPaintingInfo.rootLayer && (localPaintFlags & Paint
LayerPaintingOverflowContents)) |
| 324 return true; | 352 return true; |
| 325 | 353 |
| 326 for (DeprecatedPaintLayerFragment& fragment: fragments) { | 354 for (DeprecatedPaintLayerFragment& fragment: fragments) { |
| 327 LayoutPoint newOffsetFromRoot = offsetFromRoot + fragment.paginationOffs
et; | 355 LayoutPoint newOffsetFromRoot = offsetFromRoot + fragment.paginationOffs
et; |
| 328 // Note that this really only works reliably on the first fragment. If t
he layer has visible | 356 // Note that this really only works reliably on the first fragment. If t
he layer has visible |
| 329 // overflow and a subsequent fragment doesn't intersect with the border
box of the layer | 357 // overflow and a subsequent fragment doesn't intersect with the border
box of the layer |
| 330 // (i.e. only contains an overflow portion of the layer), intersection w
ill fail. The reason | 358 // (i.e. only contains an overflow portion of the layer), intersection w
ill fail. The reason |
| 331 // for this is that fragment.layerBounds is set to the border box, not t
he bounding box, of | 359 // for this is that fragment.layerBounds is set to the border box, not t
he bounding box, of |
| 332 // the layer. | 360 // the layer. |
| 333 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac
kgroundRect.rect(), newOffsetFromRoot)) | 361 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac
kgroundRect.rect(), newOffsetFromRoot)) |
| 334 return true; | 362 return true; |
| 335 } | 363 } |
| 336 return false; | 364 return false; |
| 337 } | 365 } |
| 338 | 366 |
| 339 void DeprecatedPaintLayerPainter::paintLayerWithTransform(GraphicsContext* conte
xt, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintF
lags) | 367 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintLayer
WithTransform(GraphicsContext* context, const DeprecatedPaintLayerPaintingInfo&
paintingInfo, PaintLayerFlags paintFlags) |
| 340 { | 368 { |
| 341 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint
ingInfo.globalPaintFlags()); | 369 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint
ingInfo.globalPaintFlags()); |
| 342 // If the transform can't be inverted, then don't paint anything. | 370 // If the transform can't be inverted, then don't paint anything. |
| 343 if (!layerTransform.isInvertible()) | 371 if (!layerTransform.isInvertible()) |
| 344 return; | 372 return FullyPainted; |
| 345 | 373 |
| 346 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer
here. | 374 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer
here. |
| 347 // m_paintLayer may be the "root", and then we should avoid looking at its p
arent. | 375 // m_paintLayer may be the "root", and then we should avoid looking at its p
arent. |
| 348 DeprecatedPaintLayer* parentLayer = m_paintLayer.parent(); | 376 DeprecatedPaintLayer* parentLayer = m_paintLayer.parent(); |
| 349 | 377 |
| 350 ClipRect ancestorBackgroundClipRect; | 378 ClipRect ancestorBackgroundClipRect; |
| 351 if (parentLayer) { | 379 if (parentLayer) { |
| 352 // Calculate the clip rectangle that the ancestors establish. | 380 // Calculate the clip rectangle that the ancestors establish. |
| 353 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags &
PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver
layScrollbarSize); | 381 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlags &
PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, IgnoreOver
layScrollbarSize); |
| 354 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) =
= IgnoreOverflowClip) | 382 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) =
= IgnoreOverflowClip) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 373 // We don't need to collect any fragments in the regular way here. We ha
ve already | 401 // We don't need to collect any fragments in the regular way here. We ha
ve already |
| 374 // calculated a clip rectangle for the ancestry if it was needed, and cl
ipping this | 402 // calculated a clip rectangle for the ancestry if it was needed, and cl
ipping this |
| 375 // layer is something that can be done further down the path, when the t
ransform has | 403 // layer is something that can be done further down the path, when the t
ransform has |
| 376 // been applied. | 404 // been applied. |
| 377 DeprecatedPaintLayerFragment fragment; | 405 DeprecatedPaintLayerFragment fragment; |
| 378 fragment.backgroundRect = paintingInfo.paintDirtyRect; | 406 fragment.backgroundRect = paintingInfo.paintDirtyRect; |
| 379 fragments.append(fragment); | 407 fragments.append(fragment); |
| 380 } | 408 } |
| 381 | 409 |
| 382 bool needsScope = fragments.size() > 1; | 410 bool needsScope = fragments.size() > 1; |
| 411 PaintResult result = FullyPainted; |
| 383 for (const auto& fragment : fragments) { | 412 for (const auto& fragment : fragments) { |
| 384 Optional<ScopeRecorder> scopeRecorder; | 413 Optional<ScopeRecorder> scopeRecorder; |
| 385 if (needsScope) | 414 if (needsScope) |
| 386 scopeRecorder.emplace(*context); | 415 scopeRecorder.emplace(*context); |
| 387 Optional<LayerClipRecorder> clipRecorder; | 416 Optional<LayerClipRecorder> clipRecorder; |
| 388 if (parentLayer) { | 417 if (parentLayer) { |
| 389 ClipRect clipRectForFragment(ancestorBackgroundClipRect); | 418 ClipRect clipRectForFragment(ancestorBackgroundClipRect); |
| 390 clipRectForFragment.moveBy(fragment.paginationOffset); | 419 clipRectForFragment.moveBy(fragment.paginationOffset); |
| 391 clipRectForFragment.intersect(fragment.backgroundRect); | 420 clipRectForFragment.intersect(fragment.backgroundRect); |
| 392 if (clipRectForFragment.isEmpty()) | 421 if (clipRectForFragment.isEmpty()) |
| 393 continue; | 422 continue; |
| 394 if (needsToClip(paintingInfo, clipRectForFragment)) { | 423 if (needsToClip(paintingInfo, clipRectForFragment)) { |
| 395 if (m_paintLayer.layoutObject()->style()->position() != StaticPo
sition && clipRectForFragment.isClippedByClipCss()) | 424 if (m_paintLayer.layoutObject()->style()->position() != StaticPo
sition && clipRectForFragment.isClippedByClipCss()) |
| 396 UseCounter::count(m_paintLayer.layoutObject()->document(), U
seCounter::ClipCssOfPositionedElement); | 425 UseCounter::count(m_paintLayer.layoutObject()->document(), U
seCounter::ClipCssOfPositionedElement); |
| 397 clipRecorder.emplace(*context, *parentLayer->layoutObject(), Dis
playItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati
onOffset, paintFlags); | 426 clipRecorder.emplace(*context, *parentLayer->layoutObject(), Dis
playItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati
onOffset, paintFlags); |
| 398 } | 427 } |
| 399 } | 428 } |
| 400 | 429 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags,
fragment.paginationOffset) == NotFullyPainted) |
| 401 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag
ment.paginationOffset); | 430 result = NotFullyPainted; |
| 402 } | 431 } |
| 432 return result; |
| 403 } | 433 } |
| 404 | 434 |
| 405 void DeprecatedPaintLayerPainter::paintFragmentByApplyingTransform(GraphicsConte
xt* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFla
gs paintFlags, const LayoutPoint& fragmentTranslation) | 435 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintFragm
entByApplyingTransform(GraphicsContext* context, const DeprecatedPaintLayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint& fragmentTr
anslation) |
| 406 { | 436 { |
| 407 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving | 437 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving |
| 408 // the accumulated error for sub-pixel layout. | 438 // the accumulated error for sub-pixel layout. |
| 409 LayoutPoint delta; | 439 LayoutPoint delta; |
| 410 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); | 440 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); |
| 411 delta.moveBy(fragmentTranslation); | 441 delta.moveBy(fragmentTranslation); |
| 412 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo
.globalPaintFlags())); | 442 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo
.globalPaintFlags())); |
| 413 IntPoint roundedDelta = roundedIntPoint(delta); | 443 IntPoint roundedDelta = roundedIntPoint(delta); |
| 414 transform.translateRight(roundedDelta.x(), roundedDelta.y()); | 444 transform.translateRight(roundedDelta.x(), roundedDelta.y()); |
| 415 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation
+ (delta - roundedDelta); | 445 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation
+ (delta - roundedDelta); |
| 416 | 446 |
| 417 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject
(), DisplayItem::Transform3DElementTransform, transform); | 447 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject
(), DisplayItem::Transform3DElementTransform, transform); |
| 418 | 448 |
| 419 // Now do a paint with the root layer shifted to be us. | 449 // Now do a paint with the root layer shifted to be us. |
| 420 DeprecatedPaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, Layo
utRect(enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect)
)), paintingInfo.globalPaintFlags(), | 450 DeprecatedPaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, Layo
utRect(enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect)
)), paintingInfo.globalPaintFlags(), |
| 421 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); | 451 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); |
| 422 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH
asClipPathClipping; | 452 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH
asClipPathClipping; |
| 423 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags
, ForceSingleFragment); | 453 return paintLayerContentsAndReflection(context, transformedPaintingInfo, pai
ntFlags, ForceSingleFragment); |
| 424 } | 454 } |
| 425 | 455 |
| 426 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi
csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL
ayerFlags paintFlags) | 456 DeprecatedPaintLayerPainter::PaintResult DeprecatedPaintLayerPainter::paintChild
ren(unsigned childrenToVisit, GraphicsContext* context, const DeprecatedPaintLay
erPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
| 427 { | 457 { |
| 458 PaintResult result = FullyPainted; |
| 428 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) | 459 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) |
| 429 return; | 460 return result; |
| 430 | 461 |
| 431 #if ENABLE(ASSERT) | 462 #if ENABLE(ASSERT) |
| 432 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); | 463 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); |
| 433 #endif | 464 #endif |
| 434 | 465 |
| 435 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; | 466 IntSize scrollOffsetAccumulation = paintingInfo.scrollOffsetAccumulation; |
| 436 if (m_paintLayer.layoutObject()->hasOverflowClip()) | 467 if (m_paintLayer.layoutObject()->hasOverflowClip()) |
| 437 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff
set(); | 468 scrollOffsetAccumulation += m_paintLayer.layoutBox()->scrolledContentOff
set(); |
| 438 | 469 |
| 439 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode
(), childrenToVisit); | 470 DeprecatedPaintLayerStackingNodeIterator iterator(*m_paintLayer.stackingNode
(), childrenToVisit); |
| 440 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { | 471 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { |
| 441 DeprecatedPaintLayerPainter childPainter(*child->layer()); | 472 DeprecatedPaintLayerPainter childPainter(*child->layer()); |
| 442 // If this Layer should paint into its own backing or a grouped backing,
that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() | 473 // If this Layer should paint into its own backing or a grouped backing,
that will be done via CompositedDeprecatedPaintLayerMapping::paintContents() |
| 443 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). | 474 // and CompositedDeprecatedPaintLayerMapping::doPaintTask(). |
| 444 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain
tFlags(), paintFlags)) | 475 if (!childPainter.shouldPaintLayerInSoftwareMode(paintingInfo.globalPain
tFlags(), paintFlags)) |
| 445 continue; | 476 continue; |
| 446 | 477 |
| 447 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; | 478 DeprecatedPaintLayerPaintingInfo childPaintingInfo = paintingInfo; |
| 448 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; | 479 childPaintingInfo.scrollOffsetAccumulation = scrollOffsetAccumulation; |
| 449 // Rare case: accumulate scroll offset of non-stacking-context ancestors
up to m_paintLayer. | 480 // Rare case: accumulate scroll offset of non-stacking-context ancestors
up to m_paintLayer. |
| 450 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren
tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { | 481 for (DeprecatedPaintLayer* parentLayer = child->layer()->parent(); paren
tLayer != &m_paintLayer; parentLayer = parentLayer->parent()) { |
| 451 if (parentLayer->layoutObject()->hasOverflowClip()) | 482 if (parentLayer->layoutObject()->hasOverflowClip()) |
| 452 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou
tBox()->scrolledContentOffset(); | 483 childPaintingInfo.scrollOffsetAccumulation += parentLayer->layou
tBox()->scrolledContentOffset(); |
| 453 } | 484 } |
| 454 | 485 |
| 455 childPainter.paintLayer(context, childPaintingInfo, paintFlags); | 486 if (childPainter.paintLayer(context, childPaintingInfo, paintFlags) == N
otFullyPainted) |
| 487 result = NotFullyPainted; |
| 456 } | 488 } |
| 489 return result; |
| 457 } | 490 } |
| 458 | 491 |
| 459 // FIXME: inline this. | 492 // FIXME: inline this. |
| 460 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint
LayerFlags paintFlags) | 493 static bool paintForFixedRootBackground(const DeprecatedPaintLayer* layer, Paint
LayerFlags paintFlags) |
| 461 { | 494 { |
| 462 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye
rPaintingRootBackgroundOnly); | 495 return layer->layoutObject()->isDocumentElement() && (paintFlags & PaintLaye
rPaintingRootBackgroundOnly); |
| 463 } | 496 } |
| 464 | 497 |
| 465 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai
ntFlags globalPaintFlags, PaintLayerFlags paintFlags) | 498 bool DeprecatedPaintLayerPainter::shouldPaintLayerInSoftwareMode(const GlobalPai
ntFlags globalPaintFlags, PaintLayerFlags paintFlags) |
| 466 { | 499 { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 654 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
| 622 return; | 655 return; |
| 623 | 656 |
| 624 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl
osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); | 657 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl
osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); |
| 625 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 658 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 626 | 659 |
| 627 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 660 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 628 } | 661 } |
| 629 | 662 |
| 630 } // namespace blink | 663 } // namespace blink |
| OLD | NEW |