Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 18 additions & 10 deletions lib/web_ui/lib/src/engine/bitmap_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,18 @@ class BitmapCanvas extends EngineCanvas {
/// DOM to render correctly.
/// - Pictures typically have large rect/rounded rectangles as background
/// prefer DOM if canvas has not been allocated yet.
///
/// Future optimization: The check below can be used to prevent excessive
/// canvas sandwiching (switching between dom and multiple canvas(s)).
/// Once RecordingCanvas is updated to detect switch count, this can be
/// enabled.
/// (_canvasPool._canvas == null &&
/// paint.maskFilter == null &&
/// paint.shader == null &&
/// paint.style != ui.PaintingStyle.stroke)
///
bool _useDomForRendering(SurfacePaintData paint) =>
_preserveImageData == false && (
_contains3dTransform ||
(_canvasPool._canvas == null &&
paint.maskFilter == null &&
paint.shader == null &&
paint.style != ui.PaintingStyle.stroke));
_preserveImageData == false && _contains3dTransform;

@override
void drawColor(ui.Color color, ui.BlendMode blendMode) {
Expand Down Expand Up @@ -488,10 +493,13 @@ class BitmapCanvas extends EngineCanvas {
html.Element svgElm = _pathToSvgElement(
surfacePath, paint, '${pathBounds.right}', '${pathBounds.bottom}');
if (!_canvasPool.isClipped) {
svgElm.style
..transform = matrix4ToCssTransform(transform)
..transformOrigin = '0 0 0'
..position = 'absolute';
html.CssStyleDeclaration style = svgElm.style;
style.position = 'absolute';
if (!transform.isIdentity()) {
style
..transform = matrix4ToCssTransform(transform)
..transformOrigin = '0 0 0';
}
}
_drawElement(svgElm, ui.Offset(0, 0), paint);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void testMain() async {
.build()
.webOnlyRootElement);

await matchGoldenFile('backdrop_filter_clip.png', region: region);
await matchGoldenFile('backdrop_filter_clip.png', region: region,
maxDiffRatePercent: 0.8);
});

test('Background should only blur at ancestor clip boundary after move', () async {
Expand Down Expand Up @@ -110,7 +111,8 @@ void testMain() async {
.build()
.webOnlyRootElement);

await matchGoldenFile('backdrop_filter_clip_moved.png', region: region);
await matchGoldenFile('backdrop_filter_clip_moved.png', region: region,
maxDiffRatePercent: 0.8);
});
}

Expand Down