-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
RenderAnimatedOpacityMixin has the following paint method, which avoids painting both the child widget and the opacity later when fully transparent. When fully opaque, the opacity layer is elided while the child is painted. Unfortunately this last optimization causes obvious pixel snapping on low DPR screens.
RenderAnimatedOpacityMixin.paint
@override
void paint(PaintingContext context, Offset offset) {
if (child != null) {
if (_alpha == 0) {
// No need to keep the layer. We'll create a new one if necessary.
layer = null;
return;
}
if (_alpha == 255) {
// No need to keep the layer. We'll create a new one if necessary.
layer = null;
context.paintChild(child!, offset);
return;
}
assert(needsCompositing);
layer = context.pushOpacity(offset, _alpha!, super.paint, oldLayer: layer as OpacityLayer?);
}
}This can be seen fairly easily when a mouse hover first reveals a tooltip, such as in the "example app" section of the flutter gallery. The last frame visible shifts - fairly dramatically compared to the previous animation. Though the video below uses 10x time dilation to make it more obvious, it is still hard to see in the low res/low framerate GIF.
Keeping the opacity layer even when at fully opaque removes this jump.
