Repository navigation
Set AA flag for painting images #51656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b35bdde
1948bf6
a35584d
ea2fbe5
09fe50c
bb108d0
7385916
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:math' as math; | ||
| import 'dart:typed_data'; | ||
| import 'dart:ui' as ui; | ||
|
|
||
|
|
@@ -1620,6 +1621,63 @@ void main() { | |
|
|
||
| expect(tester.takeException(), 'threw'); | ||
| }); | ||
|
|
||
| Future<void> _testRotatedImage(WidgetTester tester, bool isAntiAlias) async { | ||
| final Key key = UniqueKey(); | ||
| await tester.pumpWidget(RepaintBoundary( | ||
| key: key, | ||
| child: Transform.rotate( | ||
| angle: math.pi / 180, | ||
| child: Image.memory(Uint8List.fromList(kBlueRectPng), isAntiAlias: isAntiAlias), | ||
| ), | ||
| )); | ||
|
|
||
| // precacheImage is needed, or the image in the golden file will be empty. | ||
| if (!kIsWeb) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you instead just skip the test for the browser with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do still want the most of this test to run on web to see how it behaves. The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok! Can we still reference an issue here for the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| final Finder allImages = find.byType(Image); | ||
| for (final Element e in allImages.evaluate()) { | ||
| await tester.runAsync(() async { | ||
| final Image image = e.widget as Image; | ||
| await precacheImage(image.image, e); | ||
| }); | ||
| } | ||
| await tester.pumpAndSettle(); | ||
| } | ||
|
|
||
| await expectLater( | ||
| find.byKey(key), | ||
| matchesGoldenFile('rotated_image_${isAntiAlias ? 'aa' : 'noaa'}.png'), | ||
| ); | ||
| } | ||
|
|
||
| testWidgets( | ||
| 'Rotated images', | ||
| (WidgetTester tester) async { | ||
| await _testRotatedImage(tester, true); | ||
| await _testRotatedImage(tester, false); | ||
| }, | ||
| // TODO(hterkelson): figure out why web timed out with `await precacheImage` | ||
| // so we can enable this test on web. | ||
| // | ||
| // See https://github.com/flutter/flutter/issues/54292. | ||
| skip: kIsWeb, | ||
| ); | ||
| } | ||
|
|
||
| class ImagePainter extends CustomPainter { | ||
| ImagePainter(this.image); | ||
|
|
||
| @override | ||
| void paint(ui.Canvas canvas, ui.Size size) { | ||
| canvas.drawImage(image, Offset.zero, Paint()); | ||
| } | ||
|
|
||
| @override | ||
| bool shouldRepaint(CustomPainter oldDelegate) { | ||
| return false; | ||
| } | ||
|
|
||
| final ui.Image image; | ||
| } | ||
|
|
||
| class ConfigurationAwareKey { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we assert this isn't
null? Here and below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.