//at start of cocoaGdiObjects.pas
var
_cocoa_ctx: qword;
_cocoa_text: qword;
_cocoa_rect: qword;
//later
procedure TCocoaContext.TextOut(X, Y: Integer; Options: Longint; Rect: PRect; UTF8Chars: PChar; Count: Integer; CharsDelta: PInteger);
var
BrushSolid, FillBg: Boolean;
q0, q1: qword;
begin
q0:= gettickcount64;
CGContextSaveGState(CGContext());
q1:= gettickcount64;
inc(_cocoa_ctx, q1-q0);
q0:= q1;
if Assigned(Rect) then
begin
// fill background
//debugln(['TCocoaContext.TextOut ',UTF8Chars,' ',dbgs(Rect^)]);
if (Options and ETO_OPAQUE) <> 0 then
begin
BrushSolid := BkBrush.Solid;
BkBrush.Solid := True;
with Rect^ do
Rectangle(Left, Top, Right, Bottom, True, BkBrush);
BkBrush.Solid := BrushSolid;
end;
if ((Options and ETO_CLIPPED) <> 0) and (Count > 0) then
begin
CGContextBeginPath(CGContext);
CGContextAddRect(CGContext, RectToCGrect(Rect^));
CGContextClip(CGContext);
end;
end;
q1:= gettickcount64;
inc(_cocoa_rect, q1-q0);
q0:= q1;
if (Count > 0) then
begin
FillBg := BkMode = OPAQUE;
if FillBg then
FText.BackgroundColor := BkBrush.ColorRef;
FText.SetText(UTF8Chars, Count);
FText.Draw(ctx, X, Y, FillBg, CharsDelta);
end;
q1:= gettickcount64;
inc(_cocoa_text, q1-q0);
q0:= q1;
CGContextRestoreGState(CGContext());
q1:= gettickcount64;
inc(_cocoa_ctx, q1-q0);
q0:= q1;
AttachedBitmap_SetModified();
end;