[calligra] krita/image: Added KisPainter::fill(...) method to fill a rectangular region with one color.

Dmitry Kazakov dimula73 at gmail.com
Sat Mar 26 22:00:10 CET 2011


On Sat, Mar 26, 2011 at 9:48 PM, Silvio Heinrich <plassy at web.de> wrote:

> Git commit 6fecab005a76764575f7521184168fdd3018454f by Silvio Heinrich.
> Committed on 26/03/2011 at 19:35.
> Pushed by heinrich into branch 'master'.
>
> Added KisPainter::fill(...) method to fill a rectangular region with one
> color.
>
> The method will respect the current opacity and compositeOp.
>
> M  +62   -0    krita/image/kis_painter.cc
> M  +13   -0    krita/image/kis_painter.h
>
> http://commits.kde.org/calligra/6fecab005a76764575f7521184168fdd3018454f
>
> diff --git a/krita/image/kis_painter.cc b/krita/image/kis_painter.cc
> index 0cb7236..f482f03 100644
> --- a/krita/image/kis_painter.cc
> +++ b/krita/image/kis_painter.cc
> @@ -738,6 +738,68 @@ void KisPainter::bitBltOldData(const QPoint & pos,
> const KisPaintDeviceSP srcDev
>     bitBltOldData(pos.x(), pos.y(), srcDev, srcRect.x(), srcRect.y(),
> srcRect.width(), srcRect.height());
>  }
>
> +void KisPainter::fill(qint32 x, qint32 y, qint32 width, qint32 height,
> const KoColor& color)
> +{
> +    /* This check for nonsense ought to be a Q_ASSERT. However, when
> paintops are just
> +     * initializing they perform some dummy passes with those parameters,
> and it must not crash */
> +    if(width == 0 || height == 0 || d->device.isNull())
> +        return;
> +
> +    /* Create an intermediate byte array to hold information before it is
> written
> +     * to the current paint device (aka: d->device) */
> +    quint8* dstBytes = new quint8[width * height *
> d->device->pixelSize()];
> +    d->device->readBytes(dstBytes, x, y, width, height);
>

+    d->device->writeBytes(dstBytes, x, y, width, height);
>

Hi, Silvio!
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).


-- 
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kimageshop/attachments/20110327/5b2c3251/attachment.htm 


More information about the kimageshop mailing list