Hi
(My previous email was not a joke, I don't try to troll anyone. Let tolls do their job in other places)
Let's forget Moz2D for a moment :) Imagine that it does not exist. It was done just for fun and is even not in pharo repo. (
https://github.com/syrel/Moz2D). We needed something that works and it was made investing just a few months of time of a single anonymous student during summer exams session and vacations.
I would like to start maybe one of the most important discussion that will influence Pharo and will dictate how system will look like in a few years. I invite everyone to join this discussion, especially board and consortium members. Because here is where business starts.
There are some real questions:
- Do we need Bloc or Morphic2 or %name your favourite framework%?
- How advanced and modern do you want it to be?
- What technology stack do we want to use for our new graphical framework?
- What platforms and operating systems do we want to support?
- How flexible technology stack should be? (some parts may change in the future)
- Who will pay for it?
- How many engineers can community afford?
- Do you know how much other systems invest in graphical frameworks?
- It is not a science project, isn't it?
Let me first put my two cents in.
Low-level UI framework (without widgets) consists of multiple parts:
- Vector graphics library to render shapes (fill, stroke, path builder, composition and blending operators)
- Font service library (to support different font formats and collect information about local fonts installed in the system)
- Text layout engine (this is where glyph positioning magic happens, link above too)
- Text shaping engine (for high quality text rendering, to understand the problem => http://behdad.org/text/)
- Complex script library (to support ligatures, split glyphs and other UTF8 stuff, remember https://github.com/minimaxir/big-list-of-naughty-strings)
- Image processing library (for various image effects, like gaussian blur, morphology filter, gamma, displacement map, just to name a few)
- Hardware acceleration. Software rendering is nice, however, modern UIs are full of fancy stuff that require hardware acceleration.
- Window and Event management library. With support of borderless and semi-transparent windows + good support of touchpad.
- Custom written "Glue" library that allows all components to work together. Since modern libs are implemented in C++ we would need to implement C wrapper and a lot of integration tests.
- Make the whole beast cross platform.
Did I miss something?
Here are some modern technologies commonly used for mentioned parts:
- Skia, Direct2D, CoreGraphics, Cairo
- Fontconfig, Freetype2
- HarfBuzz
- Pango, OpenType
- Graphite2, FriBidi
- Imagemagic, SVG filters libraries
- Vulkan, OpenGL
- wxWidgets, QT, GTK, SDL2
- todo
- todo
Luckily Pango covers bullets 2 - 5. It indeed sounds like a great idea!
Let's assume that we stop on Cairo + Pango. According to
pango.com
The integration of Pango with Cairo (http://cairographics.org/) provides a complete solution with high quality text handling and graphics rendering.
According to the this potential technology stack we will have:
- Cairo for vector graphics and rendering of basic shapes
- Pango for text rendering
- SDL2 for window and events management
What we will not get:
- Support of filters; Cairo does not support gaussian blur. 3D transformations, we will not be able to not implement card flip animation. Never reach the same performance if using platform native frameworks (e.g. Direct2D on windows). Cairo will not die, but there is zero progress.
- Vulkan support. Never with cairo. Pure OpenGL too (try to compile cairo-gl on mac, good luck!) There is a way to compile it with quartz support. As of version 2.7.9, XQuartz does not provide support for high-resolution Retina displays to X11 apps, which run in pixel-doubled mode on high-resolution displays. (https://bugs.freedesktop.org/show_bug.cgi?id=92777).
- Borderless or transparent window with SDL2. Also, did you notice that sdl2 window turns black/white while resizing? There is no way to get a continuous window resize event with SDL2 (https://bugzilla.libsdl.org/show_bug.cgi?id=2077). The issue is that events stop firing while user is resizing a window because main thread is blocked. Bug is already 3 years old. Indeed SDL2 is used for games, however how often do gamers resize game window?
- Stateless API. Must have for a graphical framework like Bloc where canvas state is not shared between visual elements. It means that while rendering users must not clean the state of a canvas after every draw call.
Bloc is not my or Glenn's or Doru's personal property. We suggest, you decide. It would be great if community could invest money and time in a working and appropriate solution.
P.S. If we would not care, we would agree with you instantly and even not bothered ourselves trying to spend time on finding cheap solution for such a complex problem.