KisPainter::paintPolygon used in paintops

Boudewijn Rempt boud at valdyas.org
Fri Mar 13 11:56:47 CET 2009


On Fri, 13 Mar 2009, LukasT.dev at gmail.com wrote:

> Hi,
> 
> I'm using paintPolygon in dynabrush and in spray. 
> For paintops it has one disadvantage. It is really slow.
> I made callgrind log [1] where I use it in modified spray [2].
> 
> To speed it up about of 4%, line 728 in kis_painter:
> KisPaintDeviceSP polygon = new KisPaintDevice(d->device->colorSpace(), 
> "polygon");
> Why is string used? When I call paintPolygon in paintop, it is called e.g. 600 

Ouch! That's bad -- the string is only used to give the paint device a name, which
is handy for debugging. Remove it! I'll check the rest of krita for places where
this really shouldn't be done.

> times in a stroke. Creating QString is quit slow. Is that string really 
> needed? What is its purpose? Could we use e.g. int for id, if it is id?
> 
> That method create a lot of objects like KisSelection,QImage, QPainter, QColor
> 
> What would be the solution for paintops? 
> Made own class for paintPolygon? Or optimalize paintPolygon somehow in 
> KisPainter (I don't have idea how to cache created objects in KisPainter :( )?

It is possible -- as long as you keep using the same kispainter object, and use
that object in only one thread. Otherwise, you're sunk.

> I use paintPolygon for painting shapes like filled aliased circle, 

I'd use paintEllipse for that -- but that calles paintPolygon in the end, too.

> polygon,etc..

I'm sure there are plenty of opportunities to tune this. I'll try to find some
time next week to look at the callgrind trace -- this weekend is going to be
horribly busy.

Boudewijn



More information about the kimageshop mailing list