@@ -88,8 +88,6 @@ TBrushData = record
88
88
strict private
89
89
FCanvas: ISkCanvas;
90
90
FContextHandle: THandle;
91
- FRoundRect: ISkRoundRect;
92
- FRoundRectRadii: TSkRoundRectRadii;
93
91
procedure BeginPaint (const ARect: TRectF; const AOpacity: Single; var ABrushData: TBrushData);
94
92
strict protected
95
93
FAntiAlias: Boolean;
@@ -113,6 +111,8 @@ TBrushData = record
113
111
procedure DoDrawLine (const APoint1, APoint2: TPointF; const AOpacity: Single; const ABrush: TStrokeBrush); override;
114
112
procedure DoDrawPath (const APath: TPathData; const AOpacity: Single; const ABrush: TStrokeBrush); override;
115
113
procedure DoDrawRect (const ARect: TRectF; const AOpacity: Single; const ABrush: TStrokeBrush); override;
114
+ procedure DoDrawRoundRect (const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
115
+ const AOpacity: Single; const ABrush: TStrokeBrush; const ACornerType: TCornerType = TCornerType.Round); override;
116
116
procedure DoEndScene ; override; final;
117
117
procedure DoFillEllipse (const ARect: TRectF; const AOpacity: Single; const ABrush: TBrush); override;
118
118
procedure DoFillPath (const APath: TPathData; const AOpacity: Single; const ABrush: TBrush); override;
@@ -1650,7 +1650,6 @@ procedure TSkCanvasCustom.AfterConstruction;
1650
1650
// Skia m107 shows better performance with anti-aliasing enabled. Therefore,
1651
1651
// we'll enforce it to always be true, regardless of the Quality property.
1652
1652
FAntiAlias := True;
1653
- FRoundRect := TSkRoundRect.Create;
1654
1653
SkInitialize;
1655
1654
inherited ;
1656
1655
end ;
@@ -1870,7 +1869,6 @@ function TSkCanvasCustom.CreateSaveState: TCanvasSaveState;
1870
1869
1871
1870
destructor TSkCanvasCustom.Destroy;
1872
1871
begin
1873
- FRoundRect := nil ;
1874
1872
FWrapper := nil ;
1875
1873
SkFinalize;
1876
1874
inherited ;
@@ -2021,6 +2019,43 @@ procedure TSkCanvasCustom.DoDrawRect(const ARect: TRectF;
2021
2019
end ;
2022
2020
end ;
2023
2021
2022
+ procedure TSkCanvasCustom.DoDrawRoundRect (const ARect: TRectF; const XRadius, YRadius: Single; const ACorners: TCorners;
2023
+ const AOpacity: Single; const ABrush: TStrokeBrush; const ACornerType: TCornerType);
2024
+ var
2025
+ LBrushData: TBrushData;
2026
+ LPaint: TSkPaint;
2027
+ LRoundRect: ISkRoundRect;
2028
+ LRoundRectRadii: TSkRoundRectRadii;
2029
+ begin
2030
+ if ACornerType <> TCornerType.Round then
2031
+ inherited
2032
+ else
2033
+ begin
2034
+ LPaint := BeginPaintWithStrokeBrush(ABrush, ARect, AOpacity, LBrushData);
2035
+ if LPaint <> nil then
2036
+ try
2037
+ if ACorners = AllCorners then
2038
+ Canvas.DrawRoundRect(ARect, XRadius, YRadius, LPaint)
2039
+ else
2040
+ begin
2041
+ FillChar(LRoundRectRadii, SizeOf(LRoundRectRadii), 0 );
2042
+ if TCorner.TopLeft in ACorners then
2043
+ LRoundRectRadii[TSkRoundRectCorner.UpperLeft] := PointF(XRadius, YRadius);
2044
+ if TCorner.TopRight in ACorners then
2045
+ LRoundRectRadii[TSkRoundRectCorner.UpperRight] := PointF(XRadius, YRadius);
2046
+ if TCorner.BottomLeft in ACorners then
2047
+ LRoundRectRadii[TSkRoundRectCorner.LowerLeft] := PointF(XRadius, YRadius);
2048
+ if TCorner.BottomRight in ACorners then
2049
+ LRoundRectRadii[TSkRoundRectCorner.LowerRight] := PointF(XRadius, YRadius);
2050
+ LRoundRect := TSkRoundRect.Create(ARect, LRoundRectRadii);
2051
+ Canvas.DrawRoundRect(LRoundRect, LPaint);
2052
+ end ;
2053
+ finally
2054
+ EndPaint(LBrushData);
2055
+ end ;
2056
+ end ;
2057
+ end ;
2058
+
2024
2059
procedure TSkCanvasCustom.DoEndScene ;
2025
2060
begin
2026
2061
EndCanvas(FContextHandle);
@@ -2079,6 +2114,8 @@ procedure TSkCanvasCustom.DoFillRoundRect(const ARect: TRectF; const XRadius, YR
2079
2114
var
2080
2115
LBrushData: TBrushData;
2081
2116
LPaint: TSkPaint;
2117
+ LRoundRect: ISkRoundRect;
2118
+ LRoundRectRadii: TSkRoundRectRadii;
2082
2119
begin
2083
2120
if ACornerType <> TCornerType.Round then
2084
2121
inherited
@@ -2091,17 +2128,17 @@ procedure TSkCanvasCustom.DoFillRoundRect(const ARect: TRectF; const XRadius, YR
2091
2128
Canvas.DrawRoundRect(ARect, XRadius, YRadius, LPaint)
2092
2129
else
2093
2130
begin
2094
- FillChar(FRoundRectRadii , SizeOf(FRoundRectRadii ), 0 );
2131
+ FillChar(LRoundRectRadii , SizeOf(LRoundRectRadii ), 0 );
2095
2132
if TCorner.TopLeft in ACorners then
2096
- FRoundRectRadii [TSkRoundRectCorner.UpperLeft] := PointF(XRadius, YRadius);
2133
+ LRoundRectRadii [TSkRoundRectCorner.UpperLeft] := PointF(XRadius, YRadius);
2097
2134
if TCorner.TopRight in ACorners then
2098
- FRoundRectRadii [TSkRoundRectCorner.UpperRight] := PointF(XRadius, YRadius);
2135
+ LRoundRectRadii [TSkRoundRectCorner.UpperRight] := PointF(XRadius, YRadius);
2099
2136
if TCorner.BottomLeft in ACorners then
2100
- FRoundRectRadii [TSkRoundRectCorner.LowerLeft] := PointF(XRadius, YRadius);
2137
+ LRoundRectRadii [TSkRoundRectCorner.LowerLeft] := PointF(XRadius, YRadius);
2101
2138
if TCorner.BottomRight in ACorners then
2102
- FRoundRectRadii [TSkRoundRectCorner.LowerRight] := PointF(XRadius, YRadius);
2103
- FRoundRect.SetRect (ARect, FRoundRectRadii );
2104
- Canvas.DrawRoundRect(FRoundRect , LPaint);
2139
+ LRoundRectRadii [TSkRoundRectCorner.LowerRight] := PointF(XRadius, YRadius);
2140
+ LRoundRect := TSkRoundRect.Create (ARect, LRoundRectRadii );
2141
+ Canvas.DrawRoundRect(LRoundRect , LPaint);
2105
2142
end ;
2106
2143
finally
2107
2144
EndPaint(LBrushData);
0 commit comments