<br><br><div class="gmail_quote">On Sat, Mar 26, 2011 at 9:48 PM, Silvio Heinrich <span dir="ltr"><<a href="mailto:plassy@web.de">plassy@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Git commit 6fecab005a76764575f7521184168fdd3018454f by Silvio Heinrich.<br>
Committed on 26/03/2011 at 19:35.<br>
Pushed by heinrich into branch 'master'.<br>
<br>
Added KisPainter::fill(...) method to fill a rectangular region with one color.<br>
<br>
The method will respect the current opacity and compositeOp.<br>
<br>
M +62 -0 krita/image/kis_painter.cc<br>
M +13 -0 krita/image/kis_painter.h<br>
<br>
<a href="http://commits.kde.org/calligra/6fecab005a76764575f7521184168fdd3018454f" target="_blank">http://commits.kde.org/calligra/6fecab005a76764575f7521184168fdd3018454f</a><br>
<br>
diff --git a/krita/image/kis_painter.cc b/krita/image/kis_painter.cc<br>
index 0cb7236..f482f03 100644<br>
--- a/krita/image/kis_painter.cc<br>
+++ b/krita/image/kis_painter.cc<br>
@@ -738,6 +738,68 @@ void KisPainter::bitBltOldData(const QPoint & pos, const KisPaintDeviceSP srcDev<br>
bitBltOldData(pos.x(), pos.y(), srcDev, srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height());<br>
}<br>
<br>
+void KisPainter::fill(qint32 x, qint32 y, qint32 width, qint32 height, const KoColor& color)<br>
+{<br>
+ /* This check for nonsense ought to be a Q_ASSERT. However, when paintops are just<br>
+ * initializing they perform some dummy passes with those parameters, and it must not crash */<br>
+ if(width == 0 || height == 0 || d->device.isNull())<br>
+ return;<br>
+<br>
+ /* Create an intermediate byte array to hold information before it is written<br>
+ * to the current paint device (aka: d->device) */<br>
+ quint8* dstBytes = new quint8[width * height * d->device->pixelSize()];<br>
+ d->device->readBytes(dstBytes, x, y, width, height);<br></blockquote><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
+ d->device->writeBytes(dstBytes, x, y, width, height);<br></blockquote><div><br>Hi, Silvio!<br>I'm not sure this is a good idea to use read/writeBytes here as it leads to huge memory allocations. We are trying to avoid using read/writeBytes everywhere we can. I guess, it would be safer to use per-tile composition like it is done in e.g. bitBlt (KisPaintDevice version). <br>
</div></div><br><br>-- <br>Dmitry Kazakov<br>