PDA

View Full Version : QGraphicsOpacityEffect horrible slow, how to make the same effect faster?



markg85
3rd August 2010, 20:27
Hi,

I use this effect together with QLinearGradient to create a alphaGradient mask, however this is extremely slow even with hardware acceleration turned on. When you search for it http://labs.trolltech.com/blogs/2009/12/16/qt-graphics-and-performance-an-overview/ it turns out to be a known issue:

There is also the QGraphicsOpacityEffect which allows you to set a mask widgets and graphics items, but as of today, it is not as fast as we would like it to be.

and this is roughly how i use it:


QLinearGradient alphaGradient(cust->rect().topLeft(), cust->rect().bottomLeft());
alphaGradient.setColorAt(0.12, Qt::transparent);
alphaGradient.setColorAt(0.20, Qt::black);
alphaGradient.setColorAt(0.8, Qt::black);
alphaGradient.setColorAt(0.9, Qt::transparent);

QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
effect->setOpacityMask(alphaGradient);
effect->setOpacity(1.0);

So anyway, is there a way to make this extremely fast (with hardware acceleration turned on)? If so, how?

All is has to do is set the alpha channel of an widget (QGraphicsWidget in this case)

The one hardware accelerated way i know but can't do (don't have the knowledge to do it) is by making a shader for it.

Mark.

markg85
4th August 2010, 15:06
this is gonna be odd.. answering myself :P

Oke, to speed it up a LOT i found that appending this to the starting command line of the application to be way faster then native X11 : -graphicssystem raster
On linux by default it uses X11 as the graphicssystem. I also found that (somethimes) setting the OpenGL graphicssystem (-graphicssystem opengl) is sometimes working! In my case it works but doesn't make the effect faster then the raster graphicssystem which makes me think (again) that the QGraphicsOpacityEffect has no (or nearly no) hardware acceleration support.