@@ -23,9 +23,11 @@ void main() {
2323 }
2424 });
2525
26- test ('Basic case of two opaque shapes overlapping' , () async {
27- final Node node = await parseAndResolve (basicOverlap);
28- final VectorInstructions instructions = await parse (basicOverlap);
26+ test (
27+ 'Basic case of two opaque shapes overlapping with a stroke (cannot be optimized yet)' ,
28+ () async {
29+ final Node node = await parseAndResolve (basicOverlapWithStroke);
30+ final VectorInstructions instructions = await parse (basicOverlapWithStroke);
2931
3032 final List <ResolvedPathNode > pathNodesOld =
3133 queryChildren <ResolvedPathNode >(node);
@@ -41,7 +43,7 @@ void main() {
4143 expect (instructions.paints, const < Paint > [
4244 Paint (
4345 blendMode: BlendMode .srcOver,
44- stroke: Stroke (color: Color (0xff000000 ), width : 0.0 ),
46+ stroke: Stroke (color: Color (0xff008000 ) ),
4547 fill: Fill (color: Color (0xffff0000 ))),
4648 Paint (blendMode: BlendMode .srcOver, fill: Fill (color: Color (0xff0000ff )))
4749 ]);
@@ -68,6 +70,55 @@ void main() {
6870 ]);
6971 });
7072
73+ test ('Basic case of two opaque shapes overlapping' , () async {
74+ final Node node = await parseAndResolve (basicOverlap);
75+ final VectorInstructions instructions = await parse (basicOverlap);
76+
77+ final List <ResolvedPathNode > pathNodesOld =
78+ queryChildren <ResolvedPathNode >(node);
79+
80+ final OverdrawOptimizer visitor = OverdrawOptimizer ();
81+ final Node newNode = visitor.apply (node);
82+
83+ final List <ResolvedPathNode > pathNodesNew =
84+ queryChildren <ResolvedPathNode >(newNode);
85+
86+ expect (pathNodesOld.length, pathNodesNew.length);
87+
88+ expect (instructions.paints, const < Paint > [
89+ Paint (blendMode: BlendMode .srcOver, fill: Fill (color: Color (0xffff0000 ))),
90+ Paint (blendMode: BlendMode .srcOver, fill: Fill (color: Color (0xff0000ff )))
91+ ]);
92+
93+ expect (instructions.paths, < Path > [
94+ Path (
95+ commands: const < PathCommand > [
96+ MoveToCommand (367.0 , 221.5 ),
97+ LineToCommand (99.0 , 221.5 ),
98+ LineToCommand (99.0 , 316.5 ),
99+ LineToCommand (367.0 , 316.5 ),
100+ LineToCommand (367.0 , 221.5 ),
101+ CloseCommand (),
102+ MoveToCommand (448.0 , 221.5 ),
103+ LineToCommand (448.0 , 316.5 ),
104+ LineToCommand (692.0 , 316.5 ),
105+ LineToCommand (692.0 , 221.5 ),
106+ LineToCommand (448.0 , 221.5 ),
107+ CloseCommand ()
108+ ],
109+ ),
110+ Path (
111+ commands: const < PathCommand > [
112+ MoveToCommand (367.0 , 41.50001 ),
113+ LineToCommand (448.0 , 41.50001 ),
114+ LineToCommand (448.0 , 527.49999 ),
115+ LineToCommand (367.0 , 527.49999 ),
116+ CloseCommand ()
117+ ],
118+ )
119+ ]);
120+ });
121+
71122 test ('Basic case of two shapes with opacity < 1.0 overlapping' , () async {
72123 final Node node = await parseAndResolve (opacityOverlap);
73124 final VectorInstructions instructions = await parse (opacityOverlap);
0 commit comments