Skip to content

Commit

Permalink
Minor cleanups in SkEdgeBuilder
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Kaylee Lubick <[email protected]>
Auto-Submit: Kaylee Lubick <[email protected]>
Reviewed-by: Daniel Dilan <[email protected]>
  • Loading branch information
kjlubick authored and SkCQ committed Feb 6, 2025
1 parent 87bf7d9 commit e10e218
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions src/core/SkEdgeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e10e218

Please sign in to comment.