[Development] Painting an image onto itself

Thiago Macieira thiago.macieira at intel.com
Tue Apr 10 22:12:51 CEST 2012


On terça-feira, 10 de abril de 2012 21.46.09, Andreas Aardal Hanssen wrote:
> You want to take a screenshot of the widget from within the widget's own
> paintEvent? That cannot possibly work. Or even if it did, the result would
> be completely non-deterministic. The painting code required to take the
> screenshot is in the same function.

That reminds me of a question I've been meaning to ask: what is expected to 
happen if you paint an image or a subsection of one onto itself?

For example:

	QImage img = img;
	QPainter painter(&img);
	painter.drawImage(0, 0, img);

Is this expected to work? Is it expected to work if there are no pixels that 
are both source and destination (e.g., painting the right half on the left 
half, or top-left quadrant on the bottom-right quadrant)? Does the answer 
change according to composition mode?

The reason I'm asking is that many of the painting methods suffer from the same 
problem as memcpy / memmove. Optimising those methods via SIMD code might 
cause the behaviour to change.

Note that even the "no pixel is source and destination at the same time" 
answer requires special handling, since a destination pixel could be adjacent 
to a source pixel and could thus be read and written back.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120410/3c98500f/attachment.sig>


More information about the Development mailing list