← Back to team overview

kicad-developers team mailing list archive

Re: Performance profiling


Vesa Solonen wrote:
> On Mon, 9 Mar 2009, jean-pierre charras - INPG wrote:
>>> For background, how about dropping exactness in screen measures and always
>>> fit the grid to even pixel count? Then wxBrush coud be used for drawing
>>> and the would probably speed up alot compared to single pixel draw call.

There are a lot of unnecessary calls in the grid drawing code. The
current GRPutPixel code checks every pixel to see if it is in the
current view even though the grid code determines the current view up
front so the check in GRPutPixel is redundant. Also GRPutPixel sets the
color every time you call it even thought the pen color is already set.
Each grid point coordinate is scaled in GRPutPixel. It makes more
sense to calculate the scaled starting coordinate and draw the pixels by
simpling incrementing the X and Y coordinates by the scaled integer grid
size. These simple changes will probably gain you some performance. My
guess is that the changing the grid size to use floating point values
was performance hit.

>>> -Vesa
>> The grid is a reference, so i think the dots positions must be exact.
>> Perhaps creates a grid line in memory and using a blit function could be
>> faster; (to do)

Be very careful about the decision to use blitting. Remember, depending
on what zoom level you draw your initial bitmap you will be stretching
and/or shrinking a bitmap of the drawing instead of scaling the drawing
objects to the current zoom level. At some point you will get blurring
(pixelation) zooming in or loss of detail zooming out. Redrawing the
bitmap every zoom factor change doesn't gain you any performance
increase. I know some of the new device contexts do a better job at
minimizing these problems but they still have their limits. I for one
do not want to zoom way in when laying out a PCB and see blurred curves
and lines.

> I meant zoom factor exactness, so that every grid increment is even in 
> pixels. Otherwise blitting needs fractional calculation and rounding too 
> for line position. It would be so nice if wx had same kind of drawing 
> primitive buffers available like in OpenGL vertex arrays and vertex buffer 
> objects.
> It seems wxGC has something like that:
> http://aspn.activestate.com/ASPN/Mail/Message/wxpython-users/3543798
> -Vesa

I have been working on some drawing (along with a whole bunch of other
stuff) improvements but I have been slowed by fragility of the current
drawing code. It seems like I always end up having to fix five other
things along the way when making what seems to be a fairly simple
change. I am willing to make the changes above to see if that improves
things but I will wait until after the next Kicad release. I have been
holding off on committing any code SVN because I have made some major
changes and I don't want to jeopardize pushing back the next release


> ------------------------------------
> Yahoo! Groups Links


Follow ups