-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
Right now it's using kUnpremul_SkAlphaType, which is resulting in darker anti-aliasing around edges, e.g. compare the square on bottom to the one on top:
They're made form the same picture drawn like this:
Future<List<ui.Image>> drawImage() async {
var recorder = ui.PictureRecorder();
var canvas = ui.Canvas(recorder);
canvas.drawRect(ui.Rect.fromLTWH(20, 20, 100, 100),
ui.Paint()..color = ui.Color(0xFFFF6D00));
var picture = recorder.endRecording();
var toImageImage = await picture.toImage(200, 200);
var toImageSyncImage = picture.toImageSync(200, 200);
return [toImageImage, toImageSyncImage];
}The toImage image is on top, the toImageSync image is on bottom. Changing https://github.com/flutter/engine/blob/5f92d3668c7a172be23df13eebd24ab7e7df29ee/lib/ui/painting/picture.cc#L71 to kPremul_SkAlphaType seems to fix this, but probably deserves to be tested to make sure it works - Im' pretty sure I tried unpremul at one point to try to get Linux to be happy, before finally just putting Linux on the software path for now.
@jonahwilliams fyi. If you don't get to this first, I'll pick it up when I come back next week. We may want a golden test that asserts the bytes are the same between these calls.
