| 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/PaintInfo.h" | 8 #include "core/layout/PaintInfo.h" |
| 9 #include "core/layout/svg/LayoutSVGResourceMarker.h" |
| 9 #include "core/layout/svg/SVGLayoutSupport.h" | 10 #include "core/layout/svg/SVGLayoutSupport.h" |
| 10 #include "core/layout/svg/SVGMarkerData.h" | 11 #include "core/layout/svg/SVGMarkerData.h" |
| 11 #include "core/layout/svg/SVGResources.h" | 12 #include "core/layout/svg/SVGResources.h" |
| 12 #include "core/layout/svg/SVGResourcesCache.h" | 13 #include "core/layout/svg/SVGResourcesCache.h" |
| 13 #include "core/paint/GraphicsContextAnnotator.h" | 14 #include "core/paint/GraphicsContextAnnotator.h" |
| 14 #include "core/paint/ObjectPainter.h" | 15 #include "core/paint/ObjectPainter.h" |
| 15 #include "core/paint/RenderDrawingRecorder.h" | 16 #include "core/paint/RenderDrawingRecorder.h" |
| 16 #include "core/paint/SVGContainerPainter.h" | 17 #include "core/paint/SVGContainerPainter.h" |
| 17 #include "core/paint/SVGPaintContext.h" | 18 #include "core/paint/SVGPaintContext.h" |
| 18 #include "core/paint/TransformRecorder.h" | 19 #include "core/paint/TransformRecorder.h" |
| 19 #include "core/rendering/svg/RenderSVGPath.h" | 20 #include "core/rendering/svg/RenderSVGPath.h" |
| 20 #include "core/rendering/svg/RenderSVGResourceMarker.h" | |
| 21 #include "core/rendering/svg/RenderSVGShape.h" | 21 #include "core/rendering/svg/RenderSVGShape.h" |
| 22 #include "platform/graphics/paint/DisplayItemList.h" | 22 #include "platform/graphics/paint/DisplayItemList.h" |
| 23 #include "third_party/skia/include/core/SkPicture.h" | 23 #include "third_party/skia/include/core/SkPicture.h" |
| 24 | 24 |
| 25 namespace blink { | 25 namespace blink { |
| 26 | 26 |
| 27 static bool setupNonScalingStrokeContext(AffineTransform& strokeTransform, Graph
icsContextStateSaver& stateSaver) | 27 static bool setupNonScalingStrokeContext(AffineTransform& strokeTransform, Graph
icsContextStateSaver& stateSaver) |
| 28 { | 28 { |
| 29 if (!strokeTransform.isInvertible()) | 29 if (!strokeTransform.isInvertible()) |
| 30 return false; | 30 return false; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void SVGShapePainter::paintMarkers(const PaintInfo& paintInfo) | 152 void SVGShapePainter::paintMarkers(const PaintInfo& paintInfo) |
| 153 { | 153 { |
| 154 const Vector<MarkerPosition>* markerPositions = m_renderSVGShape.markerPosit
ions(); | 154 const Vector<MarkerPosition>* markerPositions = m_renderSVGShape.markerPosit
ions(); |
| 155 if (!markerPositions || markerPositions->isEmpty()) | 155 if (!markerPositions || markerPositions->isEmpty()) |
| 156 return; | 156 return; |
| 157 | 157 |
| 158 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_renderSVGShape); | 158 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_renderSVGShape); |
| 159 if (!resources) | 159 if (!resources) |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 RenderSVGResourceMarker* markerStart = resources->markerStart(); | 162 LayoutSVGResourceMarker* markerStart = resources->markerStart(); |
| 163 RenderSVGResourceMarker* markerMid = resources->markerMid(); | 163 LayoutSVGResourceMarker* markerMid = resources->markerMid(); |
| 164 RenderSVGResourceMarker* markerEnd = resources->markerEnd(); | 164 LayoutSVGResourceMarker* markerEnd = resources->markerEnd(); |
| 165 if (!markerStart && !markerMid && !markerEnd) | 165 if (!markerStart && !markerMid && !markerEnd) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 float strokeWidth = m_renderSVGShape.strokeWidth(); | 168 float strokeWidth = m_renderSVGShape.strokeWidth(); |
| 169 unsigned size = markerPositions->size(); | 169 unsigned size = markerPositions->size(); |
| 170 for (unsigned i = 0; i < size; ++i) { | 170 for (unsigned i = 0; i < size; ++i) { |
| 171 if (RenderSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar
kerPositions)[i].type, markerStart, markerMid, markerEnd)) | 171 if (LayoutSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar
kerPositions)[i].type, markerStart, markerMid, markerEnd)) |
| 172 paintMarker(paintInfo, *marker, (*markerPositions)[i], strokeWidth); | 172 paintMarker(paintInfo, *marker, (*markerPositions)[i], strokeWidth); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, RenderSVGResourceM
arker& marker, const MarkerPosition& position, float strokeWidth) | 176 void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, LayoutSVGResourceM
arker& marker, const MarkerPosition& position, float strokeWidth) |
| 177 { | 177 { |
| 178 // An empty viewBox disables rendering. | 178 // An empty viewBox disables rendering. |
| 179 SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element()); | 179 SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element()); |
| 180 ASSERT(markerElement); | 180 ASSERT(markerElement); |
| 181 if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->vie
wBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->v
alue().isEmpty()) | 181 if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->vie
wBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->v
alue().isEmpty()) |
| 182 return; | 182 return; |
| 183 | 183 |
| 184 OwnPtr<DisplayItemList> displayItemList; | 184 OwnPtr<DisplayItemList> displayItemList; |
| 185 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 185 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 186 displayItemList = DisplayItemList::create(); | 186 displayItemList = DisplayItemList::create(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 tempPath.clear(); | 233 tempPath.clear(); |
| 234 if (m_renderSVGShape.style()->svgStyle().capStyle() == SquareCap) | 234 if (m_renderSVGShape.style()->svgStyle().capStyle() == SquareCap) |
| 235 tempPath.addRect(RenderSVGPath::zeroLengthSubpathRect(linecapPosition, m
_renderSVGShape.strokeWidth())); | 235 tempPath.addRect(RenderSVGPath::zeroLengthSubpathRect(linecapPosition, m
_renderSVGShape.strokeWidth())); |
| 236 else | 236 else |
| 237 tempPath.addEllipse(RenderSVGPath::zeroLengthSubpathRect(linecapPosition
, m_renderSVGShape.strokeWidth())); | 237 tempPath.addEllipse(RenderSVGPath::zeroLengthSubpathRect(linecapPosition
, m_renderSVGShape.strokeWidth())); |
| 238 | 238 |
| 239 return &tempPath; | 239 return &tempPath; |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace blink | 242 } // namespace blink |
| OLD | NEW |