| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 ScopeRecorder scopeRecorder(*context); | 113 ScopeRecorder scopeRecorder(*context); |
| 114 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl
ags | PaintLayerPaintingReflection); | 114 m_paintLayer.reflectionInfo()->paint(context, paintingInfo, localPaintFl
ags | PaintLayerPaintingReflection); |
| 115 } | 115 } |
| 116 | 116 |
| 117 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; | 117 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; |
| 118 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); | 118 paintLayerContents(context, paintingInfo, localPaintFlags, fragmentPolicy); |
| 119 } | 119 } |
| 120 | 120 |
| 121 class ClipPathHelper { | 121 class ClipPathHelper { |
| 122 public: | 122 public: |
| 123 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa
yer, const DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutRect& rootRelat
iveBounds, bool& rootRelativeBoundsComputed, | 123 ClipPathHelper(GraphicsContext* context, const DeprecatedPaintLayer& paintLa
yer, DeprecatedPaintLayerPaintingInfo& paintingInfo, LayoutRect& rootRelativeBou
nds, bool& rootRelativeBoundsComputed, |
| 124 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) | 124 const LayoutPoint& offsetFromRoot, PaintLayerFlags paintFlags) |
| 125 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) | 125 : m_resourceClipper(0), m_paintLayer(paintLayer), m_context(context) |
| 126 { | 126 { |
| 127 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); | 127 const ComputedStyle& style = paintLayer.layoutObject()->styleRef(); |
| 128 | 128 |
| 129 // Clip-path, like border radius, must not be applied to the contents of
a composited-scrolling container. | 129 // Clip-path, like border radius, must not be applied to the contents of
a composited-scrolling container. |
| 130 // It must, however, still be applied to the mask layer, so that the com
positor can properly mask the | 130 // It must, however, still be applied to the mask layer, so that the com
positor can properly mask the |
| 131 // scrolling contents and scrollbars. | 131 // scrolling contents and scrollbars. |
| 132 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos
itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) | 132 if (!paintLayer.layoutObject()->hasClipPath() || (paintLayer.needsCompos
itedScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 m_clipperState = SVGClipPainter::ClipperNotApplied; | 135 m_clipperState = SVGClipPainter::ClipperNotApplied; |
| 136 | 136 |
| 137 paintingInfo.ancestorHasClipPathClipping = true; |
| 138 |
| 137 ASSERT(style.clipPath()); | 139 ASSERT(style.clipPath()); |
| 138 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { | 140 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { |
| 139 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl
ipPath()); | 141 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl
ipPath()); |
| 140 if (clipPath->isValid()) { | 142 if (clipPath->isValid()) { |
| 141 if (!rootRelativeBoundsComputed) { | 143 if (!rootRelativeBoundsComputed) { |
| 142 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding
ReflectionAndStackingChildren(offsetFromRoot); | 144 rootRelativeBounds = paintLayer.physicalBoundingBoxIncluding
ReflectionAndStackingChildren(offsetFromRoot); |
| 143 rootRelativeBoundsComputed = true; | 145 rootRelativeBoundsComputed = true; |
| 144 } | 146 } |
| 145 m_clipPathRecorder.emplace(*context, *paintLayer.layoutObject(),
clipPath->path(FloatRect(rootRelativeBounds))); | 147 m_clipPathRecorder.emplace(*context, *paintLayer.layoutObject(),
clipPath->path(FloatRect(rootRelativeBounds))); |
| 146 } | 148 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 171 SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layout
Object(), m_context, m_clipperState); | 173 SVGClipPainter(*m_resourceClipper).finishEffect(*m_paintLayer.layout
Object(), m_context, m_clipperState); |
| 172 } | 174 } |
| 173 private: | 175 private: |
| 174 LayoutSVGResourceClipper* m_resourceClipper; | 176 LayoutSVGResourceClipper* m_resourceClipper; |
| 175 Optional<ClipPathRecorder> m_clipPathRecorder; | 177 Optional<ClipPathRecorder> m_clipPathRecorder; |
| 176 SVGClipPainter::ClipperState m_clipperState; | 178 SVGClipPainter::ClipperState m_clipperState; |
| 177 const DeprecatedPaintLayer& m_paintLayer; | 179 const DeprecatedPaintLayer& m_paintLayer; |
| 178 GraphicsContext* m_context; | 180 GraphicsContext* m_context; |
| 179 }; | 181 }; |
| 180 | 182 |
| 181 void DeprecatedPaintLayerPainter::paintLayerContents(GraphicsContext* context, c
onst DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags,
FragmentPolicy fragmentPolicy) | 183 void DeprecatedPaintLayerPainter::paintLayerContents(GraphicsContext* context, c
onst DeprecatedPaintLayerPaintingInfo& paintingInfoArg, PaintLayerFlags paintFla
gs, FragmentPolicy fragmentPolicy) |
| 182 { | 184 { |
| 183 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay
erDescendant()); | 185 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay
erDescendant()); |
| 184 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); | 186 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); |
| 185 | 187 |
| 186 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); | 188 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); |
| 187 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr
ollbars; | 189 bool isPaintingOverlayScrollbars = paintFlags & PaintLayerPaintingOverlayScr
ollbars; |
| 188 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing
ScrollingPhase; | 190 bool isPaintingScrollingContent = paintFlags & PaintLayerPaintingCompositing
ScrollingPhase; |
| 189 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi
tingForegroundPhase; | 191 bool isPaintingCompositedForeground = paintFlags & PaintLayerPaintingComposi
tingForegroundPhase; |
| 190 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi
tingBackgroundPhase; | 192 bool isPaintingCompositedBackground = paintFlags & PaintLayerPaintingComposi
tingBackgroundPhase; |
| 191 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon
tents; | 193 bool isPaintingOverflowContents = paintFlags & PaintLayerPaintingOverflowCon
tents; |
| 192 // Outline always needs to be painted even if we have no visible content. Al
so, | 194 // Outline always needs to be painted even if we have no visible content. Al
so, |
| 193 // the outline is painted in the background phase during composited scrollin
g. | 195 // the outline is painted in the background phase during composited scrollin
g. |
| 194 // If it were painted in the foreground phase, it would move with the scroll
ed | 196 // If it were painted in the foreground phase, it would move with the scroll
ed |
| 195 // content. When not composited scrolling, the outline is painted in the | 197 // content. When not composited scrolling, the outline is painted in the |
| 196 // foreground phase. Since scrolled contents are moved by paint invalidation
in this | 198 // foreground phase. Since scrolled contents are moved by paint invalidation
in this |
| 197 // case, the outline won't get 'dragged along'. | 199 // case, the outline won't get 'dragged along'. |
| 198 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar
s | 200 bool shouldPaintOutline = isSelfPaintingLayer && !isPaintingOverlayScrollbar
s |
| 199 && ((isPaintingScrollingContent && isPaintingCompositedBackground) | 201 && ((isPaintingScrollingContent && isPaintingCompositedBackground) |
| 200 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); | 202 || (!isPaintingScrollingContent && isPaintingCompositedForeground)); |
| 201 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting
Layer && !isPaintingOverlayScrollbars; | 203 bool shouldPaintContent = m_paintLayer.hasVisibleContent() && isSelfPainting
Layer && !isPaintingOverlayScrollbars; |
| 202 | 204 |
| 203 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou
tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) | 205 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !m_paintLayer.layou
tObject()->isLayoutView() && !m_paintLayer.layoutObject()->isDocumentElement()) |
| 204 return; | 206 return; |
| 205 | 207 |
| 208 DeprecatedPaintLayerPaintingInfo paintingInfo = paintingInfoArg; |
| 209 |
| 206 // Ensure our lists are up-to-date. | 210 // Ensure our lists are up-to-date. |
| 207 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); | 211 m_paintLayer.stackingNode()->updateLayerListsIfNeeded(); |
| 208 | 212 |
| 209 LayoutPoint offsetFromRoot; | 213 LayoutPoint offsetFromRoot; |
| 210 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 214 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
| 211 | 215 |
| 212 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) | 216 if (m_paintLayer.compositingState() == PaintsIntoOwnBacking) |
| 213 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); | 217 offsetFromRoot.move(m_paintLayer.subpixelAccumulation()); |
| 214 else | 218 else |
| 215 offsetFromRoot.move(paintingInfo.subPixelAccumulation); | 219 offsetFromRoot.move(paintingInfo.subPixelAccumulation); |
| 216 | 220 |
| 217 LayoutRect rootRelativeBounds; | 221 LayoutRect rootRelativeBounds; |
| 218 bool rootRelativeBoundsComputed = false; | 222 bool rootRelativeBoundsComputed = false; |
| 219 | 223 |
| 224 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()-
>style()->position() != StaticPosition) |
| 225 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C
lipPathOfPositionedElement); |
| 226 |
| 220 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, | 227 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, |
| 221 // so they are nested properly. | 228 // so they are nested properly. |
| 222 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat
iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); | 229 ClipPathHelper clipPathHelper(context, m_paintLayer, paintingInfo, rootRelat
iveBounds, rootRelativeBoundsComputed, offsetFromRoot, paintFlags); |
| 223 | 230 |
| 224 Optional<CompositingRecorder> compositingRecorder; | 231 Optional<CompositingRecorder> compositingRecorder; |
| 225 // Blending operations must be performed only with the nearest ancestor stac
king context. | 232 // Blending operations must be performed only with the nearest ancestor stac
king context. |
| 226 // Note that there is no need to composite if we're painting the root. | 233 // Note that there is no need to composite if we're painting the root. |
| 227 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi
thTransparency(). | 234 // FIXME: this should be unified further into DeprecatedPaintLayer::paintsWi
thTransparency(). |
| 228 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument
Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN
ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode
(); | 235 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument
Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN
ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode
(); |
| 229 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint
ingInfo.globalPaintFlags())) { | 236 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint
ingInfo.globalPaintFlags())) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 Optional<ScopeRecorder> scopeRecorder; | 384 Optional<ScopeRecorder> scopeRecorder; |
| 378 if (needsScope) | 385 if (needsScope) |
| 379 scopeRecorder.emplace(*context); | 386 scopeRecorder.emplace(*context); |
| 380 Optional<LayerClipRecorder> clipRecorder; | 387 Optional<LayerClipRecorder> clipRecorder; |
| 381 if (parentLayer) { | 388 if (parentLayer) { |
| 382 ClipRect clipRectForFragment(ancestorBackgroundClipRect); | 389 ClipRect clipRectForFragment(ancestorBackgroundClipRect); |
| 383 clipRectForFragment.moveBy(fragment.paginationOffset); | 390 clipRectForFragment.moveBy(fragment.paginationOffset); |
| 384 clipRectForFragment.intersect(fragment.backgroundRect); | 391 clipRectForFragment.intersect(fragment.backgroundRect); |
| 385 if (clipRectForFragment.isEmpty()) | 392 if (clipRectForFragment.isEmpty()) |
| 386 continue; | 393 continue; |
| 387 if (needsToClip(paintingInfo, clipRectForFragment)) | 394 if (needsToClip(paintingInfo, clipRectForFragment)) { |
| 395 if (m_paintLayer.layoutObject()->style()->position() != StaticPo
sition && clipRectForFragment.isClippedByClipCss()) |
| 396 UseCounter::count(m_paintLayer.layoutObject()->document(), U
seCounter::ClipCssOfPositionedElement); |
| 388 clipRecorder.emplace(*context, *parentLayer->layoutObject(), Dis
playItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati
onOffset, paintFlags); | 397 clipRecorder.emplace(*context, *parentLayer->layoutObject(), Dis
playItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati
onOffset, paintFlags); |
| 398 } |
| 389 } | 399 } |
| 390 | 400 |
| 391 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag
ment.paginationOffset); | 401 paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, frag
ment.paginationOffset); |
| 392 } | 402 } |
| 393 } | 403 } |
| 394 | 404 |
| 395 void DeprecatedPaintLayerPainter::paintFragmentByApplyingTransform(GraphicsConte
xt* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFla
gs paintFlags, const LayoutPoint& fragmentTranslation) | 405 void DeprecatedPaintLayerPainter::paintFragmentByApplyingTransform(GraphicsConte
xt* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintLayerFla
gs paintFlags, const LayoutPoint& fragmentTranslation) |
| 396 { | 406 { |
| 397 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving | 407 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving |
| 398 // the accumulated error for sub-pixel layout. | 408 // the accumulated error for sub-pixel layout. |
| 399 LayoutPoint delta; | 409 LayoutPoint delta; |
| 400 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); | 410 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); |
| 401 delta.moveBy(fragmentTranslation); | 411 delta.moveBy(fragmentTranslation); |
| 402 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo
.globalPaintFlags())); | 412 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo
.globalPaintFlags())); |
| 403 IntPoint roundedDelta = roundedIntPoint(delta); | 413 IntPoint roundedDelta = roundedIntPoint(delta); |
| 404 transform.translateRight(roundedDelta.x(), roundedDelta.y()); | 414 transform.translateRight(roundedDelta.x(), roundedDelta.y()); |
| 405 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation
+ (delta - roundedDelta); | 415 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation
+ (delta - roundedDelta); |
| 406 | 416 |
| 407 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject
(), DisplayItem::Transform3DElementTransform, transform); | 417 Transform3DRecorder transform3DRecorder(*context, *m_paintLayer.layoutObject
(), DisplayItem::Transform3DElementTransform, transform); |
| 408 | 418 |
| 409 // Now do a paint with the root layer shifted to be us. | 419 // Now do a paint with the root layer shifted to be us. |
| 410 DeprecatedPaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, Layo
utRect(enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect)
)), paintingInfo.globalPaintFlags(), | 420 DeprecatedPaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, Layo
utRect(enclosingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect)
)), paintingInfo.globalPaintFlags(), |
| 411 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); | 421 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); |
| 422 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH
asClipPathClipping; |
| 412 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags
, ForceSingleFragment); | 423 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags
, ForceSingleFragment); |
| 413 } | 424 } |
| 414 | 425 |
| 415 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi
csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL
ayerFlags paintFlags) | 426 void DeprecatedPaintLayerPainter::paintChildren(unsigned childrenToVisit, Graphi
csContext* context, const DeprecatedPaintLayerPaintingInfo& paintingInfo, PaintL
ayerFlags paintFlags) |
| 416 { | 427 { |
| 417 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) | 428 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) |
| 418 return; | 429 return; |
| 419 | 430 |
| 420 #if ENABLE(ASSERT) | 431 #if ENABLE(ASSERT) |
| 421 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); | 432 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 621 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
| 611 return; | 622 return; |
| 612 | 623 |
| 613 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl
osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); | 624 DeprecatedPaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(encl
osingIntRect(damageRect)), paintFlags, LayoutSize(), paintingRoot); |
| 614 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 625 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 615 | 626 |
| 616 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 627 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 617 } | 628 } |
| 618 | 629 |
| 619 } // namespace blink | 630 } // namespace blink |
| OLD | NEW |