Skip to content

Commit

Permalink
Revert "fix: mask disappeared when having nested mask filter on Flutt…
Browse files Browse the repository at this point in the history
…er web HTML (#45166)"

This reverts commit c90aa9a.
  • Loading branch information
auto-submit[bot] committed Jul 4, 2024
1 parent afc1898 commit 5bba744
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 47 deletions.
28 changes: 13 additions & 15 deletions lib/web_ui/lib/src/engine/canvas_pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,6 @@ class ContextStateHandle {
}

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

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

final ui.MaskFilter? maskFilter = paint.maskFilter;
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.
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) {
context.save();
context.shadowBlur = convertSigmaToRadius(maskFilter.webOnlySigma);
// Shadow color must be fully opaque.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,38 +150,6 @@ Future<void> testMain() async {
await canvasScreenshot(rc, 'mask_filter_transformed_$browser',
region: screenRect);
});

test('multiple MaskFilter.blur in $browser', () async {
const double screenWidth = 300.0;
const double screenHeight = 300.0;
const ui.Rect screenRect =
ui.Rect.fromLTWH(0, 0, screenWidth, screenHeight);

ContextStateHandle.debugEmulateWebKitMaskFilter = isWebkit;
final RecordingCanvas rc = RecordingCanvas(screenRect);

final SurfacePaint paint = SurfacePaint()
..maskFilter = const ui.MaskFilter.blur(ui.BlurStyle.normal, 5);
rc.save();
rc.drawCircle(const ui.Offset(150, 150), 100,
paint..color = const ui.Color(0xFFC8C800));
rc.restore();
rc.save();
rc.drawCircle(const ui.Offset(150, 150), 50,
paint..color = const ui.Color(0xFFC800C8));
rc.restore();
rc.save();
rc.drawCircle(
const ui.Offset(150, 150),
20,
paint
..color = const ui.Color(0xFF00C8C8)
..maskFilter = const ui.MaskFilter.blur(ui.BlurStyle.normal, 10));
rc.restore();

await canvasScreenshot(rc, 'multiple_mask_filter_$browser',
region: screenRect);
});
}

testMaskFilterBlur();
Expand Down

0 comments on commit 5bba744

Please sign in to comment.