@@ -1140,16 +1140,13 @@ public void DrawCircle(SvgCircle svgCircle, bool ignoreDisplay)
1140
1140
return ;
1141
1141
}
1142
1142
1143
- float cx = svgCircle . CenterX . ToDeviceValue ( null , UnitRenderingType . Horizontal , svgCircle ) ;
1144
- float cy = svgCircle . CenterY . ToDeviceValue ( null , UnitRenderingType . Vertical , svgCircle ) ;
1145
- float radius = svgCircle . Radius . ToDeviceValue ( null , UnitRenderingType . Other , svgCircle ) ;
1146
-
1147
- if ( radius <= 0f )
1143
+ var skPath = SkiaUtil . ToSKPath ( svgCircle , svgCircle . FillRule , _disposable ) ;
1144
+ if ( skPath == null || skPath . IsEmpty )
1148
1145
{
1149
1146
return ;
1150
1147
}
1151
1148
1152
- var skBounds = SKRect . Create ( cx - radius , cy - radius , radius + radius , radius + radius ) ;
1149
+ var skBounds = skPath . Bounds ;
1153
1150
1154
1151
_skCanvas . Save ( ) ;
1155
1152
@@ -1164,13 +1161,13 @@ public void DrawCircle(SvgCircle svgCircle, bool ignoreDisplay)
1164
1161
if ( SkiaUtil . IsValidFill ( svgCircle ) )
1165
1162
{
1166
1163
var skPaintFill = SkiaUtil . GetFillSKPaint ( svgCircle , _skSize , skBounds , _disposable ) ;
1167
- _skCanvas . DrawCircle ( cx , cy , radius , skPaintFill ) ;
1164
+ _skCanvas . DrawPath ( skPath , skPaintFill ) ;
1168
1165
}
1169
1166
1170
1167
if ( SkiaUtil . IsValidStroke ( svgCircle ) )
1171
1168
{
1172
1169
var skPaintStroke = SkiaUtil . GetStrokeSKPaint ( svgCircle , _skSize , skBounds , _disposable ) ;
1173
- _skCanvas . DrawCircle ( cx , cy , radius , skPaintStroke ) ;
1170
+ _skCanvas . DrawPath ( skPath , skPaintStroke ) ;
1174
1171
}
1175
1172
1176
1173
if ( skPaintFilter != null )
@@ -1193,17 +1190,13 @@ public void DrawEllipse(SvgEllipse svgEllipse, bool ignoreDisplay)
1193
1190
return ;
1194
1191
}
1195
1192
1196
- float cx = svgEllipse . CenterX . ToDeviceValue ( null , UnitRenderingType . Horizontal , svgEllipse ) ;
1197
- float cy = svgEllipse . CenterY . ToDeviceValue ( null , UnitRenderingType . Vertical , svgEllipse ) ;
1198
- float rx = svgEllipse . RadiusX . ToDeviceValue ( null , UnitRenderingType . Other , svgEllipse ) ;
1199
- float ry = svgEllipse . RadiusY . ToDeviceValue ( null , UnitRenderingType . Other , svgEllipse ) ;
1200
-
1201
- if ( rx <= 0f || ry <= 0f )
1193
+ var skPath = SkiaUtil . ToSKPath ( svgEllipse , svgEllipse . FillRule , _disposable ) ;
1194
+ if ( skPath == null || skPath . IsEmpty )
1202
1195
{
1203
1196
return ;
1204
1197
}
1205
1198
1206
- var skBounds = SKRect . Create ( cx - rx , cy - ry , rx + rx , ry + ry ) ;
1199
+ var skBounds = skPath . Bounds ;
1207
1200
1208
1201
_skCanvas . Save ( ) ;
1209
1202
@@ -1218,13 +1211,13 @@ public void DrawEllipse(SvgEllipse svgEllipse, bool ignoreDisplay)
1218
1211
if ( SkiaUtil . IsValidFill ( svgEllipse ) )
1219
1212
{
1220
1213
var skPaintFill = SkiaUtil . GetFillSKPaint ( svgEllipse , _skSize , skBounds , _disposable ) ;
1221
- _skCanvas . DrawOval ( cx , cy , rx , ry , skPaintFill ) ;
1214
+ _skCanvas . DrawPath ( skPath , skPaintFill ) ;
1222
1215
}
1223
1216
1224
1217
if ( SkiaUtil . IsValidStroke ( svgEllipse ) )
1225
1218
{
1226
1219
var skPaintStroke = SkiaUtil . GetStrokeSKPaint ( svgEllipse , _skSize , skBounds , _disposable ) ;
1227
- _skCanvas . DrawOval ( cx , cy , rx , ry , skPaintStroke ) ;
1220
+ _skCanvas . DrawPath ( skPath , skPaintStroke ) ;
1228
1221
}
1229
1222
1230
1223
if ( skPaintFilter != null )
@@ -1247,38 +1240,13 @@ public void DrawRectangle(SvgRectangle svgRectangle, bool ignoreDisplay)
1247
1240
return ;
1248
1241
}
1249
1242
1250
- float x = svgRectangle . X . ToDeviceValue ( null , UnitRenderingType . Horizontal , svgRectangle ) ;
1251
- float y = svgRectangle . Y . ToDeviceValue ( null , UnitRenderingType . Vertical , svgRectangle ) ;
1252
- float width = svgRectangle . Width . ToDeviceValue ( null , UnitRenderingType . Horizontal , svgRectangle ) ;
1253
- float height = svgRectangle . Height . ToDeviceValue ( null , UnitRenderingType . Vertical , svgRectangle ) ;
1254
- float rx = svgRectangle . CornerRadiusX . ToDeviceValue ( null , UnitRenderingType . Horizontal , svgRectangle ) ;
1255
- float ry = svgRectangle . CornerRadiusY . ToDeviceValue ( null , UnitRenderingType . Vertical , svgRectangle ) ;
1256
-
1257
- if ( width <= 0f || height <= 0f || rx < 0f || ry < 0f )
1243
+ var skPath = SkiaUtil . ToSKPath ( svgRectangle , svgRectangle . FillRule , _disposable ) ;
1244
+ if ( skPath == null || skPath . IsEmpty )
1258
1245
{
1259
1246
return ;
1260
1247
}
1261
1248
1262
- if ( rx > 0f )
1263
- {
1264
- float halfWidth = width / 2f ;
1265
- if ( rx > halfWidth )
1266
- {
1267
- rx = halfWidth ;
1268
- }
1269
- }
1270
-
1271
- if ( ry > 0f )
1272
- {
1273
- float halfHeight = height / 2f ;
1274
- if ( ry > halfHeight )
1275
- {
1276
- ry = halfHeight ;
1277
- }
1278
- }
1279
-
1280
- bool isRound = rx > 0f && ry > 0f ;
1281
- var skBounds = SKRect . Create ( x , y , width , height ) ;
1249
+ var skBounds = skPath . Bounds ;
1282
1250
1283
1251
_skCanvas . Save ( ) ;
1284
1252
@@ -1293,27 +1261,13 @@ public void DrawRectangle(SvgRectangle svgRectangle, bool ignoreDisplay)
1293
1261
if ( SkiaUtil . IsValidFill ( svgRectangle ) )
1294
1262
{
1295
1263
var skPaintFill = SkiaUtil . GetFillSKPaint ( svgRectangle , _skSize , skBounds , _disposable ) ;
1296
- if ( isRound )
1297
- {
1298
- _skCanvas . DrawRoundRect ( x , y , width , height , rx , ry , skPaintFill ) ;
1299
- }
1300
- else
1301
- {
1302
- _skCanvas . DrawRect ( x , y , width , height , skPaintFill ) ;
1303
- }
1264
+ _skCanvas . DrawPath ( skPath , skPaintFill ) ;
1304
1265
}
1305
1266
1306
1267
if ( SkiaUtil . IsValidStroke ( svgRectangle ) )
1307
1268
{
1308
1269
var skPaintStroke = SkiaUtil . GetStrokeSKPaint ( svgRectangle , _skSize , skBounds , _disposable ) ;
1309
- if ( isRound )
1310
- {
1311
- _skCanvas . DrawRoundRect ( skBounds , rx , ry , skPaintStroke ) ;
1312
- }
1313
- else
1314
- {
1315
- _skCanvas . DrawRect ( skBounds , skPaintStroke ) ;
1316
- }
1270
+ _skCanvas . DrawPath ( skPath , skPaintStroke ) ;
1317
1271
}
1318
1272
1319
1273
if ( skPaintFilter != null )
0 commit comments