[Qt-interest] how to make QGraphicsView updated as soon as possible?
Zhao, Halley
halley.zhao at intel.com
Mon Feb 14 06:37:47 CET 2011
Now I found that QPainter is created in QGraphicsView::paintEvent() each time, it consume ~12ms each time.
(maybe, the destroy of this QPainter also consume much time)
Could we avoid creating the painter each time?
I try to use a static QPainter, but it doesn’t work well:
If I reuse the QPainter created in previous ::paintEvent(), my viewport doesn’t update. And there are some warning from qt that the painter is not active.
If I reuse previous painter and call QPainter.begin(viewport()), it consume more time. ~22ms.
Is there any way to reuse the previous painter correctly?
From: Jason H [mailto:scorp1us at yahoo.com]
Sent: Monday, February 14, 2011 8:37 AM
To: Zhao, Halley; qt-interest at trolltech.com
Subject: Re: [Qt-interest] how to make QGraphicsView updated as soon as possible?
I am doing hardware accelerated video on a atom 330.
My animations take about 10% and video takes about 10%.
I definitely noticed a large difference between codecs, at the same recorded framerate and resolution. GStreamer seems to vary greatly. I settled on the Ogg/Theora.
________________________________
From: "Zhao, Halley" <halley.zhao at intel.com>
To: Jason H <scorp1us at yahoo.com>; "qt-interest at trolltech.com" <qt-interest at trolltech.com>
Sent: Sun, February 13, 2011 7:30:12 PM
Subject: RE: [Qt-interest] how to make QGraphicsView updated as soon as possible?
Thanks.
There is only one QGraphicsItem in my scene, and the ::paint() of this QGraphicsItem consumes ~6ms each time.
So, I don’t think ::paint() itself is the killer.
Hw acceleration (openGL) is used because I have assigned a GLWidget as viewport.
There is more data in the following link:
https://bugs.meego.com/show_bug.cgi?id=13303
From: Jason H [mailto:scorp1us at yahoo.com]
Sent: Sunday, February 13, 2011 8:39 AM
To: Zhao, Halley; qt-interest at trolltech.com
Subject: Re: [Qt-interest] how to make QGraphicsView updated as soon as possible?
There is a #define to set the frame rate. But you don't want a frame rate too fast because you cannot update in the interval. Your problem will be that you can't minimize your paints. You'll have to paint everything, every update from back z to front z. And so you can't compress and skip occluded regions. I'd expect your ideal to actually be slower, if you have a lot of overlapping items.
But fear not, there is hope! I would recommend you check out the graph-scene stuff if you need really smooth stuff:
http://labs.qt.nokia.com/2011/01/28/qml-scene-graph-has-moved/
http://labs.qt.nokia.com/2010/12/02/velvet-and-the-qml-scene-graph/
Also, make sure you are using hardware acceleration. The raster engine is precise and accurate but very slow. GL will allow you to get very close visually but at a fractional part of CPU. (Hardware renderers vary in implementation so you can't combine frames between hardware implementations.)
HTH
________________________________
From: "Zhao, Halley" <halley.zhao at intel.com>
To: "qt-interest at trolltech.com" <qt-interest at trolltech.com>
Sent: Fri, February 11, 2011 9:26:42 PM
Subject: [Qt-interest] how to make QGraphicsView updated as soon as possible?
After QGraphicsItem::update() is executed, there is some delay to QGraphicsItem::paint() is called.
This is not vital for common UI, but for a 30fps video frame update, this delay introduce many issue.
How could I make QGraphicsView updated as soon as possible?
Could I change the event loop to schedule the repaint as soon as possible?
There is also a similar issue for Qt::QueuedConnection, there is visible delay to invoke a method by QMetaObject::invokeMethod(this, method, Qt::QueuedConnection);
Could I reduce the delay?
(I can’t use Qt::DirectConnection because I need some code runs in Qt thread).
thanks
ZHAO, Halley (Aihua)
Email: halley.zhao at intel.com
Tel: +86(21)61166476 iNet: 8821-6476
SSG/OTC/Moblin 3W038 Pole: F4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110214/29c7e36a/attachment.html
More information about the Qt-interest-old
mailing list