private void RenderGeometory(CanvasDrawingSession session, CanvasGeometry geometry, SvgMatrix transform, CssStyleDeclaration style) { bool change = false; var geometry2 = geometry; CanvasSolidColorBrush opacityBrush = null; try { using (var t = TransformSession.CreateTransformSession(session, transform)) { var clipPath = style.ClipPath; if (clipPath != null) { if (clipPath.Uri[0] != '#') { throw new ArgumentException(); } var clipPathElement = (SvgClipPathElement)this.TargetDocument.GetElementById(clipPath.Uri.Substring(1)); var clipGeometory = this.CreateClipPath(session, clipPathElement); geometry2 = geometry.CombineWith( clipGeometory, new Matrix3x2 { M11 = 1.0F, M12 = 0.0F, M21 = 0.0F, M22 = 1.0F, M31 = 0.0F, M32 = 0.0F }, CanvasGeometryCombine.Intersect, CanvasGeometry.ComputeFlatteningTolerance(session.Dpi, 1.0F, session.Transform)); change = true; } var area = geometry2.ComputeBounds(); var opacity = style.Opacity; if (opacity != null) { opacityBrush = this.CreateOpacity(session, opacity.Value); } var fill = style.Fill; if (fill == null || fill != null && fill.PaintType != SvgPaintType.None) { var pen = this.CreatePaint(session, area, fill, style.FillOpacity); if (opacityBrush == null) { session.FillGeometry(geometry2, pen); } else { session.FillGeometry(geometry2, pen, opacityBrush); } } var stroke = style.Stroke; if (stroke != null && stroke.PaintType != SvgPaintType.None) { var pen = this.CreatePaint(session, area, stroke, style.StrokeOpacity); var strokeWidth = style.StrokeWidth; session.DrawGeometry(geometry2, pen, strokeWidth.HasValue ? this.LengthConverter.Convert(strokeWidth.Value) : 1.0F); } } } finally { if (change) { geometry2.Dispose(); } if (opacityBrush != null) { opacityBrush.Dispose(); } } }