|Summary:||[QT] clearRect fill's a given rect with white|
|Product:||WebKit||Reporter:||Dirk Schulze <krit>|
|Component:||WebKit Qt||Assignee:||Nobody <webkit-unassigned>|
|Version:||528+ (Nightly build)|
|OS:||OS X 10.5|
Description Dirk Schulze 2009-02-04 04:38:19 PST
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. But adding: m_context.get()->platformContext()->setBackground(QColor(Qt::transparent)); to 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().)
Comment 1 Dirk Schulze 2009-02-04 05:16:42 PST
Created attachment 27312 [details] transparent background for context see above
Comment 2 Simon Hausmann 2009-02-04 07:42:04 PST
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?
Comment 3 Dirk Schulze 2009-02-04 11:13:47 PST
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.
Comment 4 Simon Hausmann 2009-02-05 07:21:56 PST
(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.
Comment 5 Dirk Schulze 2009-02-05 08:50:22 PST
Created attachment 27350 [details] clearRect test This shows the problem in Canvas. Hope that's what you wanted.
Comment 6 Simon Hausmann 2009-02-06 08:17:48 PST
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!
Comment 7 Dirk Schulze 2009-02-06 09:20:38 PST
Created attachment 27400 [details] Fix for clearRect Fix for clearRect with another composite operator.