Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a49de4d

Browse files
lhkbobSkia Commit-Bot
authored andcommitted
Keep UVs consistent in degenerate quads
An earlier CL noted that the edge correction sometimes caused popping when undering extreme perspective, so I removed the edge correction thinking that it was unnecessary. Turns out that for actual degenerate quads, it is necessary. However, instead of re-determining the degenerate edge based on the local edge length, this corrects the exact same edges that had been corrected in device space. I confirmed that this seems to prevent the popping under extreme perspective and draws triangles correctly. It also avoids the coordinate scale issue that comes about when the edge tolerances had been chosen for pixel space, but many of the local coordinates being processed had already been normalized so differed by a factor of 3ish. Bug: skia:9889 Change-Id: Ida4c626aa982fe4fdac6695e2ad95e162e42fca2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269758 Reviewed-by: Brian Salomon <[email protected]> Commit-Queue: Michael Ludwig <[email protected]>
1 parent 9f0dfbd commit a49de4d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/gpu/geometry/GrQuadUtils.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,13 +936,15 @@ void TessellationHelper::Vertices::moveTo(const V4f& x2d, const V4f& y2d, const
936936
V4f e1x = skvx::shuffle<2, 3, 2, 3>(fX) - skvx::shuffle<0, 1, 0, 1>(fX);
937937
V4f e1y = skvx::shuffle<2, 3, 2, 3>(fY) - skvx::shuffle<0, 1, 0, 1>(fY);
938938
V4f e1w = skvx::shuffle<2, 3, 2, 3>(fW) - skvx::shuffle<0, 1, 0, 1>(fW);
939-
correct_bad_edges(mad(e1x, e1x, e1y * e1y) < kDist2Tolerance, &e1x, &e1y, &e1w);
939+
M4f e1Bad = mad(e1x, e1x, e1y * e1y) < kDist2Tolerance;
940+
correct_bad_edges(e1Bad, &e1x, &e1y, &e1w);
940941

941942
// // Top to bottom, in device space, for each point
942943
V4f e2x = skvx::shuffle<1, 1, 3, 3>(fX) - skvx::shuffle<0, 0, 2, 2>(fX);
943944
V4f e2y = skvx::shuffle<1, 1, 3, 3>(fY) - skvx::shuffle<0, 0, 2, 2>(fY);
944945
V4f e2w = skvx::shuffle<1, 1, 3, 3>(fW) - skvx::shuffle<0, 0, 2, 2>(fW);
945-
correct_bad_edges(mad(e2x, e2x, e2y * e2y) < kDist2Tolerance, &e2x, &e2y, &e2w);
946+
M4f e2Bad = mad(e2x, e2x, e2y * e2y) < kDist2Tolerance;
947+
correct_bad_edges(e2Bad, &e2x, &e2y, &e2w);
946948

947949
// Can only move along e1 and e2 to reach the new 2D point, so we have
948950
// x2d = (x + a*e1x + b*e2x) / (w + a*e1w + b*e2w) and
@@ -1018,10 +1020,12 @@ void TessellationHelper::Vertices::moveTo(const V4f& x2d, const V4f& y2d, const
10181020
V4f e1u = skvx::shuffle<2, 3, 2, 3>(fU) - skvx::shuffle<0, 1, 0, 1>(fU);
10191021
V4f e1v = skvx::shuffle<2, 3, 2, 3>(fV) - skvx::shuffle<0, 1, 0, 1>(fV);
10201022
V4f e1r = skvx::shuffle<2, 3, 2, 3>(fR) - skvx::shuffle<0, 1, 0, 1>(fR);
1023+
correct_bad_edges(e1Bad, &e1u, &e1v, &e1r);
10211024

10221025
V4f e2u = skvx::shuffle<1, 1, 3, 3>(fU) - skvx::shuffle<0, 0, 2, 2>(fU);
10231026
V4f e2v = skvx::shuffle<1, 1, 3, 3>(fV) - skvx::shuffle<0, 0, 2, 2>(fV);
10241027
V4f e2r = skvx::shuffle<1, 1, 3, 3>(fR) - skvx::shuffle<0, 0, 2, 2>(fR);
1028+
correct_bad_edges(e2Bad, &e2u, &e2v, &e2r);
10251029

10261030
fU += a * e1u + b * e2u;
10271031
fV += a * e1v + b * e2v;

0 commit comments

Comments
 (0)