[Interest] Custom OpenGL drawing with Skia breaks Qt Quick Scenegraph rendering

Daljit Singh daljit97 at live.com
Mon Feb 28 14:48:53 CET 2022


Hi,
I'm using the 2d vector graphics library Skia (with its OpenGL backend) in my Qt 5 project, but I have ran into a bug that I haven't been able to solve . To use Skia in my project, I've tried multiple different ways (using QQuickFramebufferObject, QSGRenderNode and also directly connecting to QQuickWindow::beforeRendering and other signals to draw my custom OpenGL code).
However, with all the different ways I've tried, the result is that Qt Quick Scene Graph rendering becomes broken introducing artefacts such as blurry and pixelated text and icons. It seems that Skia messes up with the OpenGL state and this in turn breaks the rendering of Qt Quick items (I'm already using QQuickWindow::resetOpenGLState).
I'm not exactly sure why this happens, but I've also tried isolating Skia in a separate OpenGL context (as demonstrated here https://doc.qt.io/qt-5/qtquick-scenegraph-textureinthread-example.html) and as expected the problem goes away.

I've create a small GitHub repository here https://github.com/daljit97/SkiaQtBug which shows the bug (since Skia is a pain to build I've included a prebuilt binary for x64 Windows, so you should be able to just open the project in Qt Creator and run it right away). This small example follows this tutorial at the following link https://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html and shows how mixing Skia rendering calls and native Qt Quick results in blurry and pixelated Text elements.
Also if you run the example with Qt 6, then the problem get slightly better (no more pixelated text) but other rendering artefacts are introduced.

Has anyone got any idea on what's going on?

Best,
Daljit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220228/97d0a1eb/attachment.htm>


More information about the Interest mailing list