Skip to content

Commit

Permalink
Update the golden image comparator to handle read-only image ByteData…
Browse files Browse the repository at this point in the history
… views

The engine is now wrapping image byte data in an UnmodifiableByteDataView
(see flutter/engine#19504).  The golden image
comparator must make a copy before modifying the buffer.
  • Loading branch information
jason-simmons committed Jul 14, 2020
1 parent bb32808 commit 11e5d3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/flutter_test/lib/src/_goldens_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ Future<ComparisonResult> compareLists(List<int> test, List<int> master) async {
final ByteData invertedMasterRgba = _invert(masterImageRgba);
final ByteData invertedTestRgba = _invert(testImageRgba);

final ByteData maskedDiffRgba = await testImage.toByteData();
final Uint8List testImageBytes = (await testImage.toByteData()).buffer.asUint8List();
final ByteData maskedDiffRgba = ByteData(testImageBytes.length);
maskedDiffRgba.buffer.asUint8List().setRange(0, testImageBytes.length, testImageBytes);
final ByteData isolatedDiffRgba = ByteData(width * height * 4);

for (int x = 0; x < width; x++) {
Expand Down

0 comments on commit 11e5d3d

Please sign in to comment.