Skip to content

Commit

Permalink
Revert "Use the new pushImageFilter offset parameter to fix the trans…
Browse files Browse the repository at this point in the history
…form of the children (#113673)" (#115861)

This reverts commit 91aeda7.
  • Loading branch information
jonahwilliams authored Nov 22, 2022
1 parent 91aeda7 commit 9bb07b5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 61 deletions.
4 changes: 1 addition & 3 deletions packages/flutter/lib/src/rendering/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1816,14 +1816,13 @@ class ColorFilterLayer extends ContainerLayer {
}

/// A composite layer that applies an [ImageFilter] to its children.
class ImageFilterLayer extends OffsetLayer {
class ImageFilterLayer extends ContainerLayer {
/// Creates a layer that applies an [ImageFilter] to its children.
///
/// The [imageFilter] property must be non-null before the compositing phase
/// of the pipeline.
ImageFilterLayer({
ui.ImageFilter? imageFilter,
super.offset,
}) : _imageFilter = imageFilter;

/// The image filter to apply to children.
Expand All @@ -1845,7 +1844,6 @@ class ImageFilterLayer extends OffsetLayer {
assert(imageFilter != null);
engineLayer = builder.pushImageFilter(
imageFilter!,
offset: offset,
oldLayer: _engineLayer as ui.ImageFilterEngineLayer?,
);
addChildrenToScene(builder);
Expand Down
5 changes: 2 additions & 3 deletions packages/flutter/lib/src/widgets/image_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ class _ImageFilterRenderObject extends RenderProxyBox {
}

if (layer == null) {
layer = ImageFilterLayer(imageFilter: imageFilter, offset: offset);
layer = ImageFilterLayer(imageFilter: imageFilter);
} else {
final ImageFilterLayer filterLayer = layer! as ImageFilterLayer;
filterLayer.imageFilter = imageFilter;
filterLayer.offset = offset;
}
context.pushLayer(layer!, super.paint, Offset.zero);
context.pushLayer(layer!, super.paint, offset);
assert(() {
layer!.debugCreator = debugCreator;
return true;
Expand Down
55 changes: 0 additions & 55 deletions packages/flutter/test/widgets/image_filter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// machines.
@Tags(<String>['reduced-test-set'])

import 'dart:math';
import 'dart:ui';

import 'package:flutter/foundation.dart';
Expand All @@ -30,24 +29,6 @@ void main() {
);
});

testWidgets('Image filter - blur with offset', (WidgetTester tester) async {
await tester.pumpWidget(
RepaintBoundary(
child: Transform.translate(
offset: const Offset(50, 50),
child: ImageFiltered(
imageFilter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
child: const Placeholder(),
),
),
),
);
await expectLater(
find.byType(ImageFiltered),
matchesGoldenFile('image_filter_blur_offset.png'),
);
});

testWidgets('Image filter - dilate', (WidgetTester tester) async {
await tester.pumpWidget(
RepaintBoundary(
Expand Down Expand Up @@ -116,42 +97,6 @@ void main() {
);
});

testWidgets('Image filter - matrix with offset', (WidgetTester tester) async {
final Matrix4 matrix = Matrix4.rotationZ(pi / 18);
final ImageFilter matrixFilter = ImageFilter.matrix(matrix.storage);
await tester.pumpWidget(
RepaintBoundary(
child: Transform.translate(
offset: const Offset(50, 50),
child: ImageFiltered(
imageFilter: matrixFilter,
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: Scaffold(
appBar: AppBar(
title: const Text('Matrix ImageFilter Test'),
),
body: const Center(
child:Text('Hooray!'),
),
floatingActionButton: FloatingActionButton(
onPressed: () { },
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
),
),
),
),
);
await expectLater(
find.byType(ImageFiltered),
matchesGoldenFile('image_filter_matrix_offset.png'),
);
});

testWidgets('Image filter - reuses its layer', (WidgetTester tester) async {
Future<void> pumpWithSigma(double sigma) async {
await tester.pumpWidget(
Expand Down

0 comments on commit 9bb07b5

Please sign in to comment.