Visitar URL original
Fix opacity peephole with complex nested groups + clip (#179) · flutter/packages@b11e216 · GitHub
Skip to content

Commit b11e216

Browse files
author
Jonah Williams
authored
Fix opacity peephole with complex nested groups + clip (#179)
1 parent 093956c commit b11e216

2 files changed

Lines changed: 104 additions & 1 deletion

File tree

‎packages/vector_graphics_compiler/lib/src/svg/opacity_peephole.dart‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ class _OpacityForwarder extends Visitor<Node, _ForwardResult>
9999

100100
@override
101101
Node visitSaveLayerNode(SaveLayerNode layerNode, _ForwardResult data) {
102-
throw UnsupportedError('Cannot forward opacity through a savelayer node');
102+
final double opacity = (layerNode.paint.fill?.color.a ?? 255) / 255.0;
103+
final _ForwardResult result =
104+
_ForwardResult(data.opacity * opacity, data.blendMode);
105+
return ParentNode(SvgAttributes.empty, children: <Node>[
106+
for (Node child in layerNode.children) child.accept(this, result)
107+
]);
103108
}
104109

105110
@override

0 commit comments

Comments
 (0)