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/SVGShapePainter.h" | 6 #include "core/paint/SVGShapePainter.h" |
7 | 7 |
8 #include "core/layout/svg/LayoutSVGPath.h" | 8 #include "core/layout/svg/LayoutSVGPath.h" |
9 #include "core/layout/svg/LayoutSVGResourceMarker.h" | 9 #include "core/layout/svg/LayoutSVGResourceMarker.h" |
10 #include "core/layout/svg/LayoutSVGShape.h" | 10 #include "core/layout/svg/LayoutSVGShape.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 { | 233 { |
234 const Vector<FloatPoint>* zeroLengthLineCaps = m_layoutSVGShape.zeroLengthLi
neCaps(); | 234 const Vector<FloatPoint>* zeroLengthLineCaps = m_layoutSVGShape.zeroLengthLi
neCaps(); |
235 if (!zeroLengthLineCaps || zeroLengthLineCaps->isEmpty()) | 235 if (!zeroLengthLineCaps || zeroLengthLineCaps->isEmpty()) |
236 return; | 236 return; |
237 | 237 |
238 // We need a paint for filling. | 238 // We need a paint for filling. |
239 SkPaint fillPaint = strokePaint; | 239 SkPaint fillPaint = strokePaint; |
240 fillPaint.setStyle(SkPaint::kFill_Style); | 240 fillPaint.setStyle(SkPaint::kFill_Style); |
241 | 241 |
242 AffineTransform nonScalingTransform; | 242 AffineTransform nonScalingTransform; |
243 if (m_layoutSVGShape.hasNonScalingStroke()) | 243 bool hasNonScalingStroke = m_layoutSVGShape.hasNonScalingStroke(); |
| 244 if (hasNonScalingStroke) |
244 nonScalingTransform = m_layoutSVGShape.nonScalingStrokeTransform(); | 245 nonScalingTransform = m_layoutSVGShape.nonScalingStrokeTransform(); |
245 | 246 |
246 Path tempPath; | 247 for (const FloatPoint& capPosition : *zeroLengthLineCaps) { |
247 for (size_t i = 0; i < zeroLengthLineCaps->size(); ++i) { | 248 FloatPoint position = capPosition; |
248 FloatRect subpathRect = LayoutSVGPath::zeroLengthSubpathRect((*zeroLengt
hLineCaps)[i], m_layoutSVGShape.strokeWidth()); | 249 // If non-scaling-stroke is in effect, apply the transform to the |
249 tempPath.clear(); | 250 // position (being the non-stroke geometry), and then paint the |
| 251 // requested shape. The CTM should've been adjusted in |
| 252 // SVGShapePainter::paint. |
| 253 if (hasNonScalingStroke) |
| 254 position = nonScalingTransform.mapPoint(position); |
| 255 FloatRect subpathRect = LayoutSVGPath::zeroLengthSubpathRect(position, m
_layoutSVGShape.strokeWidth()); |
250 if (m_layoutSVGShape.style()->svgStyle().capStyle() == SquareCap) | 256 if (m_layoutSVGShape.style()->svgStyle().capStyle() == SquareCap) |
251 tempPath.addRect(subpathRect); | 257 context->drawRect(subpathRect, fillPaint); |
252 else | 258 else |
253 tempPath.addEllipse(subpathRect); | 259 context->drawOval(subpathRect, fillPaint); |
254 // This open-codes LayoutSVGShape::nonScalingStrokePath, because the | |
255 // requirements here differ (we have a temporary path that we can | |
256 // mutate.) | |
257 if (m_layoutSVGShape.hasNonScalingStroke()) | |
258 tempPath.transform(nonScalingTransform); | |
259 context->drawPath(tempPath.skPath(), fillPaint); | |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 } // namespace blink | 263 } // namespace blink |
OLD | NEW |