@@ -7,14 +7,44 @@ public partial class PictureFlusher {
7
7
void _drawRRectShadow ( uiPath path , uiPaint paint ) {
8
8
D . assert ( path . isNaiveRRect , ( ) => "Cannot draw fast Shadow for non-NaiveRRect shapes" ) ;
9
9
D . assert ( paint . style == PaintingStyle . fill , ( ) => "Cannot draw fast Shadow for stroke lines" ) ;
10
- var bound = path . getBounds ( ) ;
11
- if ( ! this . _applyClip ( bound ) ) {
10
+ var layer = this . _currentLayer ;
11
+ var state = layer . currentState ;
12
+
13
+ var cache = path . flatten ( state . scale * this . _devicePixelRatio ) ;
14
+ bool convex ;
15
+ var fillMesh = cache . getFillMesh ( out convex ) ;
16
+ var meshBounds = fillMesh . transform ( state . matrix ) ;
17
+ var clipBounds = layer . layerBounds ;
18
+
19
+ uiRect ? stackBounds ;
20
+ bool iior ;
21
+ layer . clipStack . getBounds ( out stackBounds , out iior ) ;
22
+
23
+ if ( stackBounds != null ) {
24
+ clipBounds = uiRectHelper . intersect ( clipBounds , stackBounds . Value ) ;
25
+ }
26
+
27
+ if ( clipBounds . isEmpty ) {
28
+ ObjectPool < uiMeshMesh > . release ( meshBounds ) ;
12
29
return ;
13
30
}
14
31
15
- var layer = this . _currentLayer ;
16
- var state = layer . currentState ;
17
- float sigma = state . scale * paint . maskFilter . Value . sigma ;
32
+ var maskBounds = meshBounds . bounds ;
33
+ maskBounds = uiRectHelper . intersect ( maskBounds , clipBounds ) ;
34
+ if ( maskBounds . isEmpty ) {
35
+ ObjectPool < uiMeshMesh > . release ( meshBounds ) ;
36
+ return ;
37
+ }
38
+
39
+ var blurMesh = ImageMeshGenerator . imageMesh ( null , uiRectHelper . one , maskBounds ) ;
40
+ if ( ! this . _applyClip ( blurMesh . bounds ) ) {
41
+ ObjectPool < uiMeshMesh > . release ( meshBounds ) ;
42
+ ObjectPool < uiMeshMesh > . release ( blurMesh ) ;
43
+ return ;
44
+ }
45
+
46
+ var bound = path . getBounds ( ) ;
47
+ var sigma = state . scale * paint . maskFilter . Value . sigma ;
18
48
19
49
var vertices = ObjectPool < uiList < Vector3 > > . alloc ( ) ;
20
50
vertices . SetCapacity ( 4 ) ;
@@ -32,6 +62,8 @@ void _drawRRectShadow(uiPath path, uiPaint paint) {
32
62
_triangles . Add ( 1 ) ;
33
63
_triangles . Add ( 3 ) ;
34
64
65
+ ObjectPool < uiMeshMesh > . release ( meshBounds ) ;
66
+ ObjectPool < uiMeshMesh > . release ( blurMesh ) ;
35
67
var mesh = uiMeshMesh . create ( state . matrix , vertices , _triangles ) ;
36
68
layer . draws . Add ( CanvasShader . fastShadow ( layer , mesh , sigma , path . isRect , path . isCircle , path . rRectCorner , new Vector4 ( bound . left , bound . top , bound . right , bound . bottom ) , paint . color ) ) ;
37
69
}
0 commit comments