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/PaintInfo.h" | 12 #include "core/layout/PaintInfo.h" |
| 13 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
13 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
14 #include "core/paint/CompositingRecorder.h" | 15 #include "core/paint/CompositingRecorder.h" |
15 #include "core/paint/FilterPainter.h" | 16 #include "core/paint/FilterPainter.h" |
16 #include "core/paint/LayerClipRecorder.h" | 17 #include "core/paint/LayerClipRecorder.h" |
17 #include "core/paint/ScopeRecorder.h" | 18 #include "core/paint/ScopeRecorder.h" |
18 #include "core/paint/ScrollableAreaPainter.h" | 19 #include "core/paint/ScrollableAreaPainter.h" |
19 #include "core/paint/Transform3DRecorder.h" | 20 #include "core/paint/Transform3DRecorder.h" |
20 #include "core/rendering/RenderBlock.h" | 21 #include "core/rendering/RenderBlock.h" |
21 #include "core/rendering/RenderView.h" | 22 #include "core/rendering/RenderView.h" |
22 #include "core/rendering/svg/RenderSVGResourceClipper.h" | |
23 #include "platform/graphics/GraphicsLayer.h" | 23 #include "platform/graphics/GraphicsLayer.h" |
24 #include "platform/graphics/paint/ClipPathRecorder.h" | 24 #include "platform/graphics/paint/ClipPathRecorder.h" |
25 #include "platform/graphics/paint/ClipRecorder.h" | 25 #include "platform/graphics/paint/ClipRecorder.h" |
26 #include "platform/graphics/paint/CompositingDisplayItem.h" | 26 #include "platform/graphics/paint/CompositingDisplayItem.h" |
27 #include "platform/graphics/paint/DisplayItemList.h" | 27 #include "platform/graphics/paint/DisplayItemList.h" |
28 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 28 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 static inline bool shouldSuppressPaintingLayer(Layer* layer) | 32 static inline bool shouldSuppressPaintingLayer(Layer* layer) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 : m_resourceClipper(0), m_clipStateSaver(*context, false), m_renderLayer
(renderLayer), m_context(context) | 109 : m_resourceClipper(0), m_clipStateSaver(*context, false), m_renderLayer
(renderLayer), m_context(context) |
110 { | 110 { |
111 const LayoutStyle& style = renderLayer.renderer()->styleRef(); | 111 const LayoutStyle& style = renderLayer.renderer()->styleRef(); |
112 | 112 |
113 // Clip-path, like border radius, must not be applied to the contents of
a composited-scrolling container. | 113 // 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 | 114 // It must, however, still be applied to the mask layer, so that the com
positor can properly mask the |
115 // scrolling contents and scrollbars. | 115 // scrolling contents and scrollbars. |
116 if (!renderLayer.renderer()->hasClipPath() || (renderLayer.needsComposit
edScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) | 116 if (!renderLayer.renderer()->hasClipPath() || (renderLayer.needsComposit
edScrolling() && !(paintFlags & PaintLayerPaintingChildClippingMaskPhase))) |
117 return; | 117 return; |
118 | 118 |
119 m_clipperState = RenderSVGResourceClipper::ClipperNotApplied; | 119 m_clipperState = LayoutSVGResourceClipper::ClipperNotApplied; |
120 | 120 |
121 ASSERT(style.clipPath()); | 121 ASSERT(style.clipPath()); |
122 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { | 122 if (style.clipPath()->type() == ClipPathOperation::SHAPE) { |
123 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl
ipPath()); | 123 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style.cl
ipPath()); |
124 if (clipPath->isValid()) { | 124 if (clipPath->isValid()) { |
125 m_clipStateSaver.save(); | 125 m_clipStateSaver.save(); |
126 | 126 |
127 if (!rootRelativeBoundsComputed) { | 127 if (!rootRelativeBoundsComputed) { |
128 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 128 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
129 rootRelativeBoundsComputed = true; | 129 rootRelativeBoundsComputed = true; |
130 } | 130 } |
131 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*context, ren
derLayer.renderer()->displayItemClient(), | 131 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(*context, ren
derLayer.renderer()->displayItemClient(), |
132 clipPath->path(rootRelativeBounds), clipPath->windRule())); | 132 clipPath->path(rootRelativeBounds), clipPath->windRule())); |
133 } | 133 } |
134 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { | 134 } else if (style.clipPath()->type() == ClipPathOperation::REFERENCE) { |
135 ReferenceClipPathOperation* referenceClipPathOperation = toReference
ClipPathOperation(style.clipPath()); | 135 ReferenceClipPathOperation* referenceClipPathOperation = toReference
ClipPathOperation(style.clipPath()); |
136 Document& document = renderLayer.renderer()->document(); | 136 Document& document = renderLayer.renderer()->document(); |
137 // FIXME: It doesn't work with forward or external SVG references (h
ttps://bugs.webkit.org/show_bug.cgi?id=90405) | 137 // FIXME: It doesn't work with forward or external SVG references (h
ttps://bugs.webkit.org/show_bug.cgi?id=90405) |
138 Element* element = document.getElementById(referenceClipPathOperatio
n->fragment()); | 138 Element* element = document.getElementById(referenceClipPathOperatio
n->fragment()); |
139 if (isSVGClipPathElement(element) && element->renderer()) { | 139 if (isSVGClipPathElement(element) && element->renderer()) { |
140 // FIXME: Saving at this point is not required in the 'mask'- | 140 // FIXME: Saving at this point is not required in the 'mask'- |
141 // case, or if the clip ends up empty. | 141 // case, or if the clip ends up empty. |
142 m_clipStateSaver.save(); | 142 m_clipStateSaver.save(); |
143 if (!rootRelativeBoundsComputed) { | 143 if (!rootRelativeBoundsComputed) { |
144 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 144 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludin
gReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
145 rootRelativeBoundsComputed = true; | 145 rootRelativeBoundsComputed = true; |
146 } | 146 } |
147 | 147 |
148 m_resourceClipper = toRenderSVGResourceClipper(toRenderSVGResour
ceContainer(element->renderer())); | 148 m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResour
ceContainer(element->renderer())); |
149 if (!m_resourceClipper->applyClippingToContext(renderLayer.rende
rer(), rootRelativeBounds, | 149 if (!m_resourceClipper->applyClippingToContext(renderLayer.rende
rer(), rootRelativeBounds, |
150 paintingInfo.paintDirtyRect, context, m_clipperState)) { | 150 paintingInfo.paintDirtyRect, context, m_clipperState)) { |
151 // No need to post-apply the clipper if this failed. | 151 // No need to post-apply the clipper if this failed. |
152 m_resourceClipper = 0; | 152 m_resourceClipper = 0; |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 ~ClipPathHelper() | 158 ~ClipPathHelper() |
159 { | 159 { |
160 if (m_resourceClipper) | 160 if (m_resourceClipper) |
161 m_resourceClipper->postApplyStatefulResource(m_renderLayer.renderer(
), m_context, m_clipperState); | 161 m_resourceClipper->postApplyStatefulResource(m_renderLayer.renderer(
), m_context, m_clipperState); |
162 } | 162 } |
163 private: | 163 private: |
164 RenderSVGResourceClipper* m_resourceClipper; | 164 LayoutSVGResourceClipper* m_resourceClipper; |
165 GraphicsContextStateSaver m_clipStateSaver; | 165 GraphicsContextStateSaver m_clipStateSaver; |
166 OwnPtr<ClipPathRecorder> m_clipPathRecorder; | 166 OwnPtr<ClipPathRecorder> m_clipPathRecorder; |
167 RenderSVGResourceClipper::ClipperState m_clipperState; | 167 LayoutSVGResourceClipper::ClipperState m_clipperState; |
168 const Layer& m_renderLayer; | 168 const Layer& m_renderLayer; |
169 GraphicsContext* m_context; | 169 GraphicsContext* m_context; |
170 }; | 170 }; |
171 | 171 |
172 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy
) | 172 void LayerPainter::paintLayerContents(GraphicsContext* context, const LayerPaint
ingInfo& paintingInfo, PaintLayerFlags paintFlags, FragmentPolicy fragmentPolicy
) |
173 { | 173 { |
174 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); | 174 ASSERT(m_renderLayer.isSelfPaintingLayer() || m_renderLayer.hasSelfPaintingL
ayerDescendant()); |
175 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); | 175 ASSERT(!(paintFlags & PaintLayerAppliedTransform)); |
176 | 176 |
177 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); | 177 bool isSelfPaintingLayer = m_renderLayer.isSelfPaintingLayer(); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 if (!m_renderLayer.containsDirtyOverlayScrollbars()) | 713 if (!m_renderLayer.containsDirtyOverlayScrollbars()) |
714 return; | 714 return; |
715 | 715 |
716 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect),
paintBehavior, LayoutSize(), paintingRoot); | 716 LayerPaintingInfo paintingInfo(&m_renderLayer, enclosingIntRect(damageRect),
paintBehavior, LayoutSize(), paintingRoot); |
717 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 717 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
718 | 718 |
719 m_renderLayer.setContainsDirtyOverlayScrollbars(false); | 719 m_renderLayer.setContainsDirtyOverlayScrollbars(false); |
720 } | 720 } |
721 | 721 |
722 } // namespace blink | 722 } // namespace blink |
OLD | NEW |