Add research

master
Melroy van den Berg 2020-11-23 01:50:50 +01:00
parent 2f2384b8cb
commit 3f47b08c2b
4 changed files with 106 additions and 33 deletions

View File

@ -54,13 +54,15 @@ The current plan:
## Devs
Decentralized Browser written in C and C++20. And using the [cmark-gfm](https://github.com/github/cmark-gfm) library, used for CommonMark (markdown) parsing.
Decentralized Browser written in C++20 with C libraries. And using the [cmark-gfm](https://github.com/github/cmark-gfm) library, used for CommonMark (markdown) parsing.
The GUI-toolkit or 2D/3D engine used displaying the content is not yet decided. Can be anything really, like: Qt, wxWidgets or Imgui.
The GUI toolkit and 2D/vector graphics engine is not yet decided (see research below).
We can also still change the language of the source code (iso markdown). Atleast no HTML and JavaScript anymore, content is king after all.
For the development environment I'm using VSCodium with `C/C++`, `Cmake` and `Cmake Tools` extensions installed.
### Development Environment
I'm using VSCodium editor, with the following extensions installed: `C/C++`, `Cmake` and `Cmake Tools` .
## Depedencies
@ -68,40 +70,14 @@ For the build you need at least:
* GCC 9 or higher (GCC 8 should also work)
* CMake
* Qt (`qt5-default` package)
* Qt (`qt5-default` package) -> for now
For Release packaging:
* CPack
### GUIs
### 2D/Vector engines - Under Research
#### Qt
We are currently in an exploration phase, which 2D vector graphics rendering library we should us.
Qt [Rich Text Processing](https://doc.qt.io/qt-5/richtext.html)/QTextDocument can't be used, since that only supports HTML for rich text. Or the use of built-in markdown parser, in both cases doesn't give us the right flexibility we need.
Meaning we can try to use low-level [QPainter](https://doc.qt.io/qt-5/qpainter.html) calls on a viewport/paint device (like QPixmap, QWidget, QPicture and QOpenGLPaintDevice), see [Qt GUI](https://doc.qt.io/qt-5/qtgui-index.html) module. We can also use Qt Quick Scene Graph for OpenGL rendering. Or use 2D renderer using either raster paint engine (without OpenGL calls).
But first let's try using [QGraphicsTextItem](https://doc.qt.io/qt-5/qgraphicstextitem.html) on a [QGraphicsScene](https://doc.qt.io/qt-5/qgraphicsscene.html).
Examples:
* [Drawing text](https://github.com/radekp/qt/blob/master/src/gui/text/qtextlayout.cpp#L1114) with QPainter.
* [Mifit Text render](https://github.com/mifit/mifit/blob/master/libs/opengl/Text.cpp) for a code example.
* [Drawing Text/line using QPainter](https://www.youtube.com/watch?v=tc3nlNEAdig) (video).
By `baysmith`:
It generates image atlas dynamically using a QPainter to draw to a texture which is displayed with quads. I don't know how much less efficient it is to draw the characters to the image on demand rather than prebaking, but I need the flexibility to change the font to anything the system provides.
* [Calligra](https://github.com/KDE/calligra) Word processor using Qt, maybe also creating their own text painting as well?
#### Dear Imgui
[Imgui](https://github.com/ocornut/imgui) is used for Games but also applications. For example the Unity Editor is using Imgui!
For some inspiration; there exists [Text Editor #1](https://github.com/BalazsJako/ImGuiColorTextEdit), [Text Editor #2](https://github.com/Rezonality/zep) created with Imgui.
But there are many more demos and projects out there using Imgui!
See also [Fonts documentation](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) of Imgui.
See [research document](docs/research.md) for more information and conclusions based on facts.

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

96
docs/research.md Normal file
View File

@ -0,0 +1,96 @@
# Research topics
## Graphical frameworks & renderers
*Goal:* We want to draw text on the screen as fast as possible. Skipping the HTML parser step, meaning: `Markdown` -> `screen` instead of: `Markdown` -> `HTML` / `CSS` -> `screen`.
## Skia
Skia is a 2D graphics library. Using for drwaing text, geometries, and images. Support backends CPU raster, OpenGL/Vulkan. Both for display and SVG/PDF (can also read those files).
Instead of using Qt / QtSkia, we can directly use Skia. Skia is also used for Google Chrome/Chrome OS, Firefox, Android, LibreOffice and more.
Skia supports several (platform-dependent) back-ends, including one for CPU-based software rasterization, one for Portable Document Format (PDF) output, and one for GPU-accelerated OpenGL, OpenGL ES, Vulkan, and Metal one.
**Conclusion:** *No Conclusion yet* - Under investigation
## GTK+ / Cairo
GTK+ is using the Cairo 2D graphics renderer using rasterization (CPU). But Cairo also including backends for acceleration and for vector output formats. Can be used for both display and export to PDF/SVG.
**Conclusion:** *No Conclusion yet* - Under investigation
## NanoVG
[NanoVG](https://github.com/memononen/nanovg) is a 2D vector drawing library on top of OpenGL for UI and visualization. Its very small, with a lean API.
**Conclusion:** *No Conclusion yet* - Under investigation
### Qt
Qt has many Qt-classes, features and APIs for drawing and rendering. See the following sub-items:
#### Rich Text
Qt [Rich Text Processing](https://doc.qt.io/qt-5/richtext.html)/QTextDocument only accepts HTML format (or directly markdown). But in this project, we are not intressed in HTML and we want to use our own markdown parser in order to extend the markdown language where and when is needed.
**Conclusion:** Will NOT be used.
#### QPainter
Painter is mainly a software renderer also called raster paint engine.
With [QPainter](https://doc.qt.io/qt-5/qpainter.html) you can draw on a viewport/paint device directly (like QPixmap, QWidget, QPicture and QOpenGLPaintDevice), see [Qt GUI](https://doc.qt.io/qt-5/qtgui-index.html) module. Q
**Conclusion:** *No Conclusion yet* - Under investigation
#### QT Quick/OpenGL
Qt as recently switched more and more to Qt Quick Scene features for 2D/OpenGL renderer and used as raster paint engine.
**Conclusion:** *No Conclusion yet* - Under investigation
#### QGraphics Scene
We can try using a [QGraphicsScene](https://doc.qt.io/qt-5/qgraphicsscene.html) and add items to the scene like the [QGraphicsTextItem](https://doc.qt.io/qt-5/qgraphicstextitem.html). The items added will be rendered and displayed automatically.
*Very bad* performance has been discovered during testing, by creating items to the scene. Even with small number of objects and changing the font to bold or italic will cause 20ms.
**Conclusion:** Will NOT be used.
#### QtSkia
Skia is ported to Qt, called QtSkia. The Qt WebEgine renders web pages by using Skia and is not using QPainter or Qt for this purpose.
[Studies](https://www.facebook.com/notes/beagleboardorg-foundation/comparing-html-rendering-performance-with-qtwebkit-and-qt-native-classes/439968524361/) has shown with the Matrix GUI (developed by Texas Instruments for ARM based SoCs) that (Qt)WebKit is much much faster in rendering then the built-in Qt renderer.
Why using QtSkia, if we can just directly using Skia?
**Conclusion:** *No Conclusion yet* - Under investigation
### Qt examples/links
* [Drawing text](https://github.com/radekp/qt/blob/master/src/gui/text/qtextlayout.cpp#L1114) with QPainter.
* [Mifit Text render](https://github.com/mifit/mifit/blob/master/libs/opengl/Text.cpp) for a code example.
* [Drawing Text/line using QPainter](https://www.youtube.com/watch?v=tc3nlNEAdig) (video).
By `baysmith`:
It generates image atlas dynamically using a QPainter to draw to a texture which is displayed with quads. I don't know how much less efficient it is to draw the characters to the image on demand rather than prebaking, but I need the flexibility to change the font to anything the system provides.
* [Calligra](https://github.com/KDE/calligra) Word processor using Qt, maybe also creating their own text painting as well?
## ImGui
For some inspiration; there exists [Text Editor #1](https://github.com/BalazsJako/ImGuiColorTextEdit), [Text Editor #2](https://github.com/Rezonality/zep) created with Imgui.
* [Fonts documentation](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) of Imgui.
After testing the Imgui demo window using GLFW library + Vulkan backend, I discover a lot of mouse lag when dragging windows over the screen.
Also the application suffered quite some screen tearing (even with VSYNC on).
My expectation is that there are some huge synchronization issues with Imgui and OpenGL/Vulkan backends. Therefor is my advice is not to use Imgui for text rendering applications until futher notice.
**Conclusion:** Will NOT be used.

View File

@ -124,6 +124,7 @@ void MainWindow::setOutputToTextEdit(const QString& text)
auto htmlStart = Time::now();
// Possible rendering is done in seperate thread? Returning this function faster.
textEdit->setHtml(text);
auto htmlEnd = Time::now();