clearRect doesn't erase a given rect, it just fills it with white.
clearRect uses p->eraseRect to clear a given rect. eraseRect is the same as p->fillRect(rect, p->background()). We never set the background, because we're using transparent background mode, the default. And the documentation saith that setBackground() has no effect in transparent background mode.
ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
solves the problem.
(I would add set the background somewhere in the ImageBuffer. We may need to erase the context somewehere else than in context->clearRect().)
Created attachment 27312 [details]
transparent background for context
Dirk, thanks for tracking this down! I think an alternate and perhaps cleaner solution would be to set the composition mode to QPainter::CompositionMode_Clear. What do you think?
I tried QPainter::CompositionMode_Clear first, but it doesn't fix the problem. I'm not sure why setBackground() works. It shouldn't http://doc.trolltech.com/4.4/qpainter.html#setBackground . And setting background mode manually to Qt::TransparentMode doens't work either.
(In reply to comment #3)
> I tried QPainter::CompositionMode_Clear first, but it doesn't fix the problem.
> I'm not sure why setBackground() works. It shouldn't
> http://doc.trolltech.com/4.4/qpainter.html#setBackground . And setting
> background mode manually to Qt::TransparentMode doens't work either.
That's odd. What's the easiest way to test/verify this? I can try to take a look at this with our QPainter guys.
Created attachment 27350 [details]
This shows the problem in Canvas. Hope that's what you wanted.
I had a chat with our QPainter guys and discussed your testcase. We can use CompositionMode_Clear, but then we have to call drawRect(rect); instead of eraseRect(). The fastest way however is to simply call fillRect(Qt::transparent). Both worked for me (_Clear with drawRect() and fillRect(Qt::transparent).
Can you make a patch with fillRect(Qt::transparent)? I'll review it then :)
Thanks again, Dirk!
Created attachment 27400 [details]
Fix for clearRect
Fix for clearRect with another composite operator.
landed in r40721