Repository navigation
Commit c63648d
authored
[vector_graphics_compiler] Support SVG alpha masks (mask-type="alpha") (flutter#13025)
[vector_graphics_compiler] Support SVG alpha masks (`mask-type="alpha"`)
Fixes flutter#158734
This PR adds support for SVG alpha masks (`mask-type="alpha"` and `style="mask-type: alpha"`) in `vector_graphics_compiler`, split out from flutter/packages#11909 per review feedback.
### Summary of Changes
* **SVG Parser & AST (`vector_graphics_compiler`)**:
* Parses the `mask-type` attribute (and inline `style="mask-type: ..."` property) on `<mask>` elements in `SvgParser`.
* Propagates `isAlphaMask` through `ResolvedMaskNode` and `MaskNode`.
* Emits `BlendMode.dstIn` for alpha masks instead of `BlendMode.srcIn` with a luminance-to-alpha color filter matrix (`BlendMode.modulate`).
* **MaskingOptimizer Compatibility**:
* Updates `MaskingOptimizer` so single-path masks using gradients with translucent stops (`stop-opacity < 1.0`) are preserved rather than replaced with solid geometry intersection (which previously discarded the gradient's alpha channel).
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
TAG=agy
CONV=1bad96cc-81aa-438f-98f6-cb909289144a1 parent 3b733d2 commit c63648d
19 files changed
Lines changed: 303 additions & 11 deletions
File tree
- packages/vector_graphics_compiler
- lib/src
- svg
- test
- third_party/packages/flutter_svg/test/golden_widget
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1493 | 1493 | | |
1494 | 1494 | | |
1495 | 1495 | | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
220 | 226 | | |
221 | 227 | | |
222 | 228 | | |
| |||
228 | 234 | | |
229 | 235 | | |
230 | 236 | | |
| 237 | + | |
231 | 238 | | |
232 | 239 | | |
233 | 240 | | |
| |||
237 | 244 | | |
238 | 245 | | |
239 | 246 | | |
| 247 | + | |
240 | 248 | | |
241 | 249 | | |
242 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1094 | 1108 | | |
1095 | 1109 | | |
1096 | 1110 | | |
| |||
1597 | 1611 | | |
1598 | 1612 | | |
1599 | 1613 | | |
| 1614 | + | |
| 1615 | + | |
1600 | 1616 | | |
1601 | 1617 | | |
1602 | 1618 | | |
| |||
1778 | 1794 | | |
1779 | 1795 | | |
1780 | 1796 | | |
| 1797 | + | |
| 1798 | + | |
1781 | 1799 | | |
1782 | 1800 | | |
1783 | 1801 | | |
| |||
1807 | 1825 | | |
1808 | 1826 | | |
1809 | 1827 | | |
| 1828 | + | |
| 1829 | + | |
1810 | 1830 | | |
1811 | 1831 | | |
1812 | 1832 | | |
| |||
1962 | 1982 | | |
1963 | 1983 | | |
1964 | 1984 | | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
1965 | 1991 | | |
1966 | 1992 | | |
1967 | 1993 | | |
| |||
1992 | 2018 | | |
1993 | 2019 | | |
1994 | 2020 | | |
| 2021 | + | |
1995 | 2022 | | |
1996 | 2023 | | |
1997 | 2024 | | |
| |||
2037 | 2064 | | |
2038 | 2065 | | |
2039 | 2066 | | |
| 2067 | + | |
| 2068 | + | |
2040 | 2069 | | |
2041 | 2070 | | |
2042 | 2071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
441 | 446 | | |
442 | 447 | | |
443 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
444 | 453 | | |
445 | 454 | | |
446 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
447 | 461 | | |
448 | 462 | | |
449 | 463 | | |
| |||
454 | 468 | | |
455 | 469 | | |
456 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
457 | 474 | | |
458 | 475 | | |
459 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
168 | 172 | | |
169 | 173 | | |
170 | 174 | | |
| |||
0 commit comments