bool SVGLayoutSupport::updateGraphicsContext(const PaintInfo& paintInfo, GraphicsContextStateSaver& stateSaver, const ComputedStyle& style, LayoutObject& layoutObject, LayoutSVGResourceMode resourceMode, const AffineTransform* additionalPaintServerTransform) { ASSERT(paintInfo.context == stateSaver.context()); GraphicsContext& context = *paintInfo.context; if (paintInfo.isRenderingClipPathAsMaskImage()) { if (resourceMode == ApplyToStrokeMode) return false; context.setFillColor(SVGComputedStyle::initialFillPaintColor()); return true; } SVGPaintServer paintServer = SVGPaintServer::requestForLayoutObject(layoutObject, style, resourceMode); if (!paintServer.isValid()) return false; if (additionalPaintServerTransform && paintServer.isTransformDependent()) paintServer.prependTransform(*additionalPaintServerTransform); const SVGComputedStyle& svgStyle = style.svgStyle(); float paintAlpha = resourceMode == ApplyToFillMode ? svgStyle.fillOpacity() : svgStyle.strokeOpacity(); paintServer.apply(context, resourceMode, paintAlpha, stateSaver); if (resourceMode == ApplyToFillMode) context.setFillRule(svgStyle.fillRule()); else applyStrokeStyleToContext(context, style, layoutObject); return true; }
bool SVGRenderSupport::updateGraphicsContext(const PaintInfo& paintInfo, GraphicsContextStateSaver& stateSaver, RenderStyle* style, RenderObject& renderer, RenderSVGResourceMode resourceMode, const AffineTransform* additionalPaintServerTransform) { ASSERT(style); ASSERT(paintInfo.context == stateSaver.context()); GraphicsContext* context = paintInfo.context; if (paintInfo.isRenderingClipPathAsMaskImage()) { if (resourceMode == ApplyToStrokeMode) return false; context->setAlphaAsFloat(1); context->setFillColor(SVGRenderStyle::initialFillPaintColor()); return true; } SVGPaintServer paintServer = SVGPaintServer::requestForRenderer(renderer, style, resourceMode); if (!paintServer.isValid()) return false; if (additionalPaintServerTransform && paintServer.isTransformDependent()) paintServer.prependTransform(*additionalPaintServerTransform); paintServer.apply(*context, resourceMode, &stateSaver); const SVGRenderStyle& svgStyle = style->svgStyle(); if (resourceMode == ApplyToFillMode) { context->setAlphaAsFloat(svgStyle.fillOpacity()); context->setFillRule(svgStyle.fillRule()); } else { context->setAlphaAsFloat(svgStyle.strokeOpacity()); applyStrokeStyleToContext(context, style, &renderer); } return true; }
static bool setupNonScalingStrokeContext(AffineTransform& strokeTransform, GraphicsContextStateSaver& stateSaver) { if (!strokeTransform.isInvertible()) return false; stateSaver.save(); stateSaver.context().concatCTM(strokeTransform.inverse()); return true; }
bool RenderSVGShape::setupNonScalingStrokeContext(AffineTransform& strokeTransform, GraphicsContextStateSaver& stateSaver) { Optional<AffineTransform> inverse = strokeTransform.inverse(); if (!inverse) return false; stateSaver.save(); stateSaver.context()->concatCTM(inverse.value()); return true; }