Hi there,
I've written a simple marquee text class for delphi some time ago, which I recently ported to lazarus along with the project using it. I encountered almost no problems, however, the cpu utilization of the marquee animation increased by a factor of 100: compiling with delphi 2006 and executing the application, the task manager always shows 0%, whereas the lazarus-compiled version consumes between 15% and 50% of the cpu (enabling optimizations has no effect).
The class works as follows: a text line is drawn to an off-screen TBitmap, and then the appropriate rectangle section of this bitmap (depending on the current position of the animation) is copied to a TPaintBox canvas by a repeated Timer event that also advances the position counter.
This is the method used for copying:
procedure TMarqueeText.CopySection(x1, y1, x2, y2: Integer; source: TCanvas;
destX, destY: Integer; dest: TCanvas);
var
sourceRect, destRect: TRect;
begin
sourceRect := Rect(x1, y1, x2, y2);
destRect := Rect(destX, destY, destX+(x2-x1), destY+(y2-y1));
dest.CopyRect(destRect, source, sourceRect);
end;
It seems that the TCanvas.Draw and CopyRect methods are very slow compared to their VCL counterparts (at least in this particular case).
I wonder what I'm doing wrong here, simply copying an image portion to another canvas can't be that expensive...
Development system: WinXP SP3, Lazarus 1.0