Let's consider adding a faster, modern rendering engine for custom 2D and Text rendering like Skia or Direct2D/DirectWrite
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
Since this topic is one of my personal favorite topics, which I deal with as a hobby in my spare time, I have been experimenting with GDI+, DirectWrite/Direct2D and SkiaSharp a bit lately. While we've made significant improvements around GDI/GDI+ memory consumptions and efficiency, we hear more and more feedback that the WinForms community finds GDI+ too slow in its (rendering) core for modernizing older Framework Apps and moving them to .NET. And it makes sense: Customer's use more and more 4K monitors (often more than 1), and GDIPlus takes much longer time to render bigger area.
So, here are a couple of thoughts as a guideline for questions and discussions, which I think would help to form a better picture around this topic.
* Do we need to consider this at all or does GDI/GDI+ suffice after all for the custom drawing things we want to do in WinForms?
* **DirectX/Direct2D** is native to Window. Is that good or bad, is this a pro or a con argument?
* Same question for **Skia(Sharp)** which is NOT native to Windows. But since it's the render engine for Google's chrome, it's been used by Edge browser indirectly.
* Skia has an extremely easy way to render into PDF, which is an extreme plus for the typical WinForms (LOB Apps) audience. I am not aware that DirectX/Direct2D allows this equally easy.
* DirectX/Direct2D is the base for rendering WinUI. Should we see XAML-Islands for WinUi 3 in the future (and I am not at all implying that we won't, just to be clear!), there might be easier migration options for content rendering going forward.
* Skia would introduce external dependencies, which we might not want or like. Or do we? For this, the next issue might be relevant:
* Is this (no matter what technology we would go for) something which we want to have as an add-on or deeper integrated into WinForms? Would we like to - for example - have a control like the DataGridView, which is completely rendered by GDI/GDI+ and not a wrapper around some Win32 control, refactored so it would be rendered by that modern rendering engine?
* Are there any additional rendering engine options we should include in the discussion?
Here is a good document to get the essentials of Skia in the context of GDI/GDI+:
https://www.chromium.org/developers/design-documents/graphics-and-skia
Here are the (visual) results of a .NET 6 app I wrote and experimented with.
DISCLAIMER: Please note, that I did not use the existing SkiaSharp WinForms controls, since they pull in .NET Framework dependencies and the OpenGL version of the Skia WinForms control is based on a rather old (Framework) version of the OpenTK's GLControl. While reimplementing the SkiaSharp controls based on the latest version of OpenTK (5.n) works for most of the things I tried reasonably well, I had TONS of problems when rendering circles, ellipses (which are internally seem to be converted into arc-based paths, which I think is the problem) and the alike and could only make those work on one of my several test machines, and also only with a BIG memory leak.
This demo just animates a few hundred Circles in different (transparent) colors and bounces them off the boundaries:
This is GDI+:

This is Skia:
https://user-images.githubusercontent.com/9663150/147891114-bf532588-a87b-4436-a7e3-fc861272191c.mp4
This is Skia based on OpenGL:
https://user-images.githubusercontent.com/9663150/147890994-74c26c8a-4a33-496c-a125-85f8c2c9f2fc.mp4
Contributor guide
Assessment
This issue has not been assessed yet.