[Interest] Best way to threaded render (images) going forward?

Wesley Krasko wesblake at gmail.com
Fri Dec 6 18:40:39 CET 2019


I solved this problem, thanks all. So our previous video surface WAS
QPainter on a separate thread already, it is possible. It was also cross
platform. But, it was the deprecated QGLWidget.
It turns out even if I could have gotten this all working in QOpenGLWidget,
that newer widget had a bug so we can't use it.
https://bugreports.qt.io/browse/QTBUG-49657
Our app does run in full screen and that bug still exists in 5.13.x
So, I went to a new, simpler model and it's working. I subclassed the
regular QWidget for the surface, and made a worker thread that uses a
QPainter on a QImage. I do all the resizing of the frames, compositing them
together, etc in that thread, then just pass the final QImage via signal to
the QWidget to draw in the UI thread. It's working fine, on all platforms
again, at 60fps with no apparent impact on the rest of the UI.
If it helps anyone, here is the final thread with some example code:
https://forum.qt.io/topic/109480/proper-way-to-pass-qimage-from-thread-through-signal/2
So in the final though, in Renderer::render(), I'm actually doing all the
work stated above, not just drawImage.


On Fri, Dec 6, 2019 at 8:56 AM Uwe Rathmann <Uwe.Rathmann at tigertal.de>
wrote:

> On 11/22/19 2:14 PM, Roland Hughes wrote:
>
> > There have been many requests over the years to allow QPainter
> > operations outside of the primary thread. In particular for running
> > graphs like heart rate monitors which are just a brick on the screen the
> > user generally cannot interact with.
>
> With X11 it is at least possible to draw outside of the paint event -
> see Qt::WA_PaintOutsidePaintEvent. This type of operation is used in the
> Qwt plot package for exactly the use case you have mentioned.
>
> I'm not 100% sure if it wouldn't be possible to the same in an extra
> thread.
>
> With Qt3 it was even possible to draw in XOR mode, what was at that time
> the way how rubberbands were implemented. This was an operation where
> you could erase content without having to repaint from scratch. But this
> one seems to be gone forever.
>
> Uwe
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>


-- 
Wes Krasko
www.worldwidewes.com
www.kraskofamily.com
"Stay away from negative people. They have a problem for every solution."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20191206/4b0fdeed/attachment.html>


More information about the Interest mailing list