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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool RenderSVGShape::shapeDependentFillContains(const FloatPoint& point, const W
indRule fillRule) const | 105 bool RenderSVGShape::shapeDependentFillContains(const FloatPoint& point, const W
indRule fillRule) const |
106 { | 106 { |
107 return path().contains(point, fillRule); | 107 return path().contains(point, fillRule); |
108 } | 108 } |
109 | 109 |
110 bool RenderSVGShape::fillContains(const FloatPoint& point, bool requiresFill, co
nst WindRule fillRule) | 110 bool RenderSVGShape::fillContains(const FloatPoint& point, bool requiresFill, co
nst WindRule fillRule) |
111 { | 111 { |
112 if (!m_fillBoundingBox.contains(point)) | 112 if (!m_fillBoundingBox.contains(point)) |
113 return false; | 113 return false; |
114 | 114 |
115 bool hasFallback; | 115 if (requiresFill && !SVGPaintServer::existsForRenderer(*this, style(), Apply
ToFillMode)) |
116 if (requiresFill && !RenderSVGResource::requestPaintingResource(ApplyToFillM
ode, this, style(), hasFallback)) | |
117 return false; | 116 return false; |
118 | 117 |
119 return shapeDependentFillContains(point, fillRule); | 118 return shapeDependentFillContains(point, fillRule); |
120 } | 119 } |
121 | 120 |
122 bool RenderSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke
) | 121 bool RenderSVGShape::strokeContains(const FloatPoint& point, bool requiresStroke
) |
123 { | 122 { |
124 if (!strokeBoundingBox().contains(point)) | 123 if (!strokeBoundingBox().contains(point)) |
125 return false; | 124 return false; |
126 | 125 |
127 bool hasFallback; | 126 if (requiresStroke && !SVGPaintServer::existsForRenderer(*this, style(), App
lyToStrokeMode)) |
128 if (requiresStroke && !RenderSVGResource::requestPaintingResource(ApplyToStr
okeMode, this, style(), hasFallback)) | |
129 return false; | 127 return false; |
130 | 128 |
131 return shapeDependentStrokeContains(point); | 129 return shapeDependentStrokeContains(point); |
132 } | 130 } |
133 | 131 |
134 void RenderSVGShape::layout() | 132 void RenderSVGShape::layout() |
135 { | 133 { |
136 bool updateCachedBoundariesInParents = false; | 134 bool updateCachedBoundariesInParents = false; |
137 | 135 |
138 if (m_needsShapeUpdate || m_needsBoundariesUpdate) { | 136 if (m_needsShapeUpdate || m_needsBoundariesUpdate) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!SVGResources::supportsMarkers(*toSVGGraphicsElement(element()))) | 191 if (!SVGResources::supportsMarkers(*toSVGGraphicsElement(element()))) |
194 return false; | 192 return false; |
195 | 193 |
196 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); | 194 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(
this); |
197 if (!resources) | 195 if (!resources) |
198 return false; | 196 return false; |
199 | 197 |
200 return resources->markerStart() || resources->markerMid() || resources->mark
erEnd(); | 198 return resources->markerStart() || resources->markerMid() || resources->mark
erEnd(); |
201 } | 199 } |
202 | 200 |
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&) | 201 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&) |
238 { | 202 { |
239 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 203 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
240 if (paintInfo.phase != PaintPhaseForeground | 204 if (paintInfo.phase != PaintPhaseForeground |
241 || style()->visibility() == HIDDEN | 205 || style()->visibility() == HIDDEN |
242 || isShapeEmpty()) | 206 || isShapeEmpty()) |
243 return; | 207 return; |
244 | 208 |
245 FloatRect boundingBox = paintInvalidationRectInLocalCoordinates(); | 209 FloatRect boundingBox = paintInvalidationRectInLocalCoordinates(); |
246 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox,
m_localTransform, paintInfo)) | 210 if (!SVGRenderSupport::paintInfoIntersectsPaintInvalidationRect(boundingBox,
m_localTransform, paintInfo)) |
247 return; | 211 return; |
248 | 212 |
249 PaintInfo childPaintInfo(paintInfo); | 213 PaintInfo childPaintInfo(paintInfo); |
250 | 214 |
251 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); | 215 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); |
252 childPaintInfo.applyTransform(m_localTransform); | 216 childPaintInfo.applyTransform(m_localTransform); |
253 | 217 |
254 SVGRenderingContext renderingContext(this, childPaintInfo); | 218 SVGRenderingContext renderingContext(this, childPaintInfo); |
255 | 219 |
256 if (renderingContext.isRenderingPrepared()) { | 220 if (renderingContext.isRenderingPrepared()) { |
257 const SVGRenderStyle& svgStyle = style()->svgStyle(); | 221 const SVGRenderStyle& svgStyle = style()->svgStyle(); |
258 if (svgStyle.shapeRendering() == SR_CRISPEDGES) | 222 if (svgStyle.shapeRendering() == SR_CRISPEDGES) |
259 childPaintInfo.context->setShouldAntialias(false); | 223 childPaintInfo.context->setShouldAntialias(false); |
260 | 224 |
261 for (int i = 0; i < 3; i++) { | 225 for (int i = 0; i < 3; i++) { |
262 switch (svgStyle.paintOrderType(i)) { | 226 switch (svgStyle.paintOrderType(i)) { |
263 case PT_FILL: | 227 case PT_FILL: { |
264 fillShape(this->style(), childPaintInfo.context); | 228 GraphicsContextStateSaver stateSaver(*childPaintInfo.context, fa
lse); |
| 229 if (!SVGPaintServer::updateGraphicsContext(childPaintInfo.contex
t, style(), *this, ApplyToFillMode, stateSaver)) |
| 230 break; |
| 231 fillShape(childPaintInfo.context); |
265 break; | 232 break; |
| 233 } |
266 case PT_STROKE: | 234 case PT_STROKE: |
267 if (svgStyle.hasVisibleStroke()) { | 235 if (svgStyle.hasVisibleStroke()) { |
268 GraphicsContextStateSaver stateSaver(*childPaintInfo.context
, false); | 236 GraphicsContextStateSaver stateSaver(*childPaintInfo.context
, false); |
269 AffineTransform nonScalingTransform; | 237 AffineTransform nonScalingTransform; |
270 | 238 |
271 if (hasNonScalingStroke()) { | 239 if (hasNonScalingStroke()) { |
272 AffineTransform nonScalingTransform = nonScalingStrokeTr
ansform(); | 240 AffineTransform nonScalingTransform = nonScalingStrokeTr
ansform(); |
273 if (!setupNonScalingStrokeContext(nonScalingTransform, s
tateSaver)) | 241 if (!setupNonScalingStrokeContext(nonScalingTransform, s
tateSaver)) |
274 return; | 242 return; |
275 } | 243 } |
276 | 244 |
277 strokeShape(this->style(), childPaintInfo.context); | 245 if (!SVGPaintServer::updateGraphicsContext(childPaintInfo.co
ntext, style(), *this, ApplyToStrokeMode, stateSaver)) |
| 246 break; |
| 247 strokeShape(childPaintInfo.context); |
278 } | 248 } |
279 break; | 249 break; |
280 case PT_MARKERS: | 250 case PT_MARKERS: |
281 if (!m_markerPositions.isEmpty()) | 251 if (!m_markerPositions.isEmpty()) |
282 drawMarkers(childPaintInfo); | 252 drawMarkers(childPaintInfo); |
283 break; | 253 break; |
284 default: | 254 default: |
285 ASSERT_NOT_REACHED(); | 255 ASSERT_NOT_REACHED(); |
286 break; | 256 break; |
287 } | 257 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 ASSERT(resources); | 432 ASSERT(resources); |
463 | 433 |
464 RenderSVGResourceMarker* markerStart = resources->markerStart(); | 434 RenderSVGResourceMarker* markerStart = resources->markerStart(); |
465 | 435 |
466 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); | 436 SVGMarkerData markerData(m_markerPositions, markerStart ? markerStart->orien
tType() == SVGMarkerOrientAutoStartReverse : false); |
467 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); | 437 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); |
468 markerData.pathIsDone(); | 438 markerData.pathIsDone(); |
469 } | 439 } |
470 | 440 |
471 } | 441 } |
OLD | NEW |