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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (m_layoutSVGShape.style()->outlineWidth()) { | 113 if (m_layoutSVGShape.style()->outlineWidth()) { |
114 PaintInfo outlinePaintInfo(paintInfoBeforeFiltering); | 114 PaintInfo outlinePaintInfo(paintInfoBeforeFiltering); |
115 outlinePaintInfo.phase = PaintPhaseSelfOutlineOnly; | 115 outlinePaintInfo.phase = PaintPhaseSelfOutlineOnly; |
116 ObjectPainter(m_layoutSVGShape).paintOutline(outlinePaintInfo, LayoutPoi
nt(boundingBox.location())); | 116 ObjectPainter(m_layoutSVGShape).paintOutline(outlinePaintInfo, LayoutPoi
nt(boundingBox.location())); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 class PathWithTemporaryWindingRule { | 120 class PathWithTemporaryWindingRule { |
121 public: | 121 public: |
122 PathWithTemporaryWindingRule(Path& path, SkPath::FillType fillType) | 122 PathWithTemporaryWindingRule(Path& path, SkPath::FillType fillType) |
123 : m_path(const_cast<SkPath&>(path.skPath())) | 123 : m_path(const_cast<SkPath&>(path.getSkPath())) |
124 { | 124 { |
125 m_savedFillType = m_path.getFillType(); | 125 m_savedFillType = m_path.getFillType(); |
126 m_path.setFillType(fillType); | 126 m_path.setFillType(fillType); |
127 } | 127 } |
128 ~PathWithTemporaryWindingRule() | 128 ~PathWithTemporaryWindingRule() |
129 { | 129 { |
130 m_path.setFillType(m_savedFillType); | 130 m_path.setFillType(m_savedFillType); |
131 } | 131 } |
132 | 132 |
133 const SkPath& skPath() const { return m_path; } | 133 const SkPath& getSkPath() const { return m_path; } |
134 | 134 |
135 private: | 135 private: |
136 SkPath& m_path; | 136 SkPath& m_path; |
137 SkPath::FillType m_savedFillType; | 137 SkPath::FillType m_savedFillType; |
138 }; | 138 }; |
139 | 139 |
140 void SVGShapePainter::fillShape(GraphicsContext& context, const SkPaint& paint,
SkPath::FillType fillType) | 140 void SVGShapePainter::fillShape(GraphicsContext& context, const SkPaint& paint,
SkPath::FillType fillType) |
141 { | 141 { |
142 switch (m_layoutSVGShape.geometryCodePath()) { | 142 switch (m_layoutSVGShape.geometryCodePath()) { |
143 case RectGeometryFastPath: | 143 case RectGeometryFastPath: |
144 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint); | 144 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint); |
145 break; | 145 break; |
146 case EllipseGeometryFastPath: | 146 case EllipseGeometryFastPath: |
147 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint); | 147 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint); |
148 break; | 148 break; |
149 default: { | 149 default: { |
150 PathWithTemporaryWindingRule pathWithWinding(m_layoutSVGShape.path(), fi
llType); | 150 PathWithTemporaryWindingRule pathWithWinding(m_layoutSVGShape.path(), fi
llType); |
151 context.drawPath(pathWithWinding.skPath(), paint); | 151 context.drawPath(pathWithWinding.getSkPath(), paint); |
152 } | 152 } |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void SVGShapePainter::strokeShape(GraphicsContext& context, const SkPaint& paint
) | 156 void SVGShapePainter::strokeShape(GraphicsContext& context, const SkPaint& paint
) |
157 { | 157 { |
158 if (!m_layoutSVGShape.style()->svgStyle().hasVisibleStroke()) | 158 if (!m_layoutSVGShape.style()->svgStyle().hasVisibleStroke()) |
159 return; | 159 return; |
160 | 160 |
161 switch (m_layoutSVGShape.geometryCodePath()) { | 161 switch (m_layoutSVGShape.geometryCodePath()) { |
162 case RectGeometryFastPath: | 162 case RectGeometryFastPath: |
163 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint); | 163 context.drawRect(m_layoutSVGShape.objectBoundingBox(), paint); |
164 break; | 164 break; |
165 case EllipseGeometryFastPath: | 165 case EllipseGeometryFastPath: |
166 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint); | 166 context.drawOval(m_layoutSVGShape.objectBoundingBox(), paint); |
167 break; | 167 break; |
168 default: | 168 default: |
169 ASSERT(m_layoutSVGShape.hasPath()); | 169 ASSERT(m_layoutSVGShape.hasPath()); |
170 Path* usePath = &m_layoutSVGShape.path(); | 170 Path* usePath = &m_layoutSVGShape.path(); |
171 if (m_layoutSVGShape.hasNonScalingStroke()) | 171 if (m_layoutSVGShape.hasNonScalingStroke()) |
172 usePath = m_layoutSVGShape.nonScalingStrokePath(usePath, m_layoutSVG
Shape.nonScalingStrokeTransform()); | 172 usePath = m_layoutSVGShape.nonScalingStrokePath(usePath, m_layoutSVG
Shape.nonScalingStrokeTransform()); |
173 context.drawPath(usePath->skPath(), paint); | 173 context.drawPath(usePath->getSkPath(), paint); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void SVGShapePainter::paintMarkers(const PaintInfo& paintInfo, const FloatRect&
boundingBox) | 177 void SVGShapePainter::paintMarkers(const PaintInfo& paintInfo, const FloatRect&
boundingBox) |
178 { | 178 { |
179 const Vector<MarkerPosition>* markerPositions = m_layoutSVGShape.markerPosit
ions(); | 179 const Vector<MarkerPosition>* markerPositions = m_layoutSVGShape.markerPosit
ions(); |
180 if (!markerPositions || markerPositions->isEmpty()) | 180 if (!markerPositions || markerPositions->isEmpty()) |
181 return; | 181 return; |
182 | 182 |
183 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_layoutSVGShape); | 183 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(
&m_layoutSVGShape); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return; | 218 return; |
219 | 219 |
220 TransformRecorder transformRecorder(paintInfo.context, marker, marker.marker
Transformation(position.origin, position.angle, strokeWidth)); | 220 TransformRecorder transformRecorder(paintInfo.context, marker, marker.marker
Transformation(position.origin, position.angle, strokeWidth)); |
221 Optional<FloatClipRecorder> clipRecorder; | 221 Optional<FloatClipRecorder> clipRecorder; |
222 if (SVGLayoutSupport::isOverflowHidden(&marker)) | 222 if (SVGLayoutSupport::isOverflowHidden(&marker)) |
223 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker.
viewport()); | 223 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker.
viewport()); |
224 SVGContainerPainter(marker).paint(paintInfo); | 224 SVGContainerPainter(marker).paint(paintInfo); |
225 } | 225 } |
226 | 226 |
227 } // namespace blink | 227 } // namespace blink |
OLD | NEW |