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).
void CLVideoWindow:
aint(QPainter *painter, const QStyleOptionGraphicsItem *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:
aint 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):
m_View.
setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
m_View.
setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing);
m_View.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_View.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_View.setViewport(new QGLWidget());
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);
To copy to clipboard, switch view to plain text mode
Thank you in advance.
Bookmarks