Transparent background for widgets in KHTML

Germain Garand germain at ebooksfrance.org
Thu Mar 13 17:49:26 GMT 2008


Hi Rafael!

Le jeudi 13 mars 2008, Rafael Fernández López a écrit :
> Hi all,
>
> I was very glad to see that the widget support has been really improved
> these da ys on KHTML. It was a pain using them before.

thank you for caring about it - even if from where I stand, this is rather a 
regression :-}

The full story is that I have disabled the in place painting of widgets (a.k.a 
the !buffered case in copyWidget), which was solving problems of performance 
and transparency handling, and something I had hopes of being able to use 
reliably ever since Trolltech introduced the possibility of redirecting paint 
devices with an offset.

In Qt 4.3 releases, things were almost working fine, with still the occasional 
glitch and QPainter being a constant source of headaches.
In current beta qt-copy, using QWidget::render to paint on another widget's 
surface is just so broken I've given up for now, hence the "progress" :)

But anyway, I'm very happy you tackled this transparency problem. I hadn't 
noticed it before as buffered mode was only used when zooming or printing.

I thought it was enough to actually paint on a pixmap with a transparent color 
with Source painter mode, or use the Clear composition mode, to have Qt 
understand we actually needed an alpha channel on the destination, but 
apparently not at all ;(

Now for the method used in your patches, I don't think it will be fast enough 
as building a mask is expensive and would negate the benefit of using cached 
pixmaps (cf. misc/paintbuffer.{cpp,h}).

From some experiments I did and reading Qt source, it seems activating the 
alpha channel can be the most cheaply done (on X) by using QPixmap::fill with 
Qt::transparent.

This need to be done only once. For subsequent reuses of the pixmap, it's then 
possible to use the Source composition mode to fill only a sub-rectangle with 
Qt::transparent (Clear compsition mode is clearly completely broken).

So all in all, I think the best would be to handle all blanking of buffers 
directly in misc/paintbuffer.{cpp,h}, maybe passing the sub-rectangle we want 
to blank as another argument of PaintBuffer::getBuf.

e.g. whenever it would return a new pixmap => use QPixmap::fill with 
Qt::transparent, otherwise only blank the requested rectangle.

This should actually also fix transparency problems with CSS3 opacity buffers, 
which I have sometime noticed, as they used the same method for blanking.

Greetings,
Germain




More information about the kfm-devel mailing list