|
5 | 5 | using System.Drawing.Drawing2D; |
6 | 6 | using BenchmarkDotNet.Attributes; |
7 | 7 | using SixLabors.ImageSharp.Drawing.Processing; |
8 | | -using SixLabors.ImageSharp.Drawing.Processing.Backends; |
9 | 8 | using SixLabors.ImageSharp.Drawing.Tests; |
10 | 9 | using SixLabors.ImageSharp.PixelFormats; |
11 | 10 | using SixLabors.ImageSharp.Processing; |
@@ -35,8 +34,6 @@ public class FillTiger |
35 | 34 | private Image<Rgba32> image; |
36 | 35 | private List<(IPath Path, Processing.SolidBrush Fill, SolidPen Stroke)> isElements; |
37 | 36 |
|
38 | | - private WebGPURenderTarget<Rgba32> webGpuTarget; |
39 | | - |
40 | 37 | [Params(1000, 100)] |
41 | 38 | public int Dimensions { get; set; } |
42 | 39 |
|
@@ -64,8 +61,6 @@ public void Setup() |
64 | 61 |
|
65 | 62 | this.image = new Image<Rgba32>(width, height); |
66 | 63 | this.isElements = SvgBenchmarkHelper.BuildImageSharpElements(elements, scale); |
67 | | - |
68 | | - this.webGpuTarget = new WebGPURenderTarget<Rgba32>(width, height); |
69 | 64 | } |
70 | 65 |
|
71 | 66 | [IterationSetup] |
@@ -98,8 +93,6 @@ public void Cleanup() |
98 | 93 | this.sdBitmap.Dispose(); |
99 | 94 |
|
100 | 95 | this.image.Dispose(); |
101 | | - |
102 | | - this.webGpuTarget.Dispose(); |
103 | 96 | } |
104 | 97 |
|
105 | 98 | [Benchmark(Baseline = true)] |
@@ -139,83 +132,19 @@ public void SystemDrawing() |
139 | 132 |
|
140 | 133 | [Benchmark] |
141 | 134 | public void ImageSharp() |
142 | | - => this.image.Mutate(c => c.ProcessWithCanvas(canvas => |
143 | | - { |
144 | | - foreach ((IPath path, Processing.SolidBrush fill, SolidPen stroke) in this.isElements) |
145 | | - { |
146 | | - if (fill is not null) |
147 | | - { |
148 | | - canvas.Fill(fill, path); |
149 | | - } |
150 | | - |
151 | | - if (stroke is not null) |
152 | | - { |
153 | | - canvas.Draw(stroke, path); |
154 | | - } |
155 | | - } |
156 | | - })); |
157 | | - |
158 | | - [Benchmark] |
159 | | - public void ImageSharp_SingleThreaded() |
160 | | - { |
161 | | - Configuration configuration = this.image.Configuration.Clone(); |
162 | | - configuration.MaxDegreeOfParallelism = 1; |
163 | | - this.image.Mutate(configuration, c => c.ProcessWithCanvas(canvas => |
| 135 | + => this.image.Mutate(c => |
164 | 136 | { |
165 | 137 | foreach ((IPath path, Processing.SolidBrush fill, SolidPen stroke) in this.isElements) |
166 | 138 | { |
167 | 139 | if (fill is not null) |
168 | 140 | { |
169 | | - canvas.Fill(fill, path); |
| 141 | + c.Fill(fill, path); |
170 | 142 | } |
171 | 143 |
|
172 | 144 | if (stroke is not null) |
173 | 145 | { |
174 | | - canvas.Draw(stroke, path); |
| 146 | + c.Draw(stroke, path); |
175 | 147 | } |
176 | 148 | } |
177 | | - })); |
178 | | - } |
179 | | - |
180 | | - [Benchmark] |
181 | | - public void ImageSharpWebGPU() |
182 | | - { |
183 | | - using DrawingCanvas<Rgba32> canvas = this.webGpuTarget.CreateCanvas(); |
184 | | - foreach ((IPath path, Processing.SolidBrush fill, SolidPen stroke) in this.isElements) |
185 | | - { |
186 | | - if (fill is not null) |
187 | | - { |
188 | | - canvas.Fill(fill, path); |
189 | | - } |
190 | | - |
191 | | - if (stroke is not null) |
192 | | - { |
193 | | - canvas.Draw(stroke, path); |
194 | | - } |
195 | | - } |
196 | | - |
197 | | - canvas.Flush(); |
198 | | - } |
199 | | - |
200 | | - public static void VerifyOutput() |
201 | | - { |
202 | | - FillTiger bench = new(); |
203 | | - bench.Setup(); |
204 | | - |
205 | | - bench.SkiaSharp(); |
206 | | - bench.SystemDrawing(); |
207 | | - bench.ImageSharp(); |
208 | | - bench.ImageSharpWebGPU(); |
209 | | - |
210 | | - //SvgBenchmarkHelper.VerifyOutput( |
211 | | - // "tiger", |
212 | | - // Width, |
213 | | - // Height, |
214 | | - // bench.skSurface, |
215 | | - // bench.sdBitmap, |
216 | | - // bench.image, |
217 | | - // bench.webGpuTarget.TextureHandle); |
218 | | - |
219 | | - bench.Cleanup(); |
220 | | - } |
| 149 | + }); |
221 | 150 | } |
0 commit comments