From e10e218aa288bf6feb731e795b231643034f3a9b Mon Sep 17 00:00:00 2001 From: Kaylee Lubick Date: Thu, 6 Feb 2025 15:08:00 -0500 Subject: [PATCH] Minor cleanups in SkEdgeBuilder This removes one layer of indentation and moves locals a bit closer to where they are actually used. The compiler probably already hoisted the two arrays, but this makes the source code reflect that. Change-Id: I68e82c6a8f1cc13dc869c19c0609cbb94637f8b0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/948179 Commit-Queue: Daniel Dilan Commit-Queue: Kaylee Lubick Auto-Submit: Kaylee Lubick Reviewed-by: Daniel Dilan --- src/core/SkEdgeBuilder.cpp | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/core/SkEdgeBuilder.cpp b/src/core/SkEdgeBuilder.cpp index 0be077b88a64..64287e9c7f27 100644 --- a/src/core/SkEdgeBuilder.cpp +++ b/src/core/SkEdgeBuilder.cpp @@ -301,10 +301,6 @@ int SkEdgeBuilder::buildPoly(const SkPath& path, const SkIRect* iclip, bool canC } int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip, bool canCullToTheRight) { - SkAutoConicToQuads quadder; - const SkScalar conicTol = SK_Scalar1 / 4; - bool is_finite = true; - SkPathEdgeIter iter(path); if (iclip) { SkRect clip = this->recoverClip(*iclip); @@ -333,45 +329,49 @@ int SkEdgeBuilder::build(const SkPath& path, const SkIRect* iclip, bool canCullT } } }, &rec); - is_finite = rec.fIsFinite; - } else { - auto handle_quad = [this](const SkPoint pts[3]) { - SkPoint monoX[5]; - int n = SkChopQuadAtYExtrema(pts, monoX); - for (int i = 0; i <= n; i++) { - this->addQuad(&monoX[i * 2]); + fEdgeList = fList.begin(); + return rec.fIsFinite ? fList.size() : 0; + } + + SkAutoConicToQuads quadder; + constexpr float kConicTol = 0.25f; + SkPoint monoY[10]; + SkPoint monoX[5]; + auto handle_quad = [this, &monoX](const SkPoint pts[3]) { + int n = SkChopQuadAtYExtrema(pts, monoX); + for (int i = 0; i <= n; i++) { + this->addQuad(&monoX[i * 2]); + } + }; + + while (auto e = iter.next()) { + switch (e.fEdge) { + case SkPathEdgeIter::Edge::kLine: + this->addLine(e.fPts); + break; + case SkPathEdgeIter::Edge::kQuad: { + handle_quad(e.fPts); + break; } - }; - while (auto e = iter.next()) { - switch (e.fEdge) { - case SkPathEdgeIter::Edge::kLine: - this->addLine(e.fPts); - break; - case SkPathEdgeIter::Edge::kQuad: { - handle_quad(e.fPts); - break; + case SkPathEdgeIter::Edge::kConic: { + const SkPoint* quadPts = + quadder.computeQuads(e.fPts, iter.conicWeight(), kConicTol); + for (int i = 0; i < quadder.countQuads(); ++i) { + handle_quad(quadPts); + quadPts += 2; } - case SkPathEdgeIter::Edge::kConic: { - const SkPoint* quadPts = quadder.computeQuads( - e.fPts, iter.conicWeight(), conicTol); - for (int i = 0; i < quadder.countQuads(); ++i) { - handle_quad(quadPts); - quadPts += 2; - } - } break; - case SkPathEdgeIter::Edge::kCubic: { - SkPoint monoY[10]; - int n = SkChopCubicAtYExtrema(e.fPts, monoY); - for (int i = 0; i <= n; i++) { - this->addCubic(&monoY[i * 3]); - } - break; + } break; + case SkPathEdgeIter::Edge::kCubic: { + int n = SkChopCubicAtYExtrema(e.fPts, monoY); + for (int i = 0; i <= n; i++) { + this->addCubic(&monoY[i * 3]); } + break; } } } fEdgeList = fList.begin(); - return is_finite ? fList.size() : 0; + return fList.size(); } int SkEdgeBuilder::buildEdges(const SkPath& path,