/* * Copyright 2009 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
#ifdef NEWTON_RAPHSON // Quadratic convergence, typically <= 3 iterations. // Initial guess. // TODO(turk): Check for zero denominator? Shouldn't happen unless the curve // is not only monotonic but degenerate.
SkScalar t1 = ycrv[0] / (ycrv[0] - ycrv[3]);
// The result might be valid, even if outside of the range [0, 1], but // we never evaluate a Bezier outside this interval, so we return false. if (t1 < 0 || t1 > SK_Scalar1) returnfalse; // This shouldn't happen, but check anyway. return converged;
#else// BISECTION // Linear convergence, typically 16 iterations.
// Check that the endpoints straddle zero.
SkScalar tNeg, tPos; // Negative and positive function parameters. if (ycrv[0] < 0) { if (ycrv[3] < 0) returnfalse;
tNeg = 0;
tPos = SK_Scalar1;
} elseif (ycrv[0] > 0) { if (ycrv[3] > 0) returnfalse;
tNeg = SK_Scalar1;
tPos = 0;
} else {
*t = 0; returntrue;
}
// we need the data to be monotonically descending in Y if (srcPts[0].fY > srcPts[3].fY) {
dst[0] = srcPts[3];
dst[1] = srcPts[2];
dst[2] = srcPts[1];
dst[3] = srcPts[0];
reverse = true;
} else {
memcpy(dst, srcPts, 4 * sizeof(SkPoint));
reverse = false;
}
// are we completely above or below const SkScalar ctop = fClip.fTop; const SkScalar cbot = fClip.fBottom; if (dst[3].fY <= ctop || dst[0].fY >= cbot) { returnfalse;
}
SkScalar t;
SkPoint tmp[7]; // for SkChopCubicAt
// are we partially above if (dst[0].fY < ctop && ChopMonoAtY(dst, ctop, &t)) {
SkChopCubicAt(dst, tmp, t);
dst[0] = tmp[3];
dst[1] = tmp[4];
dst[2] = tmp[5];
}
// are we partially below if (dst[3].fY > cbot && ChopMonoAtY(dst, cbot, &t)) {
SkChopCubicAt(dst, tmp, t);
dst[1] = tmp[1];
dst[2] = tmp[2];
dst[3] = tmp[3];
}
if (reverse) { using std::swap;
swap(dst[0], dst[3]);
swap(dst[1], dst[2]);
} returntrue;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
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.