[Lazarus] Painting performance

Mattias Gaertner nc-gaertnma at netcologne.de
Fri May 21 16:21:41 CEST 2010


On Fri, 21 May 2010 15:34:12 +0200
Roland Turcan <konf at rotursoft.sk> wrote:

> Hello Lazarus mailing list!
> 
> I  am  still  porting our application from Delphi/Kylix to Lazarus and
> the performance of the same units responsible for graphical output are
> nearly  the  same,  but the performance on Lazarus Carbon/Gtk2 is much
> slower than on VCL/CLX.

1. The gtk drawing functions are per se slower than the winapi
functions.
2. To achieve Delphi compatible drawing the LCL has to combine several
gtk functions to get the same effect of one winapi function. Especially
the specialized functions, that are fast under winapi, have no direct
counterpart in the gtk. And Delphi programs use mostly the fast
functions of the winapi.
3. system colors (e.g. clBtnFace) are gradients and images under gtk,
while under winapi they are simple colors.

 
> What   would   you  recommend  to  find  out  the  bottleneck  of  the
> performance. Maybe it is in some part of code about painting which
> must be rewritten for performance improvement on LCL.

Try to reduce the number of drawing operations. For
example don't use Get/SetPixel. Use a polygon instead of MoveTo/LineTo.
Use default fonts and text styles. Use default Brush and Pen styles.
Draw to a memory bitmap and draw that. See my other mail about fpcanvas
and aggpas.
There are plans to accelerate aggpas by drawing directly to the
widgetset image buffers.

Use gprof to find out where the bottleneck is.

 
> Thanks for all recommendations in advance.


Mattias
 




More information about the Lazarus mailing list