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/SVGShapePainter.h" | 5 #include "core/paint/SVGShapePainter.h" |
6 | 6 |
7 #include "core/layout/svg/LayoutSVGResourceMarker.h" | 7 #include "core/layout/svg/LayoutSVGResourceMarker.h" |
8 #include "core/layout/svg/LayoutSVGShape.h" | 8 #include "core/layout/svg/LayoutSVGShape.h" |
9 #include "core/layout/svg/SVGLayoutSupport.h" | 9 #include "core/layout/svg/SVGLayoutSupport.h" |
10 #include "core/layout/svg/SVGMarkerData.h" | 10 #include "core/layout/svg/SVGMarkerData.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 paintContext.paintInfo().phase)) { | 66 paintContext.paintInfo().phase)) { |
67 LayoutObjectDrawingRecorder recorder( | 67 LayoutObjectDrawingRecorder recorder( |
68 paintContext.paintInfo().context, m_layoutSVGShape, | 68 paintContext.paintInfo().context, m_layoutSVGShape, |
69 paintContext.paintInfo().phase, boundingBox); | 69 paintContext.paintInfo().phase, boundingBox); |
70 const SVGComputedStyle& svgStyle = m_layoutSVGShape.style()->svgStyle(); | 70 const SVGComputedStyle& svgStyle = m_layoutSVGShape.style()->svgStyle(); |
71 | 71 |
72 bool shouldAntiAlias = svgStyle.shapeRendering() != SR_CRISPEDGES && | 72 bool shouldAntiAlias = svgStyle.shapeRendering() != SR_CRISPEDGES && |
73 svgStyle.shapeRendering() != SR_OPTIMIZESPEED; | 73 svgStyle.shapeRendering() != SR_OPTIMIZESPEED; |
74 | 74 |
75 for (int i = 0; i < 3; i++) { | 75 for (int i = 0; i < 3; i++) { |
76 switch (svgStyle.paintOrderType(i)) { | 76 switch (m_layoutSVGShape.style()->paintOrderType(i)) { |
77 case PT_FILL: { | 77 case PT_FILL: { |
78 PaintFlags fillFlags; | 78 PaintFlags fillFlags; |
79 if (!SVGPaintContext::paintForLayoutObject( | 79 if (!SVGPaintContext::paintForLayoutObject( |
80 paintContext.paintInfo(), m_layoutSVGShape.styleRef(), | 80 paintContext.paintInfo(), m_layoutSVGShape.styleRef(), |
81 m_layoutSVGShape, ApplyToFillMode, fillFlags)) | 81 m_layoutSVGShape, ApplyToFillMode, fillFlags)) |
82 break; | 82 break; |
83 fillFlags.setAntiAlias(shouldAntiAlias); | 83 fillFlags.setAntiAlias(shouldAntiAlias); |
84 fillShape(paintContext.paintInfo().context, fillFlags, | 84 fillShape(paintContext.paintInfo().context, fillFlags, |
85 fillRuleFromStyle(paintContext.paintInfo(), svgStyle)); | 85 fillRuleFromStyle(paintContext.paintInfo(), svgStyle)); |
86 break; | 86 break; |
87 } | 87 } |
88 case PT_STROKE: | 88 case PT_STROKE: |
89 if (svgStyle.hasVisibleStroke()) { | 89 if (m_layoutSVGShape.style()->hasVisibleStroke()) { |
90 GraphicsContextStateSaver stateSaver( | 90 GraphicsContextStateSaver stateSaver( |
91 paintContext.paintInfo().context, false); | 91 paintContext.paintInfo().context, false); |
92 AffineTransform nonScalingTransform; | 92 AffineTransform nonScalingTransform; |
93 const AffineTransform* additionalPaintServerTransform = 0; | 93 const AffineTransform* additionalPaintServerTransform = 0; |
94 | 94 |
95 if (m_layoutSVGShape.hasNonScalingStroke()) { | 95 if (m_layoutSVGShape.hasNonScalingStroke()) { |
96 nonScalingTransform = | 96 nonScalingTransform = |
97 m_layoutSVGShape.nonScalingStrokeTransform(); | 97 m_layoutSVGShape.nonScalingStrokeTransform(); |
98 if (!setupNonScalingStrokeContext(nonScalingTransform, | 98 if (!setupNonScalingStrokeContext(nonScalingTransform, |
99 stateSaver)) | 99 stateSaver)) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 default: { | 169 default: { |
170 PathWithTemporaryWindingRule pathWithWinding(m_layoutSVGShape.path(), | 170 PathWithTemporaryWindingRule pathWithWinding(m_layoutSVGShape.path(), |
171 fillType); | 171 fillType); |
172 context.drawPath(pathWithWinding.getSkPath(), flags); | 172 context.drawPath(pathWithWinding.getSkPath(), flags); |
173 } | 173 } |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void SVGShapePainter::strokeShape(GraphicsContext& context, | 177 void SVGShapePainter::strokeShape(GraphicsContext& context, |
178 const PaintFlags& flags) { | 178 const PaintFlags& flags) { |
179 if (!m_layoutSVGShape.style()->svgStyle().hasVisibleStroke()) | 179 if (!m_layoutSVGShape.style()->hasVisibleStroke()) |
180 return; | 180 return; |
181 | 181 |
182 switch (m_layoutSVGShape.geometryCodePath()) { | 182 switch (m_layoutSVGShape.geometryCodePath()) { |
183 case RectGeometryFastPath: | 183 case RectGeometryFastPath: |
184 context.drawRect(m_layoutSVGShape.objectBoundingBox(), flags); | 184 context.drawRect(m_layoutSVGShape.objectBoundingBox(), flags); |
185 break; | 185 break; |
186 case EllipseGeometryFastPath: | 186 case EllipseGeometryFastPath: |
187 context.drawOval(m_layoutSVGShape.objectBoundingBox(), flags); | 187 context.drawOval(m_layoutSVGShape.objectBoundingBox(), flags); |
188 break; | 188 break; |
189 default: | 189 default: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 marker.markerTransformation(position.origin, position.angle, | 245 marker.markerTransformation(position.origin, position.angle, |
246 strokeWidth)); | 246 strokeWidth)); |
247 Optional<FloatClipRecorder> clipRecorder; | 247 Optional<FloatClipRecorder> clipRecorder; |
248 if (SVGLayoutSupport::isOverflowHidden(&marker)) | 248 if (SVGLayoutSupport::isOverflowHidden(&marker)) |
249 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, | 249 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, |
250 marker.viewport()); | 250 marker.viewport()); |
251 SVGContainerPainter(marker).paint(paintInfo); | 251 SVGContainerPainter(marker).paint(paintInfo); |
252 } | 252 } |
253 | 253 |
254 } // namespace blink | 254 } // namespace blink |
OLD | NEW |