OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005, 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. | 5 * Copyright (C) 2009 Google, Inc. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> | 8 * Copyright (C) 2009 Jeff Schiller <codedread@gmail.com> |
9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> | 9 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> |
10 * Copyright (C) 2011 University of Szeged | 10 * Copyright (C) 2011 University of Szeged |
(...skipping 10 matching lines...) Expand all Loading... |
21 * | 21 * |
22 * You should have received a copy of the GNU Library General Public License | 22 * You should have received a copy of the GNU Library General Public License |
23 * along with this library; see the file COPYING.LIB. If not, write to | 23 * along with this library; see the file COPYING.LIB. If not, write to |
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 * Boston, MA 02110-1301, USA. | 25 * Boston, MA 02110-1301, USA. |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/rendering/svg/RenderSVGShape.h" | 29 #include "core/rendering/svg/RenderSVGShape.h" |
30 | 30 |
| 31 #include "core/paint/SVGPaintServer.h" |
31 #include "core/rendering/GraphicsContextAnnotator.h" | 32 #include "core/rendering/GraphicsContextAnnotator.h" |
32 #include "core/rendering/HitTestRequest.h" | 33 #include "core/rendering/HitTestRequest.h" |
33 #include "core/rendering/PointerEventsHitRules.h" | 34 #include "core/rendering/PointerEventsHitRules.h" |
34 #include "core/rendering/svg/RenderSVGResourceMarker.h" | 35 #include "core/rendering/svg/RenderSVGResourceMarker.h" |
35 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" | |
36 #include "core/rendering/svg/SVGPathData.h" | 36 #include "core/rendering/svg/SVGPathData.h" |
37 #include "core/rendering/svg/SVGRenderSupport.h" | 37 #include "core/rendering/svg/SVGRenderSupport.h" |
38 #include "core/rendering/svg/SVGRenderingContext.h" | 38 #include "core/rendering/svg/SVGRenderingContext.h" |
39 #include "core/rendering/svg/SVGResources.h" | 39 #include "core/rendering/svg/SVGResources.h" |
40 #include "core/rendering/svg/SVGResourcesCache.h" | 40 #include "core/rendering/svg/SVGResourcesCache.h" |
41 #include "core/svg/SVGGraphicsElement.h" | 41 #include "core/svg/SVGGraphicsElement.h" |
42 #include "platform/geometry/FloatPoint.h" | 42 #include "platform/geometry/FloatPoint.h" |
43 #include "platform/graphics/GraphicsContextStateSaver.h" | 43 #include "platform/graphics/GraphicsContextStateSaver.h" |
44 #include "wtf/MathExtras.h" | 44 #include "wtf/MathExtras.h" |
45 | 45 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!SVGResources::supportsMarkers(*toSVGGraphicsElement(element()))) | 193 if (!SVGResources::supportsMarkers(*toSVGGraphicsElement(element()))) |
194 return false; | 194 return false; |
195 | 195 |
196 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); | 196 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); |
197 if (!resources) | 197 if (!resources) |
198 return false; | 198 return false; |
199 | 199 |
200 return resources->markerStart() || resources->markerMid() || resources->mark
erEnd(); | 200 return resources->markerStart() || resources->markerMid() || resources->mark
erEnd(); |
201 } | 201 } |
202 | 202 |
203 void RenderSVGShape::fillShape(RenderStyle* style, GraphicsContext* context) | |
204 { | |
205 bool hasFallback; | |
206 if (RenderSVGResource* fillPaintingResource = RenderSVGResource::requestPain
tingResource(ApplyToFillMode, this, style, hasFallback)) { | |
207 if (fillPaintingResource->applyResource(this, style, context, ApplyToFil
lMode)) { | |
208 fillShape(context); | |
209 fillPaintingResource->postApplyResource(context); | |
210 } else if (hasFallback) { | |
211 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::s
haredSolidPaintingResource(); | |
212 if (fallbackResource->applyResource(this, style, context, ApplyToFil
lMode)) { | |
213 fillShape(context); | |
214 fallbackResource->postApplyResource(context); | |
215 } | |
216 } | |
217 } | |
218 } | |
219 | |
220 void RenderSVGShape::strokeShape(RenderStyle* style, GraphicsContext* context) | |
221 { | |
222 bool hasFallback; | |
223 if (RenderSVGResource* strokePaintingResource = RenderSVGResource::requestPa
intingResource(ApplyToStrokeMode, this, style, hasFallback)) { | |
224 if (strokePaintingResource->applyResource(this, style, context, ApplyToS
trokeMode)) { | |
225 strokeShape(context); | |
226 strokePaintingResource->postApplyResource(context); | |
227 } else if (hasFallback) { | |
228 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::s
haredSolidPaintingResource(); | |
229 if (fallbackResource->applyResource(this, style, context, ApplyToStr
okeMode)) { | |
230 strokeShape(context); | |
231 fallbackResource->postApplyResource(context); | |
232 } | |
233 } | |
234 } | |
235 } | |
236 | |
237 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&) | 203 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&) |
238 { | 204 { |
239 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 205 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
240 if (paintInfo.phase != PaintPhaseForeground | 206 if (paintInfo.phase != PaintPhaseForeground |
241 || style()->visibility() == HIDDEN | 207 || style()->visibility() == HIDDEN |
242 || isShapeEmpty()) | 208 || isShapeEmpty()) |
243 return; | 209 return; |
244 | 210 |
245 FloatRect boundingBox = paintInvalidationRectInLocalCoordinates(); | 211 FloatRect boundingBox = paintInvalidationRectInLocalCoordinates(); |
246 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox,
m_localTransform, paintInfo)) | 212 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox,
m_localTransform, paintInfo)) |
247 return; | 213 return; |
248 | 214 |
249 PaintInfo childPaintInfo(paintInfo); | 215 PaintInfo childPaintInfo(paintInfo); |
250 | 216 |
251 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); | 217 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); |
252 childPaintInfo.applyTransform(m_localTransform); | 218 childPaintInfo.applyTransform(m_localTransform); |
253 | 219 |
254 SVGRenderingContext renderingContext(this, childPaintInfo); | 220 SVGRenderingContext renderingContext(this, childPaintInfo); |
255 | 221 |
256 if (renderingContext.isRenderingPrepared()) { | 222 if (renderingContext.isRenderingPrepared()) { |
257 const SVGRenderStyle& svgStyle = style()->svgStyle(); | 223 const SVGRenderStyle& svgStyle = style()->svgStyle(); |
258 if (svgStyle.shapeRendering() == SR_CRISPEDGES) | 224 if (svgStyle.shapeRendering() == SR_CRISPEDGES) |
259 childPaintInfo.context->setShouldAntialias(false); | 225 childPaintInfo.context->setShouldAntialias(false); |
260 | 226 |
261 for (int i = 0; i < 3; i++) { | 227 for (int i = 0; i < 3; i++) { |
262 switch (svgStyle.paintOrderType(i)) { | 228 switch (svgStyle.paintOrderType(i)) { |
263 case PT_FILL: | 229 case PT_FILL: { |
264 fillShape(this->style(), childPaintInfo.context); | 230 GraphicsContextStateSaver stateSaver(*childPaintInfo.context, fa
lse); |
| 231 if (!SVGPaintServer::updateGraphicsContext(stateSaver, style(),
*this, ApplyToFillMode)) |
| 232 break; |
| 233 fillShape(childPaintInfo.context); |
265 break; | 234 break; |
| 235 } |
266 case PT_STROKE: | 236 case PT_STROKE: |
267 if (svgStyle.hasVisibleStroke()) { | 237 if (svgStyle.hasVisibleStroke()) { |
268 GraphicsContextStateSaver stateSaver(*childPaintInfo.context
, false); | 238 GraphicsContextStateSaver stateSaver(*childPaintInfo.context
, false); |
269 AffineTransform nonScalingTransform; | 239 AffineTransform nonScalingTransform; |
270 | 240 |
271 if (hasNonScalingStroke()) { | 241 if (hasNonScalingStroke()) { |
272 AffineTransform nonScalingTransform = nonScalingStrokeTr
ansform(); | 242 AffineTransform nonScalingTransform = nonScalingStrokeTr
ansform(); |
273 if (!setupNonScalingStrokeContext(nonScalingTransform, s
tateSaver)) | 243 if (!setupNonScalingStrokeContext(nonScalingTransform, s
tateSaver)) |
274 return; | 244 return; |
275 } | 245 } |
276 | 246 |
277 strokeShape(this->style(), childPaintInfo.context); | 247 if (!SVGPaintServer::updateGraphicsContext(stateSaver, style
(), *this, ApplyToStrokeMode)) |
| 248 break; |
| 249 strokeShape(childPaintInfo.context); |
278 } | 250 } |
279 break; | 251 break; |
280 case PT_MARKERS: | 252 case PT_MARKERS: |
281 if (!m_markerPositions.isEmpty()) | 253 if (!m_markerPositions.isEmpty()) |
282 drawMarkers(childPaintInfo); | 254 drawMarkers(childPaintInfo); |
283 break; | 255 break; |
284 default: | 256 default: |
285 ASSERT_NOT_REACHED(); | 257 ASSERT_NOT_REACHED(); |
286 break; | 258 break; |
287 } | 259 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 ASSERT(resources); | 434 ASSERT(resources); |
463 | 435 |
464 RenderSVGResourceMarker* markerStart = resources->markerStart(); | 436 RenderSVGResourceMarker* markerStart = resources->markerStart(); |
465 | 437 |
466 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); | 438 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); |
467 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); | 439 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); |
468 markerData.pathIsDone(); | 440 markerData.pathIsDone(); |
469 } | 441 } |
470 | 442 |
471 } | 443 } |
OLD | NEW |