Skip to content

Commit 9a75d67

Browse files
committed
Blend Modes #2
1 parent 620881e commit 9a75d67

File tree

1 file changed

+36
-28
lines changed

1 file changed

+36
-28
lines changed

lib/src/transformers/node_transformers/passive_rectangle_transformer.dart

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ List<Widget> buildFills(
588588
// blendmodes in the correct order to this fill.
589589
Widget fill = buildFill(
590590
node,
591-
index: node.fills.indexOf(model),
591+
index: i,
592592
imageBytes: imageBytes,
593593
imageOpacity: imageOpacity,
594594
imageRotation: imageRotation,
@@ -599,31 +599,38 @@ List<Widget> buildFills(
599599
scopedValues: scopedValues,
600600
);
601601

602-
// for (final MapEntry(key: i, value: paint)
603-
// in lastBlendTree.entries.toList().reversed) {
604-
// // fill = BlendMask(
605-
// // model: paint,
606-
// // image: null,
607-
// // child: fill,
608-
// // );
609-
// fill = Stack(
610-
// children: [
611-
// fill,
612-
// Positioned.fill(
613-
// child: PaintBlendMask(
614-
// model: paint,
615-
// image: null,
616-
// child: buildFill(
617-
// node,
618-
// index: i,
619-
// settings: settings,
620-
// scopedValues: scopedValues,
621-
// ),
622-
// ),
623-
// ),
624-
// ],
625-
// );
626-
// }
602+
// fill = BlendMask(
603+
// model: paint,
604+
// image: null,
605+
// child: fill,
606+
// );
607+
fill = Stack(
608+
fit: StackFit.expand,
609+
children: [
610+
fill,
611+
for (final MapEntry(key: i, value: paint)
612+
in lastBlendTree.entries.toList().reversed)
613+
if (paint.visible)
614+
Positioned.fill(
615+
child: PaintBlendMask(
616+
model: paint,
617+
image: null,
618+
child: buildFill(
619+
node,
620+
index: i,
621+
imageBytes: imageBytes,
622+
imageOpacity: imageOpacity,
623+
imageRotation: imageRotation,
624+
imageFillBuilder: imageFillBuilder,
625+
useInk: useInk,
626+
obscureImages: obscureImages,
627+
settings: settings,
628+
scopedValues: scopedValues,
629+
),
630+
),
631+
),
632+
],
633+
);
627634

628635
lastBlendTree.clear();
629636
raster.add(wrapFillWithPositioned(
@@ -905,8 +912,8 @@ class RenderPaintBlendMask extends RenderProxyBox {
905912

906913
Paint makePaint(Rect bounds) {
907914
Paint paint = Paint()..blendMode = _model.blendMode.flutterBlendMode;
908-
paint.color = Colors.white;
909-
return paint;
915+
// paint.color = Colors.white;
916+
// return paint;
910917

911918
switch (_model.type) {
912919
case PaintType.solid:
@@ -937,6 +944,7 @@ class RenderPaintBlendMask extends RenderProxyBox {
937944

938945
@override
939946
void paint(context, offset) {
947+
// Complex blend modes can be raster cached incorrectly on the Skia backend.
940948
context.setWillChangeHint();
941949
context.canvas.saveLayer(
942950
offset & size,

0 commit comments

Comments
 (0)