Painting on selections and selection masks

Boudewijn Rempt boud at valdyas.org
Fri Oct 28 09:42:29 UTC 2011


Hi,

I've been doing quite a bit of work in this area, first building on Sven's branch, then doing some other experiments. Here are my provisional conclusions and a proposed (less than ideal) solution:


* tools cannot handle colorspaces without an alpha channel. We cannot generate a dab, we can't do anything. It's a limitation in our design.
* pigment cannot handle masks with more than one channel. Again, nothing we can do much about.
* the actual problem when painting on a gray without alpha colorspace paintdevice isn't the color conversion code or the bitblt implementation but that we cannot generate the right dabs or interpret the canvas correctly for painting. Again, we need an alpha channel to be able to paint.

Just fixing the gray-without-alpha colorspace, or adding a special composite op will not fix the problems...

I have tried to special case the painting code to generate a dab in graya and then convert to gray and then bitblt, but I disliked the fact that we then need to check all over the code for problems handling colorspaces without alpha.

I took a look to see how hard it would be to make krita just work correctly with colorspaces without alpha but I gave up on that. Not feasible for 2.4, maybe just not feasible.

I'm right now trying the following solution:

* make KisPixelSelection have a gray + alpha colorspace and use this for creating selections
* create a KisSelectionProjection class which is used for masking. KisSelection::projection returns an instance of this class

This seems to be promising: I have a problem with the extent calculation of KisPixelSelection if it's graya, but apart from that nothing major. I think I can make this scheme work in time for 2.4.

However, this means that a simple raster selection now takes not one, but _three_ bytes, and that there's always the step of generating the projection, which takes time.

On the other hand, in the future it would make it much easier to make it possible to add, say, a blur filter mask to a transparency mask or apply filters to masks.

On a sidenote: the outline generator needs to be rewritten so it doesn't need a copy of all the bytes in a selection as a buffer but to use a paint device. This is wasteful of memory.

I've attached the current patchset, it doesn't work, but does give you a general idea.
-- 
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-KisOutlineGenerator-make-it-possible-to-generate-an-.patch
Type: text/x-patch
Size: 6357 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20111028/b8912c16/attachment-0004.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Make-KisPixelSelection-use-Gray-Alpha-instead-of-Gra.patch
Type: text/x-patch
Size: 12023 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20111028/b8912c16/attachment-0005.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Create-a-new-class-KisSelectionProjection.patch
Type: text/x-patch
Size: 31031 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20111028/b8912c16/attachment-0006.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Selection-tools-set-a-defaultbounds-object-based-on-.patch
Type: text/x-patch
Size: 1160 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20111028/b8912c16/attachment-0007.patch>


More information about the kimageshop mailing list