Bug 23728 - [QT] clearRect fill's a given rect with white
Summary: [QT] clearRect fill's a given rect with white
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-04 04:38 PST by Dirk Schulze
Modified: 2009-02-06 09:39 PST (History)
1 user (show)

See Also:


Attachments
transparent background for context (1.25 KB, patch)
2009-02-04 05:16 PST, Dirk Schulze
no flags Details | Formatted Diff | Diff
clearRect test (436 bytes, text/html)
2009-02-05 08:50 PST, Dirk Schulze
no flags Details
Fix for clearRect (1.46 KB, patch)
2009-02-06 09:20 PST, Dirk Schulze
hausmann: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.
Comment 8 Dirk Schulze 2009-02-06 09:39:06 PST
landed in r40721