Skip to content

Commit a96c74c

Browse files
Remove FillPath API from drawing backends
1 parent cde991c commit a96c74c

8 files changed

Lines changed: 12 additions & 112 deletions

File tree

src/ImageSharp.Drawing.WebGPU/WebGPUDrawingBackend.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,6 @@ internal bool TryGetInteropHandles(out nint deviceHandle, out nint queueHandle)
142142
return false;
143143
}
144144

145-
/// <inheritdoc />
146-
public void FillPath<TPixel>(
147-
ICanvasFrame<TPixel> target,
148-
IPath path,
149-
Brush brush,
150-
GraphicsOptions graphicsOptions,
151-
in RasterizerOptions rasterizerOptions,
152-
DrawingCanvasBatcher<TPixel> batcher)
153-
where TPixel : unmanaged, IPixel<TPixel>
154-
{
155-
this.ThrowIfDisposed();
156-
batcher.AddComposition(
157-
CompositionCommand.Create(
158-
path,
159-
brush,
160-
graphicsOptions,
161-
rasterizerOptions,
162-
target.Bounds.Location));
163-
}
164-
165145
/// <inheritdoc />
166146
public void FlushCompositions<TPixel>(
167147
Configuration configuration,

src/ImageSharp.Drawing/Processing/Backends/DefaultDrawingBackend.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ internal sealed class DefaultDrawingBackend : IDrawingBackend
3838
/// </summary>
3939
public static DefaultDrawingBackend Instance { get; } = new();
4040

41-
/// <inheritdoc />
42-
public void FillPath<TPixel>(
43-
ICanvasFrame<TPixel> target,
44-
IPath path,
45-
Brush brush,
46-
GraphicsOptions graphicsOptions,
47-
in RasterizerOptions rasterizerOptions,
48-
DrawingCanvasBatcher<TPixel> batcher)
49-
where TPixel : unmanaged, IPixel<TPixel>
50-
=> batcher.AddComposition(
51-
CompositionCommand.Create(path, brush, graphicsOptions, rasterizerOptions, target.Bounds.Location));
52-
5341
/// <inheritdoc />
5442
public void FlushCompositions<TPixel>(
5543
Configuration configuration,

src/ImageSharp.Drawing/Processing/Backends/IDrawingBackend.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,6 @@ namespace SixLabors.ImageSharp.Drawing.Processing.Backends;
1414
/// </remarks>
1515
internal interface IDrawingBackend
1616
{
17-
/// <summary>
18-
/// Fills a path into a destination target region.
19-
/// </summary>
20-
/// <typeparam name="TPixel">The pixel format.</typeparam>
21-
/// <param name="target">Destination frame.</param>
22-
/// <param name="path">Path in target-local coordinates.</param>
23-
/// <param name="brush">Brush used to shade covered pixels.</param>
24-
/// <param name="graphicsOptions">Graphics blending/composition options.</param>
25-
/// <param name="rasterizerOptions">Rasterizer options in target-local coordinates.</param>
26-
/// <param name="batcher">Batcher used to queue normalized composition commands.</param>
27-
public void FillPath<TPixel>(
28-
ICanvasFrame<TPixel> target,
29-
IPath path,
30-
Brush brush,
31-
GraphicsOptions graphicsOptions,
32-
in RasterizerOptions rasterizerOptions,
33-
DrawingCanvasBatcher<TPixel> batcher)
34-
where TPixel : unmanaged, IPixel<TPixel>;
35-
3617
/// <summary>
3718
/// Flushes queued composition operations for the target.
3819
/// </summary>

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public void Fill(IPath path, Brush brush)
351351

352352
transformedPath = ApplyClipPaths(transformedPath, effectiveOptions.ShapeOptions, state.ClipPaths);
353353

354-
this.FillPathCore(transformedPath, brush, effectiveOptions, RasterizerSamplingOrigin.PixelBoundary);
354+
this.PrepareCompositionCore(transformedPath, brush, effectiveOptions, RasterizerSamplingOrigin.PixelBoundary);
355355
}
356356

357357
/// <inheritdoc />
@@ -407,7 +407,7 @@ public void Process(IPath path, Action<IImageProcessingContext> operation)
407407
ImageBrush brush = new(sourceImage, sourceImage.Bounds, brushOffset);
408408

409409
this.pendingImageResources.Add(sourceImage);
410-
this.FillPathCore(transformedPath, brush, effectiveOptions, RasterizerSamplingOrigin.PixelBoundary);
410+
this.PrepareCompositionCore(transformedPath, brush, effectiveOptions, RasterizerSamplingOrigin.PixelBoundary);
411411
}
412412

413413
/// <inheritdoc />
@@ -480,7 +480,7 @@ public void Draw(Pen pen, IPath path)
480480

481481
outline = ApplyClipPaths(outline, effectiveOptions.ShapeOptions, state.ClipPaths);
482482

483-
this.FillPathCore(outline, pen.StrokeFill, effectiveOptions, RasterizerSamplingOrigin.PixelCenter);
483+
this.PrepareCompositionCore(outline, pen.StrokeFill, effectiveOptions, RasterizerSamplingOrigin.PixelCenter);
484484
}
485485

486486
/// <inheritdoc />
@@ -813,13 +813,13 @@ private void DrawImageCore(
813813
}
814814

815815
/// <summary>
816-
/// Rasterizes and submits a fill operation to the backend.
816+
/// Prepares a path fill composition command and enqueues it in the batcher.
817817
/// </summary>
818818
/// <param name="path">Path to fill.</param>
819819
/// <param name="brush">Brush used for shading.</param>
820820
/// <param name="options">Effective drawing options.</param>
821821
/// <param name="samplingOrigin">Rasterizer sampling origin.</param>
822-
private void FillPathCore(
822+
private void PrepareCompositionCore(
823823
IPath path,
824824
Brush brush,
825825
DrawingOptions options,
@@ -849,13 +849,13 @@ private void FillPathCore(
849849
samplingOrigin,
850850
graphicsOptions.AntialiasThreshold);
851851

852-
this.backend.FillPath(
853-
this.targetFrame,
854-
path,
855-
brush,
856-
graphicsOptions,
857-
rasterizerOptions,
858-
this.batcher);
852+
this.batcher.AddComposition(
853+
CompositionCommand.Create(
854+
path,
855+
brush,
856+
graphicsOptions,
857+
rasterizerOptions,
858+
this.targetFrame.Bounds.Location));
859859
}
860860

861861
/// <summary>

tests/ImageSharp.Drawing.Tests/Processing/Backends/SkiaCoverageDrawingBackend.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,6 @@ internal sealed class SkiaCoverageDrawingBackend : IDrawingBackend, IDisposable
2626

2727
public int LiveCoverageCount => this.preparedCoverage.Count;
2828

29-
public void FillPath<TPixel>(
30-
ICanvasFrame<TPixel> target,
31-
IPath path,
32-
Brush brush,
33-
GraphicsOptions graphicsOptions,
34-
in RasterizerOptions rasterizerOptions,
35-
DrawingCanvasBatcher<TPixel> batcher)
36-
where TPixel : unmanaged, IPixel<TPixel>
37-
=> batcher.AddComposition(
38-
CompositionCommand.Create(
39-
path,
40-
brush,
41-
graphicsOptions,
42-
rasterizerOptions,
43-
target.Bounds.Location));
44-
4529
public void FlushCompositions<TPixel>(
4630
Configuration configuration,
4731
ICanvasFrame<TPixel> target,

tests/ImageSharp.Drawing.Tests/Processing/DrawingCanvasBatcherTests.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@ private sealed class CapturingBackend : IDrawingBackend
5555
0.5f)),
5656
Array.Empty<PreparedCompositionCommand>());
5757

58-
public void FillPath<TPixel>(
59-
ICanvasFrame<TPixel> target,
60-
IPath path,
61-
Brush brush,
62-
GraphicsOptions graphicsOptions,
63-
in RasterizerOptions rasterizerOptions,
64-
DrawingCanvasBatcher<TPixel> batcher)
65-
where TPixel : unmanaged, IPixel<TPixel>
66-
=> batcher.AddComposition(
67-
CompositionCommand.Create(path, brush, graphicsOptions, rasterizerOptions, target.Bounds.Location));
68-
6958
public void FlushCompositions<TPixel>(
7059
Configuration configuration,
7160
ICanvasFrame<TPixel> target,

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,6 @@ public MirroringCpuReadbackTestBackend(ICanvasFrame<TPixel> proxyFrame, Image<TP
151151

152152
public Configuration? LastReadbackConfiguration { get; private set; }
153153

154-
public void FillPath<TTargetPixel>(
155-
ICanvasFrame<TTargetPixel> target,
156-
IPath path,
157-
Brush brush,
158-
GraphicsOptions graphicsOptions,
159-
in RasterizerOptions rasterizerOptions,
160-
DrawingCanvasBatcher<TTargetPixel> batcher)
161-
where TTargetPixel : unmanaged, IPixel<TTargetPixel>
162-
=> batcher.AddComposition(
163-
CompositionCommand.Create(path, brush, graphicsOptions, rasterizerOptions, target.Bounds.Location));
164-
165154
public void FlushCompositions<TTargetPixel>(
166155
Configuration configuration,
167156
ICanvasFrame<TTargetPixel> target,

tests/ImageSharp.Drawing.Tests/Processing/RasterizerDefaultsExtensionsTests.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ public void SetDrawingBackendOnProcessingContext_RoundTrips()
4747

4848
private sealed class RecordingDrawingBackend : IDrawingBackend
4949
{
50-
public void FillPath<TPixel>(
51-
ICanvasFrame<TPixel> target,
52-
IPath path,
53-
Brush brush,
54-
GraphicsOptions graphicsOptions,
55-
in RasterizerOptions rasterizerOptions,
56-
DrawingCanvasBatcher<TPixel> batcher)
57-
where TPixel : unmanaged, IPixel<TPixel>
58-
{
59-
}
60-
6150
public void FlushCompositions<TPixel>(
6251
Configuration configuration,
6352
ICanvasFrame<TPixel> target,

0 commit comments

Comments
 (0)