/* OPTIMIZATION: Union doesn't need to be all-or-nothing. A run of three or more convex paths with union ops could be locally resolved and still improve over doing the
ops one at a time. */ bool SkOpBuilder::resolve(SkPath* result) {
SkPath original = *result; 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) {
*result = fPathRefs[0]; for (int index = 1; index < count; ++index) { if (!Op(*result, fPathRefs[index], fOps[index], result)) {
reset();
*result = original; returnfalse;
}
}
reset(); returntrue;
}
SkPath sum; for (int index = 0; index < count; ++index) { if (!Simplify(fPathRefs[index], &fPathRefs[index])) {
reset();
*result = original; returnfalse;
} if (!fPathRefs[index].isEmpty()) { // convert the even odd result back to winding form before accumulating it if (!FixWinding(&fPathRefs[index])) {
*result = original; returnfalse;
}
sum.addPath(fPathRefs[index]);
}
}
reset(); bool success = Simplify(sum, result); if (!success) {
*result = original;
} return success;
}
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.