Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: Source/core/rendering/svg/RenderSVGShape.cpp

Issue 14907011: Support 'paint-order' from SVG2. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix review issues and add paint-order for text too Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 strokePaintingResource->postApplyResource(this, context, ApplyToStro keMode, 0, this); 236 strokePaintingResource->postApplyResource(this, context, ApplyToStro keMode, 0, this);
237 else if (fallbackColor.isValid()) { 237 else if (fallbackColor.isValid()) {
238 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::s haredSolidPaintingResource(); 238 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::s haredSolidPaintingResource();
239 fallbackResource->setColor(fallbackColor); 239 fallbackResource->setColor(fallbackColor);
240 if (fallbackResource->applyResource(this, style, context, ApplyToStr okeMode)) 240 if (fallbackResource->applyResource(this, style, context, ApplyToStr okeMode))
241 fallbackResource->postApplyResource(this, context, ApplyToStroke Mode, 0, this); 241 fallbackResource->postApplyResource(this, context, ApplyToStroke Mode, 0, this);
242 } 242 }
243 } 243 }
244 } 244 }
245 245
246 void RenderSVGShape::fillAndStrokeShape(GraphicsContext* context)
247 {
248 RenderStyle* style = this->style();
249
250 fillShape(style, context);
251
252 if (!style->svgStyle()->hasVisibleStroke())
253 return;
254
255 GraphicsContextStateSaver stateSaver(*context, false);
256
257 if (hasNonScalingStroke()) {
258 AffineTransform nonScalingTransform = nonScalingStrokeTransform();
259 if (!setupNonScalingStrokeContext(nonScalingTransform, stateSaver))
260 return;
261 }
262
263 strokeShape(style, context);
264 }
265
266 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&) 246 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&)
267 { 247 {
268 if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || isEmpty()) 248 if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || isEmpty())
269 return; 249 return;
270 FloatRect boundingBox = repaintRectInLocalCoordinates(); 250 FloatRect boundingBox = repaintRectInLocalCoordinates();
271 if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTr ansform, paintInfo)) 251 if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTr ansform, paintInfo))
272 return; 252 return;
273 253
274 PaintInfo childPaintInfo(paintInfo); 254 PaintInfo childPaintInfo(paintInfo);
275 bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == Pain tPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline); 255 bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == Pain tPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
276 if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) { 256 if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
277 GraphicsContextStateSaver stateSaver(*childPaintInfo.context); 257 GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
278 childPaintInfo.applyTransform(m_localTransform); 258 childPaintInfo.applyTransform(m_localTransform);
279 259
280 if (childPaintInfo.phase == PaintPhaseForeground) { 260 if (childPaintInfo.phase == PaintPhaseForeground) {
281 SVGRenderingContext renderingContext(this, childPaintInfo); 261 SVGRenderingContext renderingContext(this, childPaintInfo);
282 262
283 if (renderingContext.isRenderingPrepared()) { 263 if (renderingContext.isRenderingPrepared()) {
284 const SVGRenderStyle* svgStyle = style()->svgStyle(); 264 const SVGRenderStyle* svgStyle = style()->svgStyle();
285 if (svgStyle->shapeRendering() == SR_CRISPEDGES) 265 if (svgStyle->shapeRendering() == SR_CRISPEDGES)
286 childPaintInfo.context->setShouldAntialias(false); 266 childPaintInfo.context->setShouldAntialias(false);
287 267
288 fillAndStrokeShape(childPaintInfo.context); 268 for (int i = 0; i < 3; i++) {
289 if (!m_markerPositions.isEmpty()) 269 switch (svgStyle->paintOrderType(i)) {
290 drawMarkers(childPaintInfo); 270 case PT_FILL:
271 fillShape(this->style(), childPaintInfo.context);
272 break;
273 case PT_STROKE:
274 if (svgStyle->hasVisibleStroke()) {
275 GraphicsContextStateSaver stateSaver(*childPaintInfo .context, false);
276 AffineTransform nonScalingTransform;
277
278 if (hasNonScalingStroke()) {
279 AffineTransform nonScalingTransform = nonScaling StrokeTransform();
280 if (!setupNonScalingStrokeContext(nonScalingTran sform, stateSaver))
281 return;
282 }
283
284 strokeShape(this->style(), childPaintInfo.context);
285 }
286 break;
287 case PT_MARKERS:
288 if (!m_markerPositions.isEmpty())
289 drawMarkers(childPaintInfo);
290 break;
291 default:
292 ASSERT_NOT_REACHED();
293 break;
294 }
295 }
291 } 296 }
292 } 297 }
293 298
294 if (drawsOutline) 299 if (drawsOutline)
295 paintOutline(childPaintInfo, IntRect(boundingBox)); 300 paintOutline(childPaintInfo, IntRect(boundingBox));
296 } 301 }
297 } 302 }
298 303
299 // This method is called from inside paintOutline() since we call paintOutline() 304 // This method is called from inside paintOutline() since we call paintOutline()
300 // while transformed to our coord system, return local coords 305 // while transformed to our coord system, return local coords
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return; 459 return;
455 460
456 ASSERT(m_path); 461 ASSERT(m_path);
457 462
458 SVGMarkerData markerData(m_markerPositions); 463 SVGMarkerData markerData(m_markerPositions);
459 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement); 464 m_path->apply(&markerData, SVGMarkerData::updateFromPathElement);
460 markerData.pathIsDone(); 465 markerData.pathIsDone();
461 } 466 }
462 467
463 } 468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698