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

Commit d2376e4

Browse files
Kingtous金韬
authored and
金韬
committed
fix: mask disappeared when having nested mask filter on Flutter web HTML
1 parent 351a7ca commit d2376e4

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
@@ -936,6 +936,7 @@ class ContextStateHandle {
936936
}
937937

938938
ui.MaskFilter? _currentFilter;
939+
String? _currentFilterCss;
939940
SurfacePaintData? _lastUsedPaint;
940941

941942
/// Currently active shader bounds.
@@ -1005,19 +1006,20 @@ class ContextStateHandle {
10051006
}
10061007

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

0 commit comments

Comments
 (0)