Reduce quick switch layout churn and flatten planar depth transforms
This commit is contained in:
@@ -18,18 +18,34 @@ class QuickSwitchPose {
|
||||
final Offset translation;
|
||||
final double scale, rotationX, rotationY, rotationZ, depth, opacity, shadow;
|
||||
|
||||
Matrix4 transform(Size size) => Matrix4.identity()
|
||||
..setEntry(3, 2, rotationX != 0 || rotationY != 0 || depth != 0 ? .0012 : 0)
|
||||
..translateByDouble(
|
||||
translation.dx * size.width,
|
||||
translation.dy * size.height,
|
||||
depth,
|
||||
1,
|
||||
)
|
||||
..rotateX(rotationX)
|
||||
..rotateY(rotationY)
|
||||
..rotateZ(rotationZ)
|
||||
..scaleByDouble(scale, scale, scale, 1);
|
||||
Matrix4 transform(Size size) {
|
||||
// A flat card at constant depth projects to a uniform 2D scale. Keep it
|
||||
// affine so backdrop filters do not enter the renderer's 3D path.
|
||||
if (rotationX == 0 && rotationY == 0) {
|
||||
final projection = 1 / (1 + .0012 * depth);
|
||||
return Matrix4.identity()
|
||||
..translateByDouble(
|
||||
translation.dx * size.width * projection,
|
||||
translation.dy * size.height * projection,
|
||||
0,
|
||||
1,
|
||||
)
|
||||
..rotateZ(rotationZ)
|
||||
..scaleByDouble(scale * projection, scale * projection, 1, 1);
|
||||
}
|
||||
return Matrix4.identity()
|
||||
..setEntry(3, 2, .0012)
|
||||
..translateByDouble(
|
||||
translation.dx * size.width,
|
||||
translation.dy * size.height,
|
||||
depth,
|
||||
1,
|
||||
)
|
||||
..rotateX(rotationX)
|
||||
..rotateY(rotationY)
|
||||
..rotateZ(rotationZ)
|
||||
..scaleByDouble(scale, scale, scale, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool quickSwitchOutgoingOnTop(QuickSwitchAnimation style, double progress) =>
|
||||
|
||||
Reference in New Issue
Block a user