Skip to content

Commit 2565b7b

Browse files
[FMX Render] Improve performance for FillRect with round corners
Co-Authored-By: Paulo César Botelho Barbosa <16469061+paulocesarbot@users.noreply.github.com>
1 parent c47f6df commit 2565b7b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Source/FMX/FMX.Skia.Canvas.pas

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ TBrushData = record
115115
procedure DoFillEllipse(const ARect: TRectF; const AOpacity: Single; const ABrush: TBrush); override;
116116
procedure DoFillPath(const APath: TPathData; const AOpacity: Single; const ABrush: TBrush); override;
117117
procedure DoFillRect(const ARect: TRectF; const AOpacity: Single; const ABrush: TBrush); override;
118+
procedure DoFillRoundRect(const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
119+
const AOpacity: Single; const ABrush: TBrush; const ACornerType: TCornerType); override;
118120
{$IF CompilerVersion >= 30}
119121
procedure DoSetMatrix(const AMatrix: TMatrix); override;
120122
{$ENDIF}
@@ -2096,6 +2098,41 @@ procedure TSkCanvasCustom.DoFillRect(const ARect: TRectF;
20962098
end;
20972099
end;
20982100

2101+
procedure TSkCanvasCustom.DoFillRoundRect(const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
2102+
const AOpacity: Single; const ABrush: TBrush; const ACornerType: TCornerType);
2103+
var
2104+
LBrushData: TBrushData;
2105+
LPaint: TSkPaint;
2106+
LRoundRectRadii: TSkRoundRectRadii;
2107+
begin
2108+
if ACornerType <> TCornerType.Round then
2109+
inherited
2110+
else
2111+
begin
2112+
LPaint := BeginPaintWithBrush(ABrush, ARect, AOpacity, LBrushData);
2113+
if LPaint <> nil then
2114+
try
2115+
if ACorners = AllCorners then
2116+
Canvas.DrawRoundRect(ARect, XRadius, YRadius, LPaint)
2117+
else
2118+
begin
2119+
FillChar(LRoundRectRadii, SizeOf(LRoundRectRadii), 0);
2120+
if TCorner.TopLeft in ACorners then
2121+
LRoundRectRadii[TSkRoundRectCorner.UpperLeft] := PointF(XRadius, YRadius);
2122+
if TCorner.TopRight in ACorners then
2123+
LRoundRectRadii[TSkRoundRectCorner.UpperRight] := PointF(XRadius, YRadius);
2124+
if TCorner.BottomLeft in ACorners then
2125+
LRoundRectRadii[TSkRoundRectCorner.LowerLeft] := PointF(XRadius, YRadius);
2126+
if TCorner.BottomRight in ACorners then
2127+
LRoundRectRadii[TSkRoundRectCorner.LowerRight] := PointF(XRadius, YRadius);
2128+
Canvas.DrawRoundRect(TSkRoundRect.Create(ARect, LRoundRectRadii), LPaint);
2129+
end;
2130+
finally
2131+
EndPaint(LBrushData);
2132+
end;
2133+
end;
2134+
end;
2135+
20992136
class procedure TSkCanvasCustom.DoFinalizeBitmap(var ABitmapHandle: THandle);
21002137
begin
21012138
end;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy