| 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/paint/ObjectPainter.h" | 8 #include "core/paint/ObjectPainter.h" |
| 9 #include "core/paint/SVGMarkerPainter.h" | 9 #include "core/paint/SVGContainerPainter.h" |
| 10 #include "core/rendering/GraphicsContextAnnotator.h" | 10 #include "core/rendering/GraphicsContextAnnotator.h" |
| 11 #include "core/rendering/PaintInfo.h" | 11 #include "core/rendering/PaintInfo.h" |
| 12 #include "core/rendering/svg/RenderSVGPath.h" | 12 #include "core/rendering/svg/RenderSVGPath.h" |
| 13 #include "core/rendering/svg/RenderSVGResourceMarker.h" |
| 13 #include "core/rendering/svg/RenderSVGShape.h" | 14 #include "core/rendering/svg/RenderSVGShape.h" |
| 14 #include "core/rendering/svg/SVGMarkerData.h" | 15 #include "core/rendering/svg/SVGMarkerData.h" |
| 15 #include "core/rendering/svg/SVGRenderSupport.h" | 16 #include "core/rendering/svg/SVGRenderSupport.h" |
| 16 #include "core/rendering/svg/SVGRenderingContext.h" | 17 #include "core/rendering/svg/SVGRenderingContext.h" |
| 17 #include "core/rendering/svg/SVGResources.h" | 18 #include "core/rendering/svg/SVGResources.h" |
| 18 #include "core/rendering/svg/SVGResourcesCache.h" | 19 #include "core/rendering/svg/SVGResourcesCache.h" |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 static bool setupNonScalingStrokeContext(AffineTransform& strokeTransform, Graph
icsContextStateSaver& stateSaver) | 23 static bool setupNonScalingStrokeContext(AffineTransform& strokeTransform, Graph
icsContextStateSaver& stateSaver) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 RenderSVGResourceMarker* markerStart = resources->markerStart(); | 156 RenderSVGResourceMarker* markerStart = resources->markerStart(); |
| 156 RenderSVGResourceMarker* markerMid = resources->markerMid(); | 157 RenderSVGResourceMarker* markerMid = resources->markerMid(); |
| 157 RenderSVGResourceMarker* markerEnd = resources->markerEnd(); | 158 RenderSVGResourceMarker* markerEnd = resources->markerEnd(); |
| 158 if (!markerStart && !markerMid && !markerEnd) | 159 if (!markerStart && !markerMid && !markerEnd) |
| 159 return; | 160 return; |
| 160 | 161 |
| 161 float strokeWidth = m_renderSVGShape.strokeWidth(); | 162 float strokeWidth = m_renderSVGShape.strokeWidth(); |
| 162 unsigned size = markerPositions->size(); | 163 unsigned size = markerPositions->size(); |
| 163 for (unsigned i = 0; i < size; ++i) { | 164 for (unsigned i = 0; i < size; ++i) { |
| 164 if (RenderSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar
kerPositions)[i].type, markerStart, markerMid, markerEnd)) | 165 if (RenderSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar
kerPositions)[i].type, markerStart, markerMid, markerEnd)) |
| 165 SVGMarkerPainter(*marker).paint(paintInfo, (*markerPositions)[i], st
rokeWidth); | 166 paintMarker(paintInfo, *marker, (*markerPositions)[i], strokeWidth); |
| 166 } | 167 } |
| 167 } | 168 } |
| 168 | 169 |
| 170 void SVGShapePainter::paintMarker(PaintInfo& paintInfo, RenderSVGResourceMarker&
marker, const MarkerPosition& position, float strokeWidth) |
| 171 { |
| 172 // An empty viewBox disables rendering. |
| 173 SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element()); |
| 174 ASSERT(markerElement); |
| 175 if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->vie
wBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->v
alue().isEmpty()) |
| 176 return; |
| 177 |
| 178 PaintInfo info(paintInfo); |
| 179 GraphicsContextStateSaver stateSaver(*info.context, false); |
| 180 info.applyTransform(marker.markerTransformation(position.origin, position.an
gle, strokeWidth), &stateSaver); |
| 181 |
| 182 if (SVGRenderSupport::isOverflowHidden(&marker)) { |
| 183 stateSaver.saveIfNeeded(); |
| 184 info.context->clip(marker.viewport()); |
| 185 } |
| 186 |
| 187 SVGContainerPainter(marker).paint(info); |
| 188 } |
| 189 |
| 169 void SVGShapePainter::strokeZeroLengthLineCaps(GraphicsContext* context) | 190 void SVGShapePainter::strokeZeroLengthLineCaps(GraphicsContext* context) |
| 170 { | 191 { |
| 171 const Vector<FloatPoint>* zeroLengthLineCaps = m_renderSVGShape.zeroLengthLi
neCaps(); | 192 const Vector<FloatPoint>* zeroLengthLineCaps = m_renderSVGShape.zeroLengthLi
neCaps(); |
| 172 if (!zeroLengthLineCaps || zeroLengthLineCaps->isEmpty()) | 193 if (!zeroLengthLineCaps || zeroLengthLineCaps->isEmpty()) |
| 173 return; | 194 return; |
| 174 | 195 |
| 175 Path* usePath; | 196 Path* usePath; |
| 176 AffineTransform nonScalingTransform; | 197 AffineTransform nonScalingTransform; |
| 177 | 198 |
| 178 if (m_renderSVGShape.hasNonScalingStroke()) | 199 if (m_renderSVGShape.hasNonScalingStroke()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 195 tempPath.clear(); | 216 tempPath.clear(); |
| 196 if (m_renderSVGShape.style()->svgStyle().capStyle() == SquareCap) | 217 if (m_renderSVGShape.style()->svgStyle().capStyle() == SquareCap) |
| 197 tempPath.addRect(RenderSVGPath::zeroLengthSubpathRect(linecapPosition, m
_renderSVGShape.strokeWidth())); | 218 tempPath.addRect(RenderSVGPath::zeroLengthSubpathRect(linecapPosition, m
_renderSVGShape.strokeWidth())); |
| 198 else | 219 else |
| 199 tempPath.addEllipse(RenderSVGPath::zeroLengthSubpathRect(linecapPosition
, m_renderSVGShape.strokeWidth())); | 220 tempPath.addEllipse(RenderSVGPath::zeroLengthSubpathRect(linecapPosition
, m_renderSVGShape.strokeWidth())); |
| 200 | 221 |
| 201 return &tempPath; | 222 return &tempPath; |
| 202 } | 223 } |
| 203 | 224 |
| 204 } // namespace blink | 225 } // namespace blink |
| OLD | NEW |