Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: mask disappeared when having nested mask filter on Flutter web HTML
  • Loading branch information
Kingtous committed Feb 16, 2024
commit 759553f1669d09e4ce859663aab2f34a69e66177
28 changes: 15 additions & 13 deletions lib/web_ui/lib/src/engine/canvas_pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ class ContextStateHandle {
}

ui.MaskFilter? _currentFilter;
String? _currentFilterCss;
SurfacePaintData? _lastUsedPaint;

/// Currently active shader bounds.
Expand Down Expand Up @@ -1003,19 +1004,20 @@ class ContextStateHandle {
}

final ui.MaskFilter? maskFilter = paint.maskFilter;
if (!_renderMaskFilterForWebkit) {
if (_currentFilter != maskFilter) {
_currentFilter = maskFilter;
context.filter = maskFilterToCanvasFilter(maskFilter);
}
} else {
// WebKit does not support the `filter` property. Instead we apply a
// shadow to the shape of the same color as the paint and the same blur
// as the mask filter.
//
// Note that on WebKit the cached value of _currentFilter is not useful.
// Instead we destructure it into the shadow properties and cache those.
if (maskFilter != null) {
if (maskFilter != null) {
if (!_renderMaskFilterForWebkit) {
if (_currentFilter != maskFilter) {
_currentFilter = maskFilter;
_currentFilterCss = maskFilterToCanvasFilter(maskFilter);
}
context.filter = _currentFilterCss;
} else {
// WebKit does not support the `filter` property. Instead we apply a
// shadow to the shape of the same color as the paint and the same blur
// as the mask filter.
//
// Note that on WebKit the cached value of _currentFilter is not useful.
// Instead we destructure it into the shadow properties and cache those.
context.save();
context.shadowBlur = convertSigmaToRadius(maskFilter.webOnlySigma);
// Shadow color must be fully opaque.
Expand Down