Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 759553f

Browse files
committed
fix: mask disappeared when having nested mask filter on Flutter web HTML
1 parent 224367a commit 759553f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

lib/web_ui/lib/src/engine/canvas_pool.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ class ContextStateHandle {
934934
}
935935

936936
ui.MaskFilter? _currentFilter;
937+
String? _currentFilterCss;
937938
SurfacePaintData? _lastUsedPaint;
938939

939940
/// Currently active shader bounds.
@@ -1003,19 +1004,20 @@ class ContextStateHandle {
10031004
}
10041005

10051006
final ui.MaskFilter? maskFilter = paint.maskFilter;
1006-
if (!_renderMaskFilterForWebkit) {
1007-
if (_currentFilter != maskFilter) {
1008-
_currentFilter = maskFilter;
1009-
context.filter = maskFilterToCanvasFilter(maskFilter);
1010-
}
1011-
} else {
1012-
// WebKit does not support the `filter` property. Instead we apply a
1013-
// shadow to the shape of the same color as the paint and the same blur
1014-
// as the mask filter.
1015-
//
1016-
// Note that on WebKit the cached value of _currentFilter is not useful.
1017-
// Instead we destructure it into the shadow properties and cache those.
1018-
if (maskFilter != null) {
1007+
if (maskFilter != null) {
1008+
if (!_renderMaskFilterForWebkit) {
1009+
if (_currentFilter != maskFilter) {
1010+
_currentFilter = maskFilter;
1011+
_currentFilterCss = maskFilterToCanvasFilter(maskFilter);
1012+
}
1013+
context.filter = _currentFilterCss;
1014+
} else {
1015+
// WebKit does not support the `filter` property. Instead we apply a
1016+
// shadow to the shape of the same color as the paint and the same blur
1017+
// as the mask filter.
1018+
//
1019+
// Note that on WebKit the cached value of _currentFilter is not useful.
1020+
// Instead we destructure it into the shadow properties and cache those.
10191021
context.save();
10201022
context.shadowBlur = convertSigmaToRadius(maskFilter.webOnlySigma);
10211023
// Shadow color must be fully opaque.

0 commit comments

Comments
 (0)