| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/LayerPainter.h" | 6 #include "core/paint/LayerPainter.h" |
| 7 | 7 |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/layout/ClipPathOperation.h" | 9 #include "core/layout/ClipPathOperation.h" |
| 10 #include "core/layout/FilterEffectRenderer.h" | 10 #include "core/layout/FilterEffectRenderer.h" |
| 11 #include "core/layout/Layer.h" | 11 #include "core/layout/Layer.h" |
| 12 #include "core/layout/LayoutBlock.h" | 12 #include "core/layout/LayoutBlock.h" |
| 13 #include "core/layout/LayoutView.h" | 13 #include "core/layout/LayoutView.h" |
| 14 #include "core/layout/PaintInfo.h" | 14 #include "core/layout/PaintInfo.h" |
| 15 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 15 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 16 #include "core/page/Page.h" | 16 #include "core/page/Page.h" |
| 17 #include "core/paint/CompositingRecorder.h" | 17 #include "core/paint/CompositingRecorder.h" |
| 18 #include "core/paint/FilterPainter.h" | 18 #include "core/paint/FilterPainter.h" |
| 19 #include "core/paint/LayerClipRecorder.h" | 19 #include "core/paint/LayerClipRecorder.h" |
| 20 #include "core/paint/SVGClipPainter.h" |
| 20 #include "core/paint/ScopeRecorder.h" | 21 #include "core/paint/ScopeRecorder.h" |
| 21 #include "core/paint/ScrollableAreaPainter.h" | 22 #include "core/paint/ScrollableAreaPainter.h" |
| 22 #include "core/paint/Transform3DRecorder.h" | 23 #include "core/paint/Transform3DRecorder.h" |
| 23 #include "platform/graphics/GraphicsLayer.h" | 24 #include "platform/graphics/GraphicsLayer.h" |
| 24 #include "platform/graphics/paint/ClipPathRecorder.h" | 25 #include "platform/graphics/paint/ClipPathRecorder.h" |
| 25 #include "platform/graphics/paint/ClipRecorder.h" | 26 #include "platform/graphics/paint/ClipRecorder.h" |
| 26 #include "platform/graphics/paint/CompositingDisplayItem.h" | 27 #include "platform/graphics/paint/CompositingDisplayItem.h" |
| 27 #include "platform/graphics/paint/DisplayItemList.h" | 28 #include "platform/graphics/paint/DisplayItemList.h" |
| 28 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 29 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
| 29 | 30 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 : m_resourceClipper(0), m_renderLayer(renderLayer), m_context(context) | 110 : m_resourceClipper(0), m_renderLayer(renderLayer), m_context(context) |
| 110 { | 111 { |
| 111 const LayoutStyle& style = renderLayer.renderer()->styleRef(); | 112 const LayoutStyle& style = renderLayer.renderer()->styleRef(); |
| 112 | 113 |
| 113 // Clip-path, like border radius, must not be applied to the contents of
a composited-scrolling container. | 114 // Clip-path, like border radius, must not be applied to the contents of
a composited-scrolling container. |
| 114 // It must, however, still be applied to the mask layer, so that the com
positor can properly mask the | 115 // It must, however, still be applied to the mask layer, so that the com
positor can properly mask the |
| 115 // scrolling contents and scrollbars. | 116 // scrolling contents and scrollbars. |
| 116 if (!renderLayer.renderer()->hasClipPath() || (renderLayer.needsComposit
edScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) | 117 if (!renderLayer.renderer()->hasClipPath() || (renderLayer.needsComposit
edScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) |
| 117 return; | 118 return; |
| 118 | 119 |
| 119 m_clipperState = LayoutSVGResourceClipper::ClipperNotApplied; | 120 m_clipperState = SVGClipPainter::ClipperNotApplied; |
| 120 | 121 |
| 121 ASSERT(style.clipPath()); | 122 ASSERT(style.clipPath()); |
| 122 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { | 123 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { |
| 123 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl
ipPath()); | 124 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl
ipPath()); |
| 124 if (clipPath->isValid()) { | 125 if (clipPath->isValid()) { |
| 125 if (!rootRelativeBoundsComputed) { | 126 if (!rootRelativeBoundsComputed) { |
| 126 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 127 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 127 rootRelativeBoundsComputed = true; | 128 rootRelativeBoundsComputed = true; |
| 128 } | 129 } |
| 129 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*context, ren
derLayer.renderer()->displayItemClient(), | 130 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*context, ren
derLayer.renderer()->displayItemClient(), |
| 130 clipPath->path(rootRelativeBounds), clipPath->windRule())); | 131 clipPath->path(rootRelativeBounds), clipPath->windRule())); |
| 131 } | 132 } |
| 132 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { | 133 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { |
| 133 ReferenceClipPathOperation* referenceClipPathOperation = toReference
ClipPathOperation(style.clipPath()); | 134 ReferenceClipPathOperation* referenceClipPathOperation = toReference
ClipPathOperation(style.clipPath()); |
| 134 Document& document = renderLayer.renderer()->document(); | 135 Document& document = renderLayer.renderer()->document(); |
| 135 // FIXME: It doesn't work with forward or external SVG references (h
ttps://bugs.webkit.org/show_bug.cgi?id=90405) | 136 // FIXME: It doesn't work with forward or external SVG references (h
ttps://bugs.webkit.org/show_bug.cgi?id=90405) |
| 136 Element* element = document.getElementById(referenceClipPathOperatio
n->fragment()); | 137 Element* element = document.getElementById(referenceClipPathOperatio
n->fragment()); |
| 137 if (isSVGClipPathElement(element) && element->renderer()) { | 138 if (isSVGClipPathElement(element) && element->renderer()) { |
| 138 if (!rootRelativeBoundsComputed) { | 139 if (!rootRelativeBoundsComputed) { |
| 139 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 140 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 140 rootRelativeBoundsComputed = true; | 141 rootRelativeBoundsComputed = true; |
| 141 } | 142 } |
| 142 | 143 |
| 143 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour
ceContainer(element->renderer())); | 144 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour
ceContainer(element->renderer())); |
| 144 if (!m_resourceClipper->applyClippingToContext(renderLayer.rende
rer(), rootRelativeBounds, | 145 if (!SVGClipPainter(*m_resourceClipper).applyClippingToContext(r
enderLayer.renderer(), rootRelativeBounds, |
| 145 paintingInfo.paintDirtyRect, context, m_clipperState)) { | 146 paintingInfo.paintDirtyRect, context, m_clipperState)) { |
| 146 // No need to post-apply the clipper if this failed. | 147 // No need to post-apply the clipper if this failed. |
| 147 m_resourceClipper = 0; | 148 m_resourceClipper = 0; |
| 148 } | 149 } |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 ~ClipPathHelper() | 154 ~ClipPathHelper() |
| 154 { | 155 { |
| 155 if (m_resourceClipper) | 156 if (m_resourceClipper) |
| 156 m_resourceClipper->postApplyStatefulResource(m_renderLayer.renderer(
), m_context, m_clipperState); | 157 SVGClipPainter(*m_resourceClipper).postApplyStatefulResource(m_rende
rLayer.renderer(), m_context, m_clipperState); |
| 157 } | 158 } |
| 158 private: | 159 private: |
| 159 LayoutSVGResourceClipper* m_resourceClipper; | 160 LayoutSVGResourceClipper* m_resourceClipper; |
| 160 OwnPtr<ClipPathRecorder> m_clipPathRecorder; | 161 OwnPtr<ClipPathRecorder> m_clipPathRecorder; |
| 161 LayoutSVGResourceClipper::ClipperState m_clipperState; | 162 SVGClipPainter::ClipperState m_clipperState; |
| 162 const Layer& m_renderLayer; | 163 const Layer& m_renderLayer; |
| 163 GraphicsContext* m_context; | 164 GraphicsContext* m_context; |
| 164 }; | 165 }; |
| 165 | 166 |
| 166 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy
) | 167 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy
) |
| 167 { | 168 { |
| 168 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); | 169 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); |
| 169 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); | 170 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); |
| 170 | 171 |
| 171 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); | 172 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 if (!m_renderLayer.containsDirtyOverlayScrollbars()) | 709 if (!m_renderLayer.containsDirtyOverlayScrollbars()) |
| 709 return; | 710 return; |
| 710 | 711 |
| 711 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d
amageRect)), paintBehavior, LayoutSize(), paintingRoot); | 712 LayerPaintingInfo paintingInfo(&m_renderLayer, LayoutRect(enclosingIntRect(d
amageRect)), paintBehavior, LayoutSize(), paintingRoot); |
| 712 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 713 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 713 | 714 |
| 714 m_renderLayer.setContainsDirtyOverlayScrollbars(false); | 715 m_renderLayer.setContainsDirtyOverlayScrollbars(false); |
| 715 } | 716 } |
| 716 | 717 |
| 717 } // namespace blink | 718 } // namespace blink |
| OLD | NEW |