@@ -983,6 +983,69 @@ protected override void debugPaintSize(PaintingContext context, Offset offset) {
983
983
}
984
984
}
985
985
986
+ public class RenderClipOval : _RenderCustomClip < Rect > {
987
+ public RenderClipOval (
988
+ RenderBox child = null ,
989
+ CustomClipper < Rect > clipper = null ,
990
+ Clip clipBehavior = Clip . antiAlias
991
+ ) : base ( child : child , clipper : clipper , clipBehavior : clipBehavior ) {
992
+ D . assert ( clipBehavior != Clip . none ) ;
993
+ }
994
+
995
+ Rect _cachedRect ;
996
+ Path _cachedPath ;
997
+
998
+ Path _getClipPath ( Rect rect ) {
999
+ if ( rect != this . _cachedRect ) {
1000
+ this . _cachedRect = rect ;
1001
+ this . _cachedPath = new Path ( ) ;
1002
+ this . _cachedPath . addOval ( this . _cachedRect ) ;
1003
+ }
1004
+
1005
+ return this . _cachedPath ;
1006
+ }
1007
+
1008
+ protected override Rect _defaultClip {
1009
+ get { return Offset . zero & this . size ; }
1010
+ }
1011
+
1012
+ public override bool hitTest ( HitTestResult result ,
1013
+ Offset position = null
1014
+ ) {
1015
+ this . _updateClip ( ) ;
1016
+ D . assert ( this . _clip != null ) ;
1017
+ Offset center = this . _clip . center ;
1018
+ Offset offset = new Offset ( ( position . dx - center . dx ) / this . _clip . width ,
1019
+ ( position . dy - center . dy ) / this . _clip . height ) ;
1020
+ if ( offset . distanceSquared > 0.25f ) {
1021
+ return false ;
1022
+ }
1023
+
1024
+ return base . hitTest ( result , position : position ) ;
1025
+ }
1026
+
1027
+ public override void paint ( PaintingContext context , Offset offset ) {
1028
+ if ( this . child != null ) {
1029
+ this . _updateClip ( ) ;
1030
+ context . pushClipPath ( this . needsCompositing , offset , this . _clip , this . _getClipPath ( this . _clip ) ,
1031
+ base . paint , clipBehavior : this . clipBehavior ) ;
1032
+ }
1033
+ }
1034
+
1035
+ protected override void debugPaintSize ( PaintingContext context , Offset offset ) {
1036
+ D . assert ( ( ) => {
1037
+ if ( this . child != null ) {
1038
+ base . debugPaintSize ( context , offset ) ;
1039
+ context . canvas . drawPath ( this . _getClipPath ( this . _clip ) . shift ( offset ) , this . _debugPaint ) ;
1040
+ this . _debugText . paint ( context . canvas ,
1041
+ offset + new Offset ( ( this . _clip . width - this . _debugText . width ) / 2.0f ,
1042
+ - this . _debugText . text . style . fontSize * 1.1f ?? 0.0f ) ) ;
1043
+ }
1044
+
1045
+ return true ;
1046
+ } ) ;
1047
+ }
1048
+ }
986
1049
987
1050
public class RenderClipPath : _RenderCustomClip < Path > {
988
1051
public RenderClipPath (
@@ -1194,7 +1257,7 @@ public override bool hitTest(HitTestResult result, Offset position = null) {
1194
1257
return base . hitTest ( result , position : position ) ;
1195
1258
}
1196
1259
1197
-
1260
+
1198
1261
public override void paint ( PaintingContext context , Offset offset ) {
1199
1262
if ( this . child != null ) {
1200
1263
this . _updateClip ( ) ;
@@ -1282,7 +1345,7 @@ public override bool hitTest(HitTestResult result, Offset position = null) {
1282
1345
return base . hitTest ( result , position : position ) ;
1283
1346
}
1284
1347
1285
-
1348
+
1286
1349
public override void paint ( PaintingContext context , Offset offset ) {
1287
1350
if ( this . child != null ) {
1288
1351
this . _updateClip ( ) ;
@@ -1301,19 +1364,20 @@ public override void paint(PaintingContext context, Offset offset) {
1301
1364
}
1302
1365
else {
1303
1366
Canvas canvas = context . canvas ;
1304
- if ( this . elevation != 0.0 ) {
1305
- canvas . drawRect (
1306
- offsetBounds . inflate ( 20.0f ) ,
1307
- _transparentPaint
1308
- ) ;
1309
-
1310
- canvas . drawShadow (
1311
- offsetPath ,
1312
- this . shadowColor ,
1313
- this . elevation ,
1314
- this . color . alpha != 0xFF
1315
- ) ;
1316
- }
1367
+ if ( this . elevation != 0.0 ) {
1368
+ canvas . drawRect (
1369
+ offsetBounds . inflate ( 20.0f ) ,
1370
+ _transparentPaint
1371
+ ) ;
1372
+
1373
+ canvas . drawShadow (
1374
+ offsetPath ,
1375
+ this . shadowColor ,
1376
+ this . elevation ,
1377
+ this . color . alpha != 0xFF
1378
+ ) ;
1379
+ }
1380
+
1317
1381
Paint paint = new Paint { color = this . color , style = PaintingStyle . fill } ;
1318
1382
canvas . drawPath ( offsetPath , paint ) ;
1319
1383
context . clipPathAndPaint ( offsetPath , this . clipBehavior ,
0 commit comments