/* OPTIMIZATION: Union doesn't need to be all-or-nothing. A run of three or more convex pathswithunionopscouldbelocallyresolvedandstillimproveoverdoingthe
ops one at a time. */
std::optional<SkPath> SkOpBuilder::resolve() { int count = fOps.size(); bool allUnion = true;
SkPathFirstDirection firstDir = SkPathFirstDirection::kUnknown; for (int index = 0; index < count; ++index) {
SkPath* test = &fPathRefs[index]; if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) {
allUnion = false; break;
} // If all paths are convex, track direction, reversing as needed. if (test->isConvex()) {
SkPathFirstDirection dir = SkPathPriv::ComputeFirstDirection(*test); if (dir == SkPathFirstDirection::kUnknown) {
allUnion = false; break;
} if (firstDir == SkPathFirstDirection::kUnknown) {
firstDir = dir;
} elseif (firstDir != dir) {
ReversePath(test);
} continue;
} // If the path is not convex but its bounds do not intersect the others, simplify is enough. const SkRect& testBounds = test->getBounds(); for (int inner = 0; inner < index; ++inner) { // OPTIMIZE: check to see if the contour bounds do not intersect other contour bounds? if (SkRect::Intersects(fPathRefs[inner].getBounds(), testBounds)) {
allUnion = false; break;
}
}
} if (!allUnion) {
SkPath result = fPathRefs[0]; for (int index = 1; index < count; ++index) { if (auto res = Op(result, fPathRefs[index], fOps[index])) {
result = *res;
} else {
reset(); return {};
}
}
reset(); return result;
}
SkPathBuilder sum; for (int index = 0; index < count; ++index) { auto result = Simplify(fPathRefs[index]); if (!result.has_value()) {
reset(); return {};
}
fPathRefs[index] = *result; if (!fPathRefs[index].isEmpty()) { // convert the even odd result back to winding form before accumulating it if (!FixWinding(&fPathRefs[index])) { return {};
}
sum.addPath(fPathRefs[index]);
}
}
reset();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.