Skip to content

Commit b04a0ec

Browse files
Remove NormalizeOutput
1 parent aee48a5 commit b04a0ec

5 files changed

Lines changed: 10 additions & 43 deletions

File tree

src/ImageSharp.Drawing/PolygonGeometry/StrokedShapeGenerator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ private static PolygonClipper.StrokeOptions CreateStrokeOptions(StrokeOptions op
146146
ArcDetailScale = options.ArcDetailScale,
147147
MiterLimit = options.MiterLimit,
148148
InnerMiterLimit = options.InnerMiterLimit,
149-
NormalizeOutput = options.NormalizeOutput,
150149
LineJoin = options.LineJoin switch
151150
{
152151
LineJoin.MiterRound => PolygonClipper.LineJoin.MiterRound,

src/ImageSharp.Drawing/Processing/DrawingCanvas{TPixel}.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,8 @@ public void Draw(Pen pen, IPath path)
469469

470470
IPath outline = pen.GeneratePath(transformedPath);
471471

472-
// Non-normalized stroke output can self-overlap; non-zero winding preserves stroke semantics.
473-
if (!pen.StrokeOptions.NormalizeOutput &&
474-
effectiveOptions.ShapeOptions.IntersectionRule != IntersectionRule.NonZero)
472+
// Stroke geometry can self-overlap; non-zero winding preserves stroke semantics.
473+
if (effectiveOptions.ShapeOptions.IntersectionRule != IntersectionRule.NonZero)
475474
{
476475
ShapeOptions shapeOptions = effectiveOptions.ShapeOptions.DeepClone();
477476
shapeOptions.IntersectionRule = IntersectionRule.NonZero;
@@ -1038,9 +1037,8 @@ private CompositionCommand CreateCompositionCommand(
10381037
compositionPath = pen.GeneratePath(operation.Path);
10391038
samplingOrigin = RasterizerSamplingOrigin.PixelCenter;
10401039

1041-
// Keep draw semantics aligned with DrawPath: non-normalized stroke output
1042-
// requires non-zero winding to preserve stroke interior behavior.
1043-
if (!pen.StrokeOptions.NormalizeOutput && intersectionRule != IntersectionRule.NonZero)
1040+
// Stroke geometry can self-overlap; non-zero winding preserves stroke semantics.
1041+
if (intersectionRule != IntersectionRule.NonZero)
10441042
{
10451043
intersectionRule = IntersectionRule.NonZero;
10461044
}

src/ImageSharp.Drawing/Processing/StrokeOptions.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ namespace SixLabors.ImageSharp.Drawing.Processing;
88
/// </summary>
99
public sealed class StrokeOptions : IEquatable<StrokeOptions?>
1010
{
11-
/// <summary>
12-
/// Gets or sets a value indicating whether stroked contours should be normalized by
13-
/// resolving self-intersections and overlaps before returning.
14-
/// </summary>
15-
/// <remarks>
16-
/// Defaults to <see langword="false"/> for maximum throughput.
17-
/// When disabled, callers should rasterize with a non-zero winding fill rule.
18-
/// </remarks>
19-
public bool NormalizeOutput { get; set; }
20-
2111
/// <summary>
2212
/// Gets or sets the miter limit used to clamp outer miter joins.
2313
/// </summary>
@@ -56,7 +46,6 @@ public sealed class StrokeOptions : IEquatable<StrokeOptions?>
5646
/// <inheritdoc/>
5747
public bool Equals(StrokeOptions? other)
5848
=> other is not null &&
59-
this.NormalizeOutput == other.NormalizeOutput &&
6049
this.MiterLimit == other.MiterLimit &&
6150
this.InnerMiterLimit == other.InnerMiterLimit &&
6251
this.ArcDetailScale == other.ArcDetailScale &&
@@ -67,7 +56,6 @@ public bool Equals(StrokeOptions? other)
6756
/// <inheritdoc/>
6857
public override int GetHashCode()
6958
=> HashCode.Combine(
70-
this.NormalizeOutput,
7159
this.MiterLimit,
7260
this.InnerMiterLimit,
7361
this.ArcDetailScale,

tests/ImageSharp.Drawing.Benchmarks/Drawing/DrawPolygon.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,7 @@ public void ImageSharpCombinedPathsWebGPUNativeSurface()
208208
}
209209

210210
[Benchmark]
211-
public IPath ImageSharpStrokeAndClipCombined() => this.isPen.GeneratePath(this.imageSharpPath);
212-
213-
[Benchmark]
214-
public IPath ImageSharpStrokeAndClipSeparate()
215-
{
216-
IPath path = Path.Empty;
217-
foreach (PointF[] loop in this.points)
218-
{
219-
path = this.isPen.GeneratePath(new Polygon(loop));
220-
}
221-
222-
return path;
223-
}
211+
public IPath ImageSharpStroke() => this.isPen.GeneratePath(this.imageSharpPath);
224212

225213
[Benchmark]
226214
public void FillPolygon()

tests/ImageSharp.Drawing.Tests/Processing/DrawingCanvasTests.StrokeOptions.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@ public void Draw_NormalizeOutputFalse_MatchesReference<TPixel>(TestImageProvider
2020
IPath leftPath = CreateBowTiePath(new RectangleF(28, 34, 128, 152));
2121
IPath rightPath = CreateBowTiePath(new RectangleF(204, 34, 128, 152));
2222

23-
SolidPen nonNormalizedPen = new(Color.CornflowerBlue.WithAlpha(0.88F), 24F);
24-
nonNormalizedPen.StrokeOptions.NormalizeOutput = false;
25-
nonNormalizedPen.StrokeOptions.LineJoin = LineJoin.Round;
26-
nonNormalizedPen.StrokeOptions.LineCap = LineCap.Round;
27-
28-
SolidPen normalizedPen = new(Color.CornflowerBlue.WithAlpha(0.88F), 24F);
29-
normalizedPen.StrokeOptions.NormalizeOutput = true;
30-
normalizedPen.StrokeOptions.LineJoin = LineJoin.Round;
31-
normalizedPen.StrokeOptions.LineCap = LineCap.Round;
23+
SolidPen pen = new(Color.CornflowerBlue.WithAlpha(0.88F), 24F);
24+
pen.StrokeOptions.LineJoin = LineJoin.Round;
25+
pen.StrokeOptions.LineCap = LineCap.Round;
3226

3327
DrawingOptions evenOddOptions = new()
3428
{
@@ -39,8 +33,8 @@ public void Draw_NormalizeOutputFalse_MatchesReference<TPixel>(TestImageProvider
3933
canvas.Fill(new Rectangle(12, 12, 336, 196), Brushes.Solid(Color.GhostWhite.WithAlpha(0.85F)));
4034

4135
_ = canvas.Save(evenOddOptions);
42-
canvas.Draw(nonNormalizedPen, leftPath);
43-
canvas.Draw(normalizedPen, rightPath);
36+
canvas.Draw(pen, leftPath);
37+
canvas.Draw(pen, rightPath);
4438
canvas.Restore();
4539

4640
canvas.Draw(Pens.Solid(Color.DarkSlateGray, 2F), leftPath);

0 commit comments

Comments
 (0)