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 14 matching lines...) Expand all Loading... |
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/rendering/GraphicsContextAnnotator.h" | 31 #include "core/rendering/GraphicsContextAnnotator.h" |
32 #include "core/rendering/HitTestRequest.h" | 32 #include "core/rendering/HitTestRequest.h" |
33 #include "core/rendering/PointerEventsHitRules.h" | 33 #include "core/rendering/PointerEventsHitRules.h" |
34 #include "core/rendering/svg/RenderSVGResourceMarker.h" | 34 #include "core/rendering/svg/RenderSVGResourceMarker.h" |
35 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" | |
36 #include "core/rendering/svg/SVGPathData.h" | 35 #include "core/rendering/svg/SVGPathData.h" |
37 #include "core/rendering/svg/SVGRenderSupport.h" | 36 #include "core/rendering/svg/SVGRenderSupport.h" |
38 #include "core/rendering/svg/SVGRenderingContext.h" | 37 #include "core/rendering/svg/SVGRenderingContext.h" |
39 #include "core/rendering/svg/SVGResources.h" | 38 #include "core/rendering/svg/SVGResources.h" |
40 #include "core/rendering/svg/SVGResourcesCache.h" | 39 #include "core/rendering/svg/SVGResourcesCache.h" |
41 #include "core/svg/SVGGraphicsElement.h" | 40 #include "core/svg/SVGGraphicsElement.h" |
42 #include "platform/geometry/FloatPoint.h" | 41 #include "platform/geometry/FloatPoint.h" |
43 #include "platform/graphics/GraphicsContextStateSaver.h" | 42 #include "platform/graphics/GraphicsContextStateSaver.h" |
44 #include "wtf/MathExtras.h" | 43 #include "wtf/MathExtras.h" |
45 | 44 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!SVGResources::supportsMarkers(*toSVGGraphicsElement(element()))) | 192 if (!SVGResources::supportsMarkers(*toSVGGraphicsElement(element()))) |
194 return false; | 193 return false; |
195 | 194 |
196 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); | 195 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); |
197 if (!resources) | 196 if (!resources) |
198 return false; | 197 return false; |
199 | 198 |
200 return resources->markerStart() || resources->markerMid() || resources->mark
erEnd(); | 199 return resources->markerStart() || resources->markerMid() || resources->mark
erEnd(); |
201 } | 200 } |
202 | 201 |
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&) | 202 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&) |
238 { | 203 { |
239 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 204 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
240 if (paintInfo.phase != PaintPhaseForeground | 205 if (paintInfo.phase != PaintPhaseForeground |
241 || style()->visibility() == HIDDEN | 206 || style()->visibility() == HIDDEN |
242 || isShapeEmpty()) | 207 || isShapeEmpty()) |
243 return; | 208 return; |
244 | 209 |
245 FloatRect boundingBox = paintInvalidationRectInLocalCoordinates(); | 210 FloatRect boundingBox = paintInvalidationRectInLocalCoordinates(); |
246 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox,
m_localTransform, paintInfo)) | 211 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox,
m_localTransform, paintInfo)) |
247 return; | 212 return; |
248 | 213 |
249 PaintInfo childPaintInfo(paintInfo); | 214 PaintInfo childPaintInfo(paintInfo); |
250 | 215 |
251 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); | 216 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); |
252 childPaintInfo.applyTransform(m_localTransform); | 217 childPaintInfo.applyTransform(m_localTransform); |
253 | 218 |
254 SVGRenderingContext renderingContext(this, childPaintInfo); | 219 SVGRenderingContext renderingContext(this, childPaintInfo); |
255 | 220 |
256 if (renderingContext.isRenderingPrepared()) { | 221 if (renderingContext.isRenderingPrepared()) { |
257 const SVGRenderStyle& svgStyle = style()->svgStyle(); | 222 const SVGRenderStyle& svgStyle = style()->svgStyle(); |
258 if (svgStyle.shapeRendering() == SR_CRISPEDGES) | 223 if (svgStyle.shapeRendering() == SR_CRISPEDGES) |
259 childPaintInfo.context->setShouldAntialias(false); | 224 childPaintInfo.context->setShouldAntialias(false); |
260 | 225 |
261 for (int i = 0; i < 3; i++) { | 226 for (int i = 0; i < 3; i++) { |
262 switch (svgStyle.paintOrderType(i)) { | 227 switch (svgStyle.paintOrderType(i)) { |
263 case PT_FILL: | 228 case PT_FILL: { |
264 fillShape(this->style(), childPaintInfo.context); | 229 GraphicsContextStateSaver stateSaver(*childPaintInfo.context, fa
lse); |
| 230 if (!SVGRenderSupport::updateGraphicsContext(stateSaver, style()
, *this, ApplyToFillMode)) |
| 231 break; |
| 232 fillShape(childPaintInfo.context); |
265 break; | 233 break; |
| 234 } |
266 case PT_STROKE: | 235 case PT_STROKE: |
267 if (svgStyle.hasVisibleStroke()) { | 236 if (svgStyle.hasVisibleStroke()) { |
268 GraphicsContextStateSaver stateSaver(*childPaintInfo.context
, false); | 237 GraphicsContextStateSaver stateSaver(*childPaintInfo.context
, false); |
269 AffineTransform nonScalingTransform; | 238 AffineTransform nonScalingTransform; |
270 | 239 |
271 if (hasNonScalingStroke()) { | 240 if (hasNonScalingStroke()) { |
272 AffineTransform nonScalingTransform = nonScalingStrokeTr
ansform(); | 241 AffineTransform nonScalingTransform = nonScalingStrokeTr
ansform(); |
273 if (!setupNonScalingStrokeContext(nonScalingTransform, s
tateSaver)) | 242 if (!setupNonScalingStrokeContext(nonScalingTransform, s
tateSaver)) |
274 return; | 243 return; |
275 } | 244 } |
276 | 245 |
277 strokeShape(this->style(), childPaintInfo.context); | 246 if (!SVGRenderSupport::updateGraphicsContext(stateSaver, sty
le(), *this, ApplyToStrokeMode)) |
| 247 break; |
| 248 strokeShape(childPaintInfo.context); |
278 } | 249 } |
279 break; | 250 break; |
280 case PT_MARKERS: | 251 case PT_MARKERS: |
281 if (!m_markerPositions.isEmpty()) | 252 if (!m_markerPositions.isEmpty()) |
282 drawMarkers(childPaintInfo); | 253 drawMarkers(childPaintInfo); |
283 break; | 254 break; |
284 default: | 255 default: |
285 ASSERT_NOT_REACHED(); | 256 ASSERT_NOT_REACHED(); |
286 break; | 257 break; |
287 } | 258 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 ASSERT(resources); | 433 ASSERT(resources); |
463 | 434 |
464 RenderSVGResourceMarker* markerStart = resources->markerStart(); | 435 RenderSVGResourceMarker* markerStart = resources->markerStart(); |
465 | 436 |
466 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); | 437 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); |
467 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); | 438 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); |
468 markerData.pathIsDone(); | 439 markerData.pathIsDone(); |
469 } | 440 } |
470 | 441 |
471 } | 442 } |
OLD | NEW |