| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if (!resources) | 184 if (!resources) |
| 185 return; | 185 return; |
| 186 | 186 |
| 187 LayoutSVGResourceMarker* markerStart = resources->markerStart(); | 187 LayoutSVGResourceMarker* markerStart = resources->markerStart(); |
| 188 LayoutSVGResourceMarker* markerMid = resources->markerMid(); | 188 LayoutSVGResourceMarker* markerMid = resources->markerMid(); |
| 189 LayoutSVGResourceMarker* markerEnd = resources->markerEnd(); | 189 LayoutSVGResourceMarker* markerEnd = resources->markerEnd(); |
| 190 if (!markerStart && !markerMid && !markerEnd) | 190 if (!markerStart && !markerMid && !markerEnd) |
| 191 return; | 191 return; |
| 192 | 192 |
| 193 float strokeWidth = m_layoutSVGShape.strokeWidth(); | 193 float strokeWidth = m_layoutSVGShape.strokeWidth(); |
| 194 unsigned size = markerPositions->size(); | |
| 195 | 194 |
| 196 for (unsigned i = 0; i < size; ++i) { | 195 for (const MarkerPosition& markerPosition : *markerPositions) { |
| 197 if (LayoutSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar
kerPositions)[i].type, markerStart, markerMid, markerEnd)) { | 196 if (const LayoutSVGResourceMarker* marker = SVGMarkerData::markerForType
(markerPosition.type, markerStart, markerMid, markerEnd)) { |
| 198 SkPictureBuilder pictureBuilder(boundingBox, nullptr, &paintInfo.con
text); | 197 SkPictureBuilder pictureBuilder(boundingBox, nullptr, &paintInfo.con
text); |
| 199 PaintInfo markerPaintInfo(pictureBuilder.context(), paintInfo); | 198 PaintInfo markerPaintInfo(pictureBuilder.context(), paintInfo); |
| 200 | 199 |
| 201 // It's expensive to track the transformed paint cull rect for each | 200 // It's expensive to track the transformed paint cull rect for each |
| 202 // marker so just disable culling. The shape paint call will already | 201 // marker so just disable culling. The shape paint call will already |
| 203 // be culled if it is outside the paint info cull rect. | 202 // be culled if it is outside the paint info cull rect. |
| 204 markerPaintInfo.m_cullRect.m_rect = LayoutRect::infiniteIntRect(); | 203 markerPaintInfo.m_cullRect.m_rect = LayoutRect::infiniteIntRect(); |
| 205 | 204 |
| 206 paintMarker(markerPaintInfo, *marker, (*markerPositions)[i], strokeW
idth); | 205 paintMarker(markerPaintInfo, *marker, markerPosition, strokeWidth); |
| 207 pictureBuilder.endRecording()->playback(paintInfo.context.canvas()); | 206 pictureBuilder.endRecording()->playback(paintInfo.context.canvas()); |
| 208 } | 207 } |
| 209 } | 208 } |
| 210 } | 209 } |
| 211 | 210 |
| 212 void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, LayoutSVGResourceM
arker& marker, const MarkerPosition& position, float strokeWidth) | 211 void SVGShapePainter::paintMarker( |
| 212 const PaintInfo& paintInfo, const LayoutSVGResourceMarker& marker, const Mar
kerPosition& position, float strokeWidth) |
| 213 { | 213 { |
| 214 // An empty viewBox disables rendering. | 214 if (!marker.shouldPaint()) |
| 215 SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element()); | |
| 216 ASSERT(markerElement); | |
| 217 if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->vie
wBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->v
alue().isEmpty()) | |
| 218 return; | 215 return; |
| 219 | 216 |
| 220 TransformRecorder transformRecorder(paintInfo.context, marker, marker.marker
Transformation(position.origin, position.angle, strokeWidth)); | 217 TransformRecorder transformRecorder(paintInfo.context, marker, marker.marker
Transformation(position.origin, position.angle, strokeWidth)); |
| 221 Optional<FloatClipRecorder> clipRecorder; | 218 Optional<FloatClipRecorder> clipRecorder; |
| 222 if (SVGLayoutSupport::isOverflowHidden(&marker)) | 219 if (SVGLayoutSupport::isOverflowHidden(&marker)) |
| 223 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker.
viewport()); | 220 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker.
viewport()); |
| 224 SVGContainerPainter(marker).paint(paintInfo); | 221 SVGContainerPainter(marker).paint(paintInfo); |
| 225 } | 222 } |
| 226 | 223 |
| 227 } // namespace blink | 224 } // namespace blink |
| OLD | NEW |