Animation paintop, bad performance

LukasT.dev@gmail.com lukast.dev at gmail.com
Mon Oct 11 09:54:17 CEST 2010


On Sunday 10 October 2010 10:25:27 Cyrille Berger Skott wrote:
> Hey,
> 
> Intead of
> 
>      if (!m_isFirst){
>          erasedRc = rc = m_previousDab;
>         KisRectConstIteratorPixel srcIt = m_currentLayerDevice-
> 
> >createRectConstIterator(rc.left(), rc.top(), rc.width(), rc.height());
> 
>         KisRectIteratorPixel dstIt = m_currentLayerDevice-
> 
> >createRectIterator(rc.left(), rc.top(), rc.width(), rc.height());
> 
>         qint32 pixelSize = m_currentLayerDevice->pixelSize();
>          for (;!srcIt.isDone(); ++srcIt, ++dstIt) {
>              memcpy(dstIt.rawData(),srcIt.oldRawData(), pixelSize );
>          }
>      }
> 
> use the COMPOSITE_COPY composite op.
 
> Reason #1 Avoid duplicating existing functionnality :) Especially since
> there might be optimization

That code does not duplicate existing functionality, because I'm copying 
oldRawData to rawData. I could copy the oldrawdata to some device and then 
COMPOSITE_COPY them back, but would that be faster? I will try, but I doubt.

As Dmitry noted, we would need new method for it. Any idea how to realize 
this? 

My idea would be restoreArea(QRect rc) in KisPainter  or in KisPaintDevice
and restoreArea would copy the oldRawData bytes to rawData bytes.

> Reason #2 In your case, there will be a limited amount of memcpy, and
> memory usuage, as tiles will be shared between src and dst

Cool :-)
 
> And in any case, avoid using deprecated iterators in new code.

Regarding deprecated iterators, the new iterators currently miss some 
features. To be specific : x() and y() is missing. 

Cyrille, would you add them, please?



More information about the kimageshop mailing list