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
11 changes: 6 additions & 5 deletions lib/web_ui/lib/src/engine/canvaskit/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,14 @@ class ImageFilterEngineLayer extends ContainerLayer

@override
void preroll(PrerollContext prerollContext, Matrix4 matrix) {
final Matrix4 transform =
(_filter as CkManagedSkImageFilterConvertible).transform;
final Matrix4 childMatrix = matrix.multiplied(transform);
prerollContext.mutatorsStack.pushTransform(transform);
final Matrix4 childMatrix = Matrix4.copy(matrix);
childMatrix.translate(_offset.dx, _offset.dy);
prerollContext.mutatorsStack
.pushTransform(Matrix4.translationValues(_offset.dx, _offset.dy, 0.0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to add a golden test if this change doesn't trigger an existing one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. PTAL

final ui.Rect childPaintBounds =
prerollChildren(prerollContext, childMatrix);
_filter.imageFilter((SkImageFilter filter) {
(_filter as CkManagedSkImageFilterConvertible)
.imageFilter((SkImageFilter filter) {
paintBounds =
rectFromSkIRect(filter.getOutputBounds(toSkRect(childPaintBounds)));
});
Expand Down
10 changes: 10 additions & 0 deletions lib/web_ui/test/ui/filters_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ Future<void> testMain() async {
await matchGoldenFile('ui_filter_matrix_imagefilter.png', region: region);
});

test('resizing matrix filter', () async {
await drawTestImageWithPaint(ui.Paint()
..imageFilter = ui.ImageFilter.matrix(
Matrix4.diagonal3Values(0.5, 0.5, 1).toFloat64(),
filterQuality: ui.FilterQuality.high,
));
await matchGoldenFile('ui_filter_matrix_imagefilter_scaled.png',
region: region);
});

test('composed filters', () async {
final ui.ImageFilter filter = ui.ImageFilter.compose(
outer: ui.ImageFilter.matrix(
Expand Down