QRegion

Boudewijn Rempt boud at valdyas.org
Mon Jun 4 09:42:51 CEST 2007


On Saturday 02 June 2007, Cyrille Berger wrote:
> Hello,
>
> I have concern about QRegion. I am not convince they are making things
> faster. Increasing them, sitematically appears very high in all profiling I
> do. So I was wondering if anyone has done any benchmarking with QRegion and
> without, and if the high cost of using them is compensate by a very high
> reduction of computation elsewhere ?

Where does the use of QRegion show up? Under what circumstances? Especially 
important is the size of your layer stack -- if you test with one background 
layer, then QRegion won't help as much as when you test with a large layer 
stack.

QRegion is used in a couple of places, from QPainterCanvas to KisProjection. 
Tools update the dirty are using KisPainter::addDirtyRect().

As for KisProjection, QRegion is actually not the right class for what we 
need, but there isn't anything better yet. QRegion quickly degrades into 
scanlines, what we need is a class that you can feed rects and then get the 
smallest set of largest possible rects out.  At one point Zack Rusin had 
promised Pippin (who also needs something like this) to see whether he could 
come up with the right kind of class, but he never did anything about it.

By default, KisProjection doesn't use the rects in a region but the bounding 
rect of the region; that degrades into doing full-image updates quite 
quickly. The "use_bounding_rect_of_dirty_region" config property determines 
this.

In KisQPainterCanvas, we use QRegion in exactly the same way as in 1.6, that 
cannot be a problem, especially because here the rects in the region simply 
cannot degrade into scanlines.

In KisLayer, QRegion is a compile-time option -- waiting for the class I 
mentioned above. I need some way to keep track of which rects in a layer are 
updated; simply using the boundingrect doesn't work because then it's 
impossible to update the projection of only part of the dirty area of a 
layer. But compile-time option is off by default.

In summary: QRegion is a stopgap until we get a better way to keep track of 
dirty areas of a paint device. That should either be a KisRegion class that 
is more efficient than QRegion and does not degrade into scanlines, or 
through marking tiles dirty in the backend and then aggregating clusters of 
dirty tiles into as large as possible dirty rects.  But that awaits Bart 
finishing his thesis :-). 

In any case, I'll add some code to KisPainter so you can switch between 
aggregating a dirty region and a single, big, dirty rect: you can then play 
with that setting when doing your profiling.

-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20070604/3e87e2d2/attachment.pgp 


More information about the kimageshop mailing list