egui icon indicating copy to clipboard operation
egui copied to clipboard

GDI and X11 "renderer"

Open valaphee opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Currently egui has to do tessellation on its own even though Windows for example has GDI, which allows to draw simple shapes with various parameters and would remove a sizeable chunk of code from the binary. It would also allow to run faster on platforms, which don't have a 3D accelerator/GPU and only a 2D accelerator / video out, like in virtual machines or some servers.

The font rendering would also match that of the system, and would automatically do the sub pixel rendering, and font smoothing (if enabled).

The X11 protocol also has a similar shape rendering technique, which would also allow for client side rendering, when using X11 forwarding, which is way more responsive then software rendering on the server (which is most likely not available) and transmitting a full image.

Describe the solution you'd like Implementing gdi and x11 integration into eframe.

Describe alternatives you've considered The GDI software renderer for OpenGL, would also work, but I guess drawing shapes directly is faster then drawing primitives. (But I would have to compare) For X11 forwarding there is not really any alternative.

Additional context

valaphee avatar Dec 24 '23 21:12 valaphee

I'm currently trying to create a bare bone GDI renderer as a proof of concept.

valaphee avatar Dec 24 '23 21:12 valaphee

My impression is that GDI the Xproto drawing interfaces are obsolete and not recommended for new programs. They're both implemented very inefficiently, often using software rendering fallback paths that aren't optimized today. Not to mention, they only work for simple shapes.

notgull avatar Dec 24 '23 22:12 notgull

They are definitely obsolete to some extend, even though GDI font rendering is still used in CEF and Firefox for example. But newer Windows OS applications seem to use a different font renderer.

Don't know much about the Wayland or X11 protocol.

But I definitely would have to test the performance implications (especially in a virtual machine), but one major benefit would be a way smaller executable size (no font renderer and tesselator) and less memory usage (as there is no texture font anymore), and less dependencies.

valaphee avatar Dec 25 '23 14:12 valaphee

Cairo seems to be a way better choice as it abstracts over the backend and supoorts GDI, Xcb surfaces and OpenVG, Direct2D, software raster and so on.

After testing.. it performs horrible and wouldn't "solve" it anyway.

valaphee avatar Apr 28 '24 13:04 valaphee