Hi,
I've tried to test Xamarin's C# wrapper for Skia called SkiaSharp. I guess that an issue that I've found in my tests might relate to Skia.
On Windows, SkiaSharp performs very slow in comparison to GDI+ when it comes to draw thick lines (stroke width greater than 1 pixel). To help you reproduce this issue, I've created a GitHub repository with a rather simple benchmark which compares the performance of SkiSharp and GDI+.
On my machine I got the following results:
Host Process Environment Information: BenchmarkDotNet=v0.9.8.0 OS=Microsoft Windows NT 6.2.9200.0 Processor=Intel(R) Core(TM) i3 CPU M 380 2.53GHz, ProcessorCount=4 Frequency=2467784 ticks, Resolution=405.2219 ns, Timer=TSC CLR=MS.NET 4.0.30319.42000, Arch=64-bit RELEASE [RyuJIT] GC=Concurrent Workstation JitModules=clrjit-v4.6.1532.0 Type=Benchmarks Mode=Throughput GarbageCollection=Concurrent Workstation
| Method | AntiAlias | Median | StdDev |
|---|
| Method | AntiAlias | Median | StdDev |
|---|---|---|---|
| Skia_Clear | False | 626.0689 us | 33.5835 us |
| GDI_Clear | False | 1,883.3675 us | 92.5697 us |
| Skia_DrawLines_SolidThick | False | 34.3181 us | 2.3956 us |
| GDI_DrawLines_SolidThick | False | 69.2968 us | 3.5125 us |
| Skia_DrawLines_SolidThin | False | 33.6100 us | 2.0326 us |
| GDI_DrawLines_SolidThin | False | 31.2110 us | 0.7240 us |
| Skia_DrawLines_DashedThick | False | 216.3211 us | 7.8385 us |
| GDI_DrawLines_DashedThick | False | 198.5229 us | 5.8046 us |
| Skia_DrawLines_DashedThin | False | 216.9377 us | 9.8053 us |
| GDI_DrawLines_DashedThin | False | 85.8987 us | 1.6362 us |
Skia_Clear | True | 689.3211 us | 18.8872 us |
| GDI_Clear | True | 1,882.9171 us | 54.4645 us |
| Skia_DrawLines_SolidThick | True | 925.7412 us | 27.4917 us |
| GDI_DrawLines_SolidThick | True | 331.8494 us | 16.4880 us |
| Skia_DrawLines_SolidThin | True | 39.8524 us | 1.3069 us |
| GDI_DrawLines_SolidThin | True | 297.3545 us | 3.2218 us |
| Skia_DrawLines_DashedThick | True | 646.9674 us | 2.7239 us |
| GDI_DrawLines_DashedThick | True | 341.4178 us | 1.2708 us |
| Skia_DrawLines_DashedThin | True | 128.6211 us | 1.1245 us |
| GDI_DrawLines_DashedThin | True | 503.6172 us | 1.7782 us |
As it can be seen from the table (see the case when AntiAlias =
True), Skia_DrawLines_SolidThick (stroke width equals 2 px) method is
2.78 times slower than its GDI+ counterpart GDI_DrawLines_SolidThick.
Next, the performance of thick dashed strokes is a bit better, namely,
Skia_DrawLines_DashedThick is 1.89 times slower than
GDI_DrawLines_DashedThick.
At the same time, SkiaSharp is able to draw thin solid lines 7.46 times
faster than GDI+. The difference in drawing thin dashed lines is 3.9
times respectively.
Do you have any explanation for such performance degradation of Skia when drawing thick lines?
Thank you in advance.
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.
The DrawLine method looks as follows [Benchmark] |
| public void Skia_DrawLines_SolidThick() |
| { |
| foreach (LineSegment ls in lineSegments) |
| skCanvas.DrawLine(ls.X0, ls.Y0, ls.X1, ls.Y1, skPaintSolidThick); |