Skip unnecessary moveTo in degenerate quad calculations
Change-Id: If73951f8e183101b80f729d9533cc3c8395b1879
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252481
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/geometry/GrQuadUtils.cpp b/src/gpu/geometry/GrQuadUtils.cpp
index 424c7e8..62d2d7e 100644
--- a/src/gpu/geometry/GrQuadUtils.cpp
+++ b/src/gpu/geometry/GrQuadUtils.cpp
@@ -644,7 +644,8 @@
}
V4f TessellationHelper::computeDegenerateQuad(const V4f& signedEdgeDistances,
- const EdgeEquations& edges, Vertices* quad) {
+ const EdgeEquations& edges,
+ V4f* x2d, V4f* y2d) {
// Move the edge by the signed edge adjustment.
V4f oc = edges.fC + signedEdgeDistances;
@@ -686,8 +687,8 @@
// A point failed against two edges, so reduce the shape to a single point, which we take as
// the center of the original quad to ensure it is contained in the intended geometry. Since
// it has collapsed, we know the shape cannot cover a pixel so update the coverage.
- SkPoint center = {0.25f * (quad->fX[0] + quad->fX[1] + quad->fX[2] + quad->fX[3]),
- 0.25f * (quad->fY[0] + quad->fY[1] + quad->fY[2] + quad->fY[3])};
+ SkPoint center = {0.25f * ((*x2d)[0] + (*x2d)[1] + (*x2d)[2] + (*x2d)[3]),
+ 0.25f * ((*y2d)[0] + (*y2d)[1] + (*y2d)[2] + (*y2d)[3])};
px = center.fX;
py = center.fY;
coverage = getDegenerateCoverage(px, py, edges);
@@ -727,7 +728,8 @@
coverage = 1.f;
}
- quad->moveTo(px, py, signedEdgeDistances != 0.f);
+ *x2d = px;
+ *y2d = py;
return coverage;
}
@@ -749,7 +751,8 @@
if (inset) {
signedEdgeDistances *= -1.f;
}
- coverage = computeDegenerateQuad(signedEdgeDistances, *edgeEquations, &projected);
+ coverage = computeDegenerateQuad(signedEdgeDistances, *edgeEquations,
+ &projected.fX, &projected.fY);
} else {
// Move the projected quad with the fast path, even though we will reconstruct the
// perspective corners afterwards.
diff --git a/src/gpu/geometry/GrQuadUtils.h b/src/gpu/geometry/GrQuadUtils.h
index a99af9e..b8b047f 100644
--- a/src/gpu/geometry/GrQuadUtils.h
+++ b/src/gpu/geometry/GrQuadUtils.h
@@ -135,11 +135,13 @@
static skvx::Vec<4, float> getDegenerateCoverage(const skvx::Vec<4, float>& px,
const skvx::Vec<4, float>& py,
const EdgeEquations& edges);
- // Outsets or insets 'vertices' in place. To be used when the interior is very small, edges
- // are near parallel, or edges are very short/zero-length. Returns coverage for each vertex.
+ // Outsets or insets 'x2d' and 'y2d' in place. To be used when the interior is very small,
+ // edges are near parallel, or edges are very short/zero-length. Returns coverage for each
+ // vertex.
skvx::Vec<4, float> computeDegenerateQuad(const skvx::Vec<4, float>& signedEdgeDistances,
const EdgeEquations& edges,
- Vertices* vertices);
+ skvx::Vec<4, float>* x2d,
+ skvx::Vec<4, float>* y2d);
// Outsets or insets 'vertices' based on the outset request described by 'outsetRequest'
// and 'inset' (true for insetting instead). If the outset is not degenerate,
// 'edgeEquations' can be null. Returns coverage for each vertex.