Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
again QGraphicsView performance
Hi
I like QGraphicsView very much, but I vave some issue with performance. I used to search help on forums histroy but I still need some help.
On my scene I have a video some CLVideoWindow’s items ihereted from QGraphicsItem. Basicly each CLVideoWindow object dispaying live video ( video size is about 800x60, so boundingRect returns QRectF
(0,0,800,600).
voidCLVideoWindow::paint(QPainter *painter, constQStyleOptionGraphicsItem *option, QWidget *widget) function does some OpenGL shaders.
So, as you can see my items is preaty dynamic. I need to call item->update() function in gui thread ~20-30 times per second for each item.
And it works fine with 2 itimes, but as soon as I add third item on the scene gui thread cpu usage jumps form 6-8% up to 30-36%. Threre is no differences beween 1 2 and 3 items ( they just display different video content ).
Problem is not in CLVideoWindow::paint function. Even if I do not do anything inside paint(…) ( just return ) gui thread takes almost the same CPU time. If I do not call update() so ofen – it’s fine ( low cpu usage ).
The problem apears only if I add third item(no metter in what sequence). I also noticed that if I maximize application gui thread also takes more CPU ( but not always ).
After I add 4,5,6.. items cpu increased on 4-5% ( this is expactable ). But how come third item gives such dramatic increase?
I have QT.4.5.2 Windows Xp / Vista.
Here are options I use for my QGraphicsView( I do not use Antialiasing):
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
m_View.setViewport(newQGLWidget());
m_View.setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
m_View.setCacheMode(QGraphicsView::CacheBackground);
m_View.setDragMode(QGraphicsView::ScrollHandDrag);
m_View.setOptimizationFlag(QGraphicsView::DontClipPainter);
m_View.setOptimizationFlag(QGraphicsView::DontSavePainterState);
m_View.setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing);
m_View.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_View.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Thank you in advance.