Delphi FireMonkey Canvas performance issues


By I am trying to make 2D game in Delphi XE5/XE6 with FireMonkey, and I need to keep multiplatformity – I need Windows and Android build. For now, game is just drawn with lines, circles, rectangles or other polygons and I use Canvas (TPaintBox on whole screen and OnPaint event to paint). Problem is, I think that performance is extremely low, even when FireMonkey should use GPU acceleration. I made this performance test which draw 1000 rectangles on random XY positions:

procedure Paint(Canvas: TCanvas);
I: Integer;
X, Y: Single;

Canvas.Fill.Color := $ffff0000;
for I := 0 to 10000 do begin
X := Random(500);
Y := Random(400);
Canvas.FillRect(TRectF.Create(X, Y, X + 20, Y + 20), 0, 0, [], 1);


I measured approach thru this function and I get these results:

Windows PC – Core2Duo 3.2GHz, GeForce 660Ti – pretty strong for such simple task – it took 20 miliseconds
Android Phone – HTC One X (4 core, 1 GHz, Tegra 3 CPU/GPU) – it took 50-60 milisends (not as big difference against PC, as i thought)
However I think that both devices should be able to …read more

Via: StackOverflow

One Response to Delphi FireMonkey Canvas performance issues

  1. Peter Feenstra says:

    Try the following:
    Put a Paintbox on a form.
    Create an instance of TBitmap (with the sizes of the Paintbox) in the ‘OnCreate’ of the form.
    Do the drawing to the Bitmap’s canvas between BeginScene and EndScene.
    Finally assign the Bitmap to the Bitmap of the Paintbox.

Leave a Reply to Peter Feenstra Cancel reply

Please use your real name instead of you company name or keyword spam.