Too much calls paint method

  

I created a test component

unit Control1;

interface

uses
System.SysUtils, System.Classes, FMX.Types, FMX.Controls;

type
TTestComp = class(TControl)
private
i: integer;
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
published
property Width;
property Height;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents(‘Test’, [TTestComp]);
end;

{ TTestComp }

constructor TTestComp.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
i := 0;
end;

procedure TTestComp.Paint;
begin
inherited;
inc(i);
canvas.BeginScene;
canvas.Fill.Color := $FF000000;
canvas.FillRect(localrect, 0, 0, [], 1);
canvas.Fill.Color := $FFFFFFFF;
canvas.FillText(localrect, IntToStr(i), false, 1, [], TTextAlign.Center);
canvas.EndScene;
end;

end.

Here is the problem:

Component is drawing in top-left corner
Too much paint method calls when resizing form.

Just resized form.

I have a lot of components, built according to this principle. And when I change the size of the form, they begin to lag (Low FPS).

Standard components (TButton and etc.) work fine

Comments are closed.