[Lazarus] Fast drawing to canvas

waldo kitty wkitty42 at windstream.net
Thu Feb 9 03:25:55 CET 2012


On 2/8/2012 19:52, Darius Blaszyk wrote:
> Despite all the advices, none of the suggestions of drawing on a TPaintBox or creating a TCustomControl actually speed up the painting significantly. Therefore I did some profiling. It appears that loading a 40kb png file (50% HD) from a stream takes about 60msec another 30msec is used to paint the bitmap to screen. It all results in approx. 11fps which is actually pretty poor when you imagine a full HD loop will make the rate drop 2.5fps.

the first thing that comes to my mind is hardware related... what hardware are 
you using? even with "fast" hardware, it is possible that FPS is very slow... as 
an example, i have numerous tools that draw to the screen on my laptop much 
slower than if they are run on a dedicated desktop machine with graphic 
intensive hardware and then there is IF graphic hardware routines are used or not...

> As I see it now, I will need to lower the access time to the png's from disk.

handling this bottleneck is always a GoodThing<tm> ;)

> I will do a test with storing only raw pixel data instead. This means that
> there will be no conversion (or decompression in the case of PNG) when streaming
> from disk. However, although the minor part of the total loop, I was hoping to
> improve the painting speed significantly as well.

you can't go any faster than the data is made available, FWTW...

> Hopefully someone else has an  idea that works. Is there a way to access even
> lower level functions from LCL? Like GDI and GTK2 functions to copy the pixel
> data as fast as possible?

how far are you in to multiplatform stuffs? is your program also tuned to the 
winwhatever world? the reason i ask is because it is possible that some things 
may be slower in the other "world" than that you are developing in...




More information about the Lazarus mailing list