[Qt-interest] bliking when overpainting on the XvImage with QPainter
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Thu Jul 9 17:33:57 CEST 2009
Lee wrote on Thursday, July 09, 2009 3:03 PM:
>> Try to access/draw the XvImage data directly into the "Qt double
>> buffer", without copying it first into a QPixmap
>
> Actually, I already tried to do so, but it turned out that I cannot
> 'put' XvImage to a pixmap.
> http://lists.x.org/archives/xorg-devel/2009-April/000641.html
Well, according to that posting it seems to me that Xv really wants to draw directly into the "Window", instead of into a Pixmap. This means bad luck for you, because when you then overlay that drawn image with text you will always have flicker.
The solution would really be to draw both video frame and text into a hidden buffer first, then swap buffers (double-buffering, as is done by Qt 4 widgets by default).
> I can't. Turing off the attribute makes it worse. The video frame
> is shown in a split second rather than blinking.
Okay, so this is really a strong indication that your call to
m_scene->put(m_window, m_gc, rect());
really draws the video frame on-screen, before the paintEvent() method finishes. What happens next in your paintEvent() method is that the text is then drawn into the (Qt) double-buffer, which is then subsequently swapped, as to become visible. Off course like this the video frame which was drawn before is then replaced by the Qt buffer, and hence only shown "for a split second".
So either you have to live with the flickering (by turning off Qt double buffering, just as you did), or you really have to find a way to draw the "Xv video frame" into a buffer (X11 pixmap, and then putting it into a QPixmap with the afore-mentioned static fromX11Pixmap() method. Then in your paintEvent() method you draw the video frame QPixmap together with the text, let Qt do the double-buffer swapping, and there you go, no more flickering :)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list